]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.5-201310162041.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.5-201310162041.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 7f9d4f5..6d1afd6 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 @@ -1932,6 +1936,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 @@ -2199,6 +2207,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 83121b7..ce1a267 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) KERNELRELEASE 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 @@ -1224,6 +1290,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 @@ -1363,17 +1431,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 @@ -1383,11 +1455,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 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
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 d8f9b7e..f6222fa 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 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,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 @@ -1309,6 +1310,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 @@ -1341,20 +1343,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 43594d5..da71e62 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1791,7 +1791,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 4355f0e..c229913 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 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index 04aeb02..73b70dd 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
2095 index f1d96d4..73ddd72 100644
2096 --- a/arch/arm/include/asm/syscall.h
2097 +++ b/arch/arm/include/asm/syscall.h
2098 @@ -57,6 +57,9 @@ static inline void syscall_get_arguments(struct task_struct *task,
2099 unsigned int i, unsigned int n,
2100 unsigned long *args)
2101 {
2102 + if (n == 0)
2103 + return;
2104 +
2105 if (i + n > SYSCALL_MAX_ARGS) {
2106 unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
2107 unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
2108 @@ -81,6 +84,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
2109 unsigned int i, unsigned int n,
2110 const unsigned long *args)
2111 {
2112 + if (n == 0)
2113 + return;
2114 +
2115 if (i + n > SYSCALL_MAX_ARGS) {
2116 pr_warning("%s called with max args %d, handling only %d\n",
2117 __func__, i + n, SYSCALL_MAX_ARGS);
2118 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2119 index 2b8114f..8fe9bcf 100644
2120 --- a/arch/arm/include/asm/thread_info.h
2121 +++ b/arch/arm/include/asm/thread_info.h
2122 @@ -77,9 +77,9 @@ struct thread_info {
2123 .flags = 0, \
2124 .preempt_count = INIT_PREEMPT_COUNT, \
2125 .addr_limit = KERNEL_DS, \
2126 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2127 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2128 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2129 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2130 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2131 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2132 .restart_block = { \
2133 .fn = do_no_restart_syscall, \
2134 }, \
2135 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2136 #define TIF_SYSCALL_AUDIT 9
2137 #define TIF_SYSCALL_TRACEPOINT 10
2138 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2139 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2140 +/* within 8 bits of TIF_SYSCALL_TRACE
2141 + * to meet flexible second operand requirements
2142 + */
2143 +#define TIF_GRSEC_SETXID 12
2144 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2145 #define TIF_USING_IWMMXT 17
2146 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2147 #define TIF_RESTORE_SIGMASK 20
2148 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2149 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2150 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2151 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2152 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2153
2154 /* Checks for any syscall work in entry-common.S */
2155 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2156 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2157 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2158
2159 /*
2160 * Change these and you break ASM code in entry-common.S
2161 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2162 index 7e1f760..de33b13 100644
2163 --- a/arch/arm/include/asm/uaccess.h
2164 +++ b/arch/arm/include/asm/uaccess.h
2165 @@ -18,6 +18,7 @@
2166 #include <asm/domain.h>
2167 #include <asm/unified.h>
2168 #include <asm/compiler.h>
2169 +#include <asm/pgtable.h>
2170
2171 #define VERIFY_READ 0
2172 #define VERIFY_WRITE 1
2173 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2174 static inline void set_fs(mm_segment_t fs)
2175 {
2176 current_thread_info()->addr_limit = fs;
2177 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2178 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2179 }
2180
2181 #define segment_eq(a,b) ((a) == (b))
2182
2183 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2184 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2185 +
2186 +static inline void pax_open_userland(void)
2187 +{
2188 +
2189 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2190 + if (segment_eq(get_fs(), USER_DS)) {
2191 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2192 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2193 + }
2194 +#endif
2195 +
2196 +}
2197 +
2198 +static inline void pax_close_userland(void)
2199 +{
2200 +
2201 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2202 + if (segment_eq(get_fs(), USER_DS)) {
2203 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2204 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2205 + }
2206 +#endif
2207 +
2208 +}
2209 +
2210 #define __addr_ok(addr) ({ \
2211 unsigned long flag; \
2212 __asm__("cmp %2, %0; movlo %0, #0" \
2213 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2214
2215 #define get_user(x,p) \
2216 ({ \
2217 + int __e; \
2218 might_fault(); \
2219 - __get_user_check(x,p); \
2220 + pax_open_userland(); \
2221 + __e = __get_user_check(x,p); \
2222 + pax_close_userland(); \
2223 + __e; \
2224 })
2225
2226 extern int __put_user_1(void *, unsigned int);
2227 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2228
2229 #define put_user(x,p) \
2230 ({ \
2231 + int __e; \
2232 might_fault(); \
2233 - __put_user_check(x,p); \
2234 + pax_open_userland(); \
2235 + __e = __put_user_check(x,p); \
2236 + pax_close_userland(); \
2237 + __e; \
2238 })
2239
2240 #else /* CONFIG_MMU */
2241 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2242 #define __get_user(x,ptr) \
2243 ({ \
2244 long __gu_err = 0; \
2245 + pax_open_userland(); \
2246 __get_user_err((x),(ptr),__gu_err); \
2247 + pax_close_userland(); \
2248 __gu_err; \
2249 })
2250
2251 #define __get_user_error(x,ptr,err) \
2252 ({ \
2253 + pax_open_userland(); \
2254 __get_user_err((x),(ptr),err); \
2255 + pax_close_userland(); \
2256 (void) 0; \
2257 })
2258
2259 @@ -312,13 +352,17 @@ do { \
2260 #define __put_user(x,ptr) \
2261 ({ \
2262 long __pu_err = 0; \
2263 + pax_open_userland(); \
2264 __put_user_err((x),(ptr),__pu_err); \
2265 + pax_close_userland(); \
2266 __pu_err; \
2267 })
2268
2269 #define __put_user_error(x,ptr,err) \
2270 ({ \
2271 + pax_open_userland(); \
2272 __put_user_err((x),(ptr),err); \
2273 + pax_close_userland(); \
2274 (void) 0; \
2275 })
2276
2277 @@ -418,11 +462,44 @@ do { \
2278
2279
2280 #ifdef CONFIG_MMU
2281 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2282 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2283 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2284 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2285 +
2286 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2287 +{
2288 + unsigned long ret;
2289 +
2290 + check_object_size(to, n, false);
2291 + pax_open_userland();
2292 + ret = ___copy_from_user(to, from, n);
2293 + pax_close_userland();
2294 + return ret;
2295 +}
2296 +
2297 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2298 +{
2299 + unsigned long ret;
2300 +
2301 + check_object_size(from, n, true);
2302 + pax_open_userland();
2303 + ret = ___copy_to_user(to, from, n);
2304 + pax_close_userland();
2305 + return ret;
2306 +}
2307 +
2308 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2309 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2310 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2311 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2312 +
2313 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2314 +{
2315 + unsigned long ret;
2316 + pax_open_userland();
2317 + ret = ___clear_user(addr, n);
2318 + pax_close_userland();
2319 + return ret;
2320 +}
2321 +
2322 #else
2323 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2324 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2325 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2326
2327 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2328 {
2329 + if ((long)n < 0)
2330 + return n;
2331 +
2332 if (access_ok(VERIFY_READ, from, n))
2333 n = __copy_from_user(to, from, n);
2334 else /* security hole - plug it */
2335 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2336
2337 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2338 {
2339 + if ((long)n < 0)
2340 + return n;
2341 +
2342 if (access_ok(VERIFY_WRITE, to, n))
2343 n = __copy_to_user(to, from, n);
2344 return n;
2345 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2346 index 5af0ed1..cea83883 100644
2347 --- a/arch/arm/include/uapi/asm/ptrace.h
2348 +++ b/arch/arm/include/uapi/asm/ptrace.h
2349 @@ -92,7 +92,7 @@
2350 * ARMv7 groups of PSR bits
2351 */
2352 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2353 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2354 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2355 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2356 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2357
2358 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2359 index 60d3b73..e5a0f22 100644
2360 --- a/arch/arm/kernel/armksyms.c
2361 +++ b/arch/arm/kernel/armksyms.c
2362 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2363
2364 /* networking */
2365 EXPORT_SYMBOL(csum_partial);
2366 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2367 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2368 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2369 EXPORT_SYMBOL(__csum_ipv6_magic);
2370
2371 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2372 #ifdef CONFIG_MMU
2373 EXPORT_SYMBOL(copy_page);
2374
2375 -EXPORT_SYMBOL(__copy_from_user);
2376 -EXPORT_SYMBOL(__copy_to_user);
2377 -EXPORT_SYMBOL(__clear_user);
2378 +EXPORT_SYMBOL(___copy_from_user);
2379 +EXPORT_SYMBOL(___copy_to_user);
2380 +EXPORT_SYMBOL(___clear_user);
2381
2382 EXPORT_SYMBOL(__get_user_1);
2383 EXPORT_SYMBOL(__get_user_2);
2384 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2385 index 9cbe70c..a7b5e34 100644
2386 --- a/arch/arm/kernel/entry-armv.S
2387 +++ b/arch/arm/kernel/entry-armv.S
2388 @@ -47,6 +47,87 @@
2389 9997:
2390 .endm
2391
2392 + .macro pax_enter_kernel
2393 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2394 + @ make aligned space for saved DACR
2395 + sub sp, sp, #8
2396 + @ save regs
2397 + stmdb sp!, {r1, r2}
2398 + @ read DACR from cpu_domain into r1
2399 + mov r2, sp
2400 + @ assume 8K pages, since we have to split the immediate in two
2401 + bic r2, r2, #(0x1fc0)
2402 + bic r2, r2, #(0x3f)
2403 + ldr r1, [r2, #TI_CPU_DOMAIN]
2404 + @ store old DACR on stack
2405 + str r1, [sp, #8]
2406 +#ifdef CONFIG_PAX_KERNEXEC
2407 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2408 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2409 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2410 +#endif
2411 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2412 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 +#endif
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r2, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r1, r2}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_open_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2439 + @ write r1 to current_thread_info()->cpu_domain
2440 + str r1, [r0, #TI_CPU_DOMAIN]
2441 + @ write r1 to DACR
2442 + mcr p15, 0, r1, c3, c0, 0
2443 + @ instruction sync
2444 + instr_sync
2445 + @ restore regs
2446 + ldmia sp!, {r0, r1}
2447 +#endif
2448 + .endm
2449 +
2450 + .macro pax_close_userland
2451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2452 + @ save regs
2453 + stmdb sp!, {r0, r1}
2454 + @ read DACR from cpu_domain into r1
2455 + mov r0, sp
2456 + @ assume 8K pages, since we have to split the immediate in two
2457 + bic r0, r0, #(0x1fc0)
2458 + bic r0, r0, #(0x3f)
2459 + ldr r1, [r0, #TI_CPU_DOMAIN]
2460 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2461 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2462 + @ write r1 to current_thread_info()->cpu_domain
2463 + str r1, [r0, #TI_CPU_DOMAIN]
2464 + @ write r1 to DACR
2465 + mcr p15, 0, r1, c3, c0, 0
2466 + @ instruction sync
2467 + instr_sync
2468 + @ restore regs
2469 + ldmia sp!, {r0, r1}
2470 +#endif
2471 + .endm
2472 +
2473 .macro pabt_helper
2474 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2475 #ifdef MULTI_PABORT
2476 @@ -89,11 +170,15 @@
2477 * Invalid mode handlers
2478 */
2479 .macro inv_entry, reason
2480 +
2481 + pax_enter_kernel
2482 +
2483 sub sp, sp, #S_FRAME_SIZE
2484 ARM( stmib sp, {r1 - lr} )
2485 THUMB( stmia sp, {r0 - r12} )
2486 THUMB( str sp, [sp, #S_SP] )
2487 THUMB( str lr, [sp, #S_LR] )
2488 +
2489 mov r1, #\reason
2490 .endm
2491
2492 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2493 .macro svc_entry, stack_hole=0
2494 UNWIND(.fnstart )
2495 UNWIND(.save {r0 - pc} )
2496 +
2497 + pax_enter_kernel
2498 +
2499 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2500 +
2501 #ifdef CONFIG_THUMB2_KERNEL
2502 SPFIX( str r0, [sp] ) @ temporarily saved
2503 SPFIX( mov r0, sp )
2504 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2505 ldmia r0, {r3 - r5}
2506 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2507 mov r6, #-1 @ "" "" "" ""
2508 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2509 + @ offset sp by 8 as done in pax_enter_kernel
2510 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2511 +#else
2512 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2513 +#endif
2514 SPFIX( addeq r2, r2, #4 )
2515 str r3, [sp, #-4]! @ save the "real" r0 copied
2516 @ from the exception stack
2517 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2518 .macro usr_entry
2519 UNWIND(.fnstart )
2520 UNWIND(.cantunwind ) @ don't unwind the user space
2521 +
2522 + pax_enter_kernel_user
2523 +
2524 sub sp, sp, #S_FRAME_SIZE
2525 ARM( stmib sp, {r1 - r12} )
2526 THUMB( stmia sp, {r0 - r12} )
2527 @@ -415,7 +512,9 @@ __und_usr:
2528 tst r3, #PSR_T_BIT @ Thumb mode?
2529 bne __und_usr_thumb
2530 sub r4, r2, #4 @ ARM instr at LR - 4
2531 + pax_open_userland
2532 1: ldrt r0, [r4]
2533 + pax_close_userland
2534 #ifdef CONFIG_CPU_ENDIAN_BE8
2535 rev r0, r0 @ little endian instruction
2536 #endif
2537 @@ -450,10 +549,14 @@ __und_usr_thumb:
2538 */
2539 .arch armv6t2
2540 #endif
2541 + pax_open_userland
2542 2: ldrht r5, [r4]
2543 + pax_close_userland
2544 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2545 blo __und_usr_fault_16 @ 16bit undefined instruction
2546 + pax_open_userland
2547 3: ldrht r0, [r2]
2548 + pax_close_userland
2549 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2550 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2551 orr r0, r0, r5, lsl #16
2552 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2553 */
2554 .pushsection .fixup, "ax"
2555 .align 2
2556 -4: mov pc, r9
2557 +4: pax_close_userland
2558 + mov pc, r9
2559 .popsection
2560 .pushsection __ex_table,"a"
2561 .long 1b, 4b
2562 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2563 THUMB( str lr, [ip], #4 )
2564 ldr r4, [r2, #TI_TP_VALUE]
2565 ldr r5, [r2, #TI_TP_VALUE + 4]
2566 -#ifdef CONFIG_CPU_USE_DOMAINS
2567 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2568 ldr r6, [r2, #TI_CPU_DOMAIN]
2569 #endif
2570 switch_tls r1, r4, r5, r3, r7
2571 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2572 ldr r8, =__stack_chk_guard
2573 ldr r7, [r7, #TSK_STACK_CANARY]
2574 #endif
2575 -#ifdef CONFIG_CPU_USE_DOMAINS
2576 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2577 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2578 #endif
2579 mov r5, r0
2580 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2581 index 94104bf..e425391 100644
2582 --- a/arch/arm/kernel/entry-common.S
2583 +++ b/arch/arm/kernel/entry-common.S
2584 @@ -10,18 +10,46 @@
2585
2586 #include <asm/unistd.h>
2587 #include <asm/ftrace.h>
2588 +#include <asm/domain.h>
2589 #include <asm/unwind.h>
2590
2591 +#include "entry-header.S"
2592 +
2593 #ifdef CONFIG_NEED_RET_TO_USER
2594 #include <mach/entry-macro.S>
2595 #else
2596 .macro arch_ret_to_user, tmp1, tmp2
2597 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2598 + @ save regs
2599 + stmdb sp!, {r1, r2}
2600 + @ read DACR from cpu_domain into r1
2601 + mov r2, sp
2602 + @ assume 8K pages, since we have to split the immediate in two
2603 + bic r2, r2, #(0x1fc0)
2604 + bic r2, r2, #(0x3f)
2605 + ldr r1, [r2, #TI_CPU_DOMAIN]
2606 +#ifdef CONFIG_PAX_KERNEXEC
2607 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2608 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2609 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2610 +#endif
2611 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2612 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2613 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2614 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2615 +#endif
2616 + @ write r1 to current_thread_info()->cpu_domain
2617 + str r1, [r2, #TI_CPU_DOMAIN]
2618 + @ write r1 to DACR
2619 + mcr p15, 0, r1, c3, c0, 0
2620 + @ instruction sync
2621 + instr_sync
2622 + @ restore regs
2623 + ldmia sp!, {r1, r2}
2624 +#endif
2625 .endm
2626 #endif
2627
2628 -#include "entry-header.S"
2629 -
2630 -
2631 .align 5
2632 /*
2633 * This is the fast syscall return path. We do as little as
2634 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2635 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2636 #endif
2637
2638 + /*
2639 + * do this here to avoid a performance hit of wrapping the code above
2640 + * that directly dereferences userland to parse the SWI instruction
2641 + */
2642 + pax_enter_kernel_user
2643 +
2644 adr tbl, sys_call_table @ load syscall table pointer
2645
2646 #if defined(CONFIG_OABI_COMPAT)
2647 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2648 index de23a9b..94c37c4 100644
2649 --- a/arch/arm/kernel/entry-header.S
2650 +++ b/arch/arm/kernel/entry-header.S
2651 @@ -184,6 +184,60 @@
2652 msr cpsr_c, \rtemp @ switch back to the SVC mode
2653 .endm
2654
2655 + .macro pax_enter_kernel_user
2656 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2657 + @ save regs
2658 + stmdb sp!, {r0, r1}
2659 + @ read DACR from cpu_domain into r1
2660 + mov r0, sp
2661 + @ assume 8K pages, since we have to split the immediate in two
2662 + bic r0, r0, #(0x1fc0)
2663 + bic r0, r0, #(0x3f)
2664 + ldr r1, [r0, #TI_CPU_DOMAIN]
2665 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2666 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2667 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2668 +#endif
2669 +#ifdef CONFIG_PAX_KERNEXEC
2670 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2671 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2672 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2673 +#endif
2674 + @ write r1 to current_thread_info()->cpu_domain
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 + .macro pax_exit_kernel
2686 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2687 + @ save regs
2688 + stmdb sp!, {r0, r1}
2689 + @ read old DACR from stack into r1
2690 + ldr r1, [sp, #(8 + S_SP)]
2691 + sub r1, r1, #8
2692 + ldr r1, [r1]
2693 +
2694 + @ write r1 to current_thread_info()->cpu_domain
2695 + mov r0, sp
2696 + @ assume 8K pages, since we have to split the immediate in two
2697 + bic r0, r0, #(0x1fc0)
2698 + bic r0, r0, #(0x3f)
2699 + str r1, [r0, #TI_CPU_DOMAIN]
2700 + @ write r1 to DACR
2701 + mcr p15, 0, r1, c3, c0, 0
2702 + @ instruction sync
2703 + instr_sync
2704 + @ restore regs
2705 + ldmia sp!, {r0, r1}
2706 +#endif
2707 + .endm
2708 +
2709 #ifndef CONFIG_THUMB2_KERNEL
2710 .macro svc_exit, rpsr, irq = 0
2711 .if \irq != 0
2712 @@ -203,6 +257,9 @@
2713 blne trace_hardirqs_off
2714 #endif
2715 .endif
2716 +
2717 + pax_exit_kernel
2718 +
2719 msr spsr_cxsf, \rpsr
2720 #if defined(CONFIG_CPU_V6)
2721 ldr r0, [sp]
2722 @@ -266,6 +323,9 @@
2723 blne trace_hardirqs_off
2724 #endif
2725 .endif
2726 +
2727 + pax_exit_kernel
2728 +
2729 ldr lr, [sp, #S_SP] @ top of the stack
2730 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2731 clrex @ clear the exclusive monitor
2732 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2733 index 918875d..cd5fa27 100644
2734 --- a/arch/arm/kernel/fiq.c
2735 +++ b/arch/arm/kernel/fiq.c
2736 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2737 void *base = vectors_page;
2738 unsigned offset = FIQ_OFFSET;
2739
2740 + pax_open_kernel();
2741 memcpy(base + offset, start, length);
2742 + pax_close_kernel();
2743 +
2744 if (!cache_is_vipt_nonaliasing())
2745 flush_icache_range((unsigned long)base + offset, offset +
2746 length);
2747 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2748 index 2c7cc1e..ab2e911 100644
2749 --- a/arch/arm/kernel/head.S
2750 +++ b/arch/arm/kernel/head.S
2751 @@ -52,7 +52,9 @@
2752 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2753
2754 .macro pgtbl, rd, phys
2755 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2756 + mov \rd, #TEXT_OFFSET
2757 + sub \rd, #PG_DIR_SIZE
2758 + add \rd, \rd, \phys
2759 .endm
2760
2761 /*
2762 @@ -432,7 +434,7 @@ __enable_mmu:
2763 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2764 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2765 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2766 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2767 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2768 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2769 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2770 #endif
2771 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2772 index 85c3fb6..054c2dc 100644
2773 --- a/arch/arm/kernel/module.c
2774 +++ b/arch/arm/kernel/module.c
2775 @@ -37,12 +37,39 @@
2776 #endif
2777
2778 #ifdef CONFIG_MMU
2779 -void *module_alloc(unsigned long size)
2780 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2781 {
2782 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2783 + return NULL;
2784 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2785 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2786 + GFP_KERNEL, prot, -1,
2787 __builtin_return_address(0));
2788 }
2789 +
2790 +void *module_alloc(unsigned long size)
2791 +{
2792 +
2793 +#ifdef CONFIG_PAX_KERNEXEC
2794 + return __module_alloc(size, PAGE_KERNEL);
2795 +#else
2796 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2797 +#endif
2798 +
2799 +}
2800 +
2801 +#ifdef CONFIG_PAX_KERNEXEC
2802 +void module_free_exec(struct module *mod, void *module_region)
2803 +{
2804 + module_free(mod, module_region);
2805 +}
2806 +EXPORT_SYMBOL(module_free_exec);
2807 +
2808 +void *module_alloc_exec(unsigned long size)
2809 +{
2810 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2811 +}
2812 +EXPORT_SYMBOL(module_alloc_exec);
2813 +#endif
2814 #endif
2815
2816 int
2817 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2818 index 07314af..c46655c 100644
2819 --- a/arch/arm/kernel/patch.c
2820 +++ b/arch/arm/kernel/patch.c
2821 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2822 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2823 int size;
2824
2825 + pax_open_kernel();
2826 if (thumb2 && __opcode_is_thumb16(insn)) {
2827 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2828 size = sizeof(u16);
2829 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2830 *(u32 *)addr = insn;
2831 size = sizeof(u32);
2832 }
2833 + pax_close_kernel();
2834
2835 flush_icache_range((uintptr_t)(addr),
2836 (uintptr_t)(addr) + size);
2837 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2838 index 94f6b05..efd7312 100644
2839 --- a/arch/arm/kernel/process.c
2840 +++ b/arch/arm/kernel/process.c
2841 @@ -217,6 +217,7 @@ void machine_power_off(void)
2842
2843 if (pm_power_off)
2844 pm_power_off();
2845 + BUG();
2846 }
2847
2848 /*
2849 @@ -230,7 +231,7 @@ void machine_power_off(void)
2850 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2851 * to use. Implementing such co-ordination would be essentially impossible.
2852 */
2853 -void machine_restart(char *cmd)
2854 +__noreturn void machine_restart(char *cmd)
2855 {
2856 local_irq_disable();
2857 smp_send_stop();
2858 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2859
2860 show_regs_print_info(KERN_DEFAULT);
2861
2862 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2863 - print_symbol("LR is at %s\n", regs->ARM_lr);
2864 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2865 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2866 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2867 "sp : %08lx ip : %08lx fp : %08lx\n",
2868 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2869 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2870 return 0;
2871 }
2872
2873 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2874 -{
2875 - unsigned long range_end = mm->brk + 0x02000000;
2876 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2877 -}
2878 -
2879 #ifdef CONFIG_MMU
2880 #ifdef CONFIG_KUSER_HELPERS
2881 /*
2882 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2883
2884 static int __init gate_vma_init(void)
2885 {
2886 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2887 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2888 return 0;
2889 }
2890 arch_initcall(gate_vma_init);
2891 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2892
2893 const char *arch_vma_name(struct vm_area_struct *vma)
2894 {
2895 - return is_gate_vma(vma) ? "[vectors]" :
2896 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2897 - "[sigpage]" : NULL;
2898 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2899 }
2900
2901 -static struct page *signal_page;
2902 -extern struct page *get_signal_page(void);
2903 -
2904 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2905 {
2906 struct mm_struct *mm = current->mm;
2907 - unsigned long addr;
2908 - int ret;
2909 -
2910 - if (!signal_page)
2911 - signal_page = get_signal_page();
2912 - if (!signal_page)
2913 - return -ENOMEM;
2914
2915 down_write(&mm->mmap_sem);
2916 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2917 - if (IS_ERR_VALUE(addr)) {
2918 - ret = addr;
2919 - goto up_fail;
2920 - }
2921 -
2922 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2923 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2924 - &signal_page);
2925 -
2926 - if (ret == 0)
2927 - mm->context.sigpage = addr;
2928 -
2929 - up_fail:
2930 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2931 up_write(&mm->mmap_sem);
2932 - return ret;
2933 + return 0;
2934 }
2935 #endif
2936 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2937 index 4693188..4596c5e 100644
2938 --- a/arch/arm/kernel/psci.c
2939 +++ b/arch/arm/kernel/psci.c
2940 @@ -24,7 +24,7 @@
2941 #include <asm/opcodes-virt.h>
2942 #include <asm/psci.h>
2943
2944 -struct psci_operations psci_ops;
2945 +struct psci_operations psci_ops __read_only;
2946
2947 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2948
2949 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2950 index 0dd3b79..e018f64 100644
2951 --- a/arch/arm/kernel/ptrace.c
2952 +++ b/arch/arm/kernel/ptrace.c
2953 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2954 return current_thread_info()->syscall;
2955 }
2956
2957 +#ifdef CONFIG_GRKERNSEC_SETXID
2958 +extern void gr_delayed_cred_worker(void);
2959 +#endif
2960 +
2961 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2962 {
2963 current_thread_info()->syscall = scno;
2964
2965 +#ifdef CONFIG_GRKERNSEC_SETXID
2966 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2967 + gr_delayed_cred_worker();
2968 +#endif
2969 +
2970 /* Do the secure computing check first; failures should be fast. */
2971 if (secure_computing(scno) == -1)
2972 return -1;
2973 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2974 index afc2489..6372bc8 100644
2975 --- a/arch/arm/kernel/setup.c
2976 +++ b/arch/arm/kernel/setup.c
2977 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2978 unsigned int elf_hwcap __read_mostly;
2979 EXPORT_SYMBOL(elf_hwcap);
2980
2981 +pteval_t __supported_pte_mask __read_only;
2982 +pmdval_t __supported_pmd_mask __read_only;
2983
2984 #ifdef MULTI_CPU
2985 -struct processor processor __read_mostly;
2986 +struct processor processor;
2987 #endif
2988 #ifdef MULTI_TLB
2989 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2990 +struct cpu_tlb_fns cpu_tlb __read_only;
2991 #endif
2992 #ifdef MULTI_USER
2993 -struct cpu_user_fns cpu_user __read_mostly;
2994 +struct cpu_user_fns cpu_user __read_only;
2995 #endif
2996 #ifdef MULTI_CACHE
2997 -struct cpu_cache_fns cpu_cache __read_mostly;
2998 +struct cpu_cache_fns cpu_cache __read_only;
2999 #endif
3000 #ifdef CONFIG_OUTER_CACHE
3001 -struct outer_cache_fns outer_cache __read_mostly;
3002 +struct outer_cache_fns outer_cache __read_only;
3003 EXPORT_SYMBOL(outer_cache);
3004 #endif
3005
3006 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
3007 asm("mrc p15, 0, %0, c0, c1, 4"
3008 : "=r" (mmfr0));
3009 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3010 - (mmfr0 & 0x000000f0) >= 0x00000030)
3011 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3012 cpu_arch = CPU_ARCH_ARMv7;
3013 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3014 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3015 + __supported_pte_mask |= L_PTE_PXN;
3016 + __supported_pmd_mask |= PMD_PXNTABLE;
3017 + }
3018 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3019 (mmfr0 & 0x000000f0) == 0x00000020)
3020 cpu_arch = CPU_ARCH_ARMv6;
3021 else
3022 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
3023 __cpu_architecture = __get_cpu_architecture();
3024
3025 #ifdef MULTI_CPU
3026 - processor = *list->proc;
3027 + memcpy((void *)&processor, list->proc, sizeof processor);
3028 #endif
3029 #ifdef MULTI_TLB
3030 cpu_tlb = *list->tlb;
3031 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3032 index ab33042..11248a8 100644
3033 --- a/arch/arm/kernel/signal.c
3034 +++ b/arch/arm/kernel/signal.c
3035 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3036 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3037 };
3038
3039 -static unsigned long signal_return_offset;
3040 -
3041 #ifdef CONFIG_CRUNCH
3042 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3043 {
3044 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3045 * except when the MPU has protected the vectors
3046 * page from PL0
3047 */
3048 - retcode = mm->context.sigpage + signal_return_offset +
3049 - (idx << 2) + thumb;
3050 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3051 } else
3052 #endif
3053 {
3054 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3055 } while (thread_flags & _TIF_WORK_MASK);
3056 return 0;
3057 }
3058 -
3059 -struct page *get_signal_page(void)
3060 -{
3061 - unsigned long ptr;
3062 - unsigned offset;
3063 - struct page *page;
3064 - void *addr;
3065 -
3066 - page = alloc_pages(GFP_KERNEL, 0);
3067 -
3068 - if (!page)
3069 - return NULL;
3070 -
3071 - addr = page_address(page);
3072 -
3073 - /* Give the signal return code some randomness */
3074 - offset = 0x200 + (get_random_int() & 0x7fc);
3075 - signal_return_offset = offset;
3076 -
3077 - /*
3078 - * Copy signal return handlers into the vector page, and
3079 - * set sigreturn to be a pointer to these.
3080 - */
3081 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3082 -
3083 - ptr = (unsigned long)addr + offset;
3084 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3085 -
3086 - return page;
3087 -}
3088 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3089 index 2dc1934..ecf0e21 100644
3090 --- a/arch/arm/kernel/smp.c
3091 +++ b/arch/arm/kernel/smp.c
3092 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3093
3094 static DECLARE_COMPLETION(cpu_running);
3095
3096 -static struct smp_operations smp_ops;
3097 +static struct smp_operations smp_ops __read_only;
3098
3099 void __init smp_set_ops(struct smp_operations *ops)
3100 {
3101 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3102 index ab517fc..9adf2fa 100644
3103 --- a/arch/arm/kernel/traps.c
3104 +++ b/arch/arm/kernel/traps.c
3105 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3106 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3107 {
3108 #ifdef CONFIG_KALLSYMS
3109 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3110 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3111 #else
3112 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3113 #endif
3114 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3115 static int die_owner = -1;
3116 static unsigned int die_nest_count;
3117
3118 +extern void gr_handle_kernel_exploit(void);
3119 +
3120 static unsigned long oops_begin(void)
3121 {
3122 int cpu;
3123 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3124 panic("Fatal exception in interrupt");
3125 if (panic_on_oops)
3126 panic("Fatal exception");
3127 +
3128 + gr_handle_kernel_exploit();
3129 +
3130 if (signr)
3131 do_exit(signr);
3132 }
3133 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3134 * The user helper at 0xffff0fe0 must be used instead.
3135 * (see entry-armv.S for details)
3136 */
3137 + pax_open_kernel();
3138 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3139 + pax_close_kernel();
3140 }
3141 return 0;
3142
3143 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3144 kuser_init(vectors_base);
3145
3146 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3147 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3148 +
3149 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3150 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3151 +#endif
3152 +
3153 #else /* ifndef CONFIG_CPU_V7M */
3154 /*
3155 * on V7-M there is no need to copy the vector table to a dedicated
3156 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3157 index 7bcee5c..e2f3249 100644
3158 --- a/arch/arm/kernel/vmlinux.lds.S
3159 +++ b/arch/arm/kernel/vmlinux.lds.S
3160 @@ -8,7 +8,11 @@
3161 #include <asm/thread_info.h>
3162 #include <asm/memory.h>
3163 #include <asm/page.h>
3164 -
3165 +
3166 +#ifdef CONFIG_PAX_KERNEXEC
3167 +#include <asm/pgtable.h>
3168 +#endif
3169 +
3170 #define PROC_INFO \
3171 . = ALIGN(4); \
3172 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3173 @@ -34,7 +38,7 @@
3174 #endif
3175
3176 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3177 - defined(CONFIG_GENERIC_BUG)
3178 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3179 #define ARM_EXIT_KEEP(x) x
3180 #define ARM_EXIT_DISCARD(x)
3181 #else
3182 @@ -90,6 +94,11 @@ SECTIONS
3183 _text = .;
3184 HEAD_TEXT
3185 }
3186 +
3187 +#ifdef CONFIG_PAX_KERNEXEC
3188 + . = ALIGN(1<<SECTION_SHIFT);
3189 +#endif
3190 +
3191 .text : { /* Real text segment */
3192 _stext = .; /* Text and read-only data */
3193 __exception_text_start = .;
3194 @@ -112,6 +121,8 @@ SECTIONS
3195 ARM_CPU_KEEP(PROC_INFO)
3196 }
3197
3198 + _etext = .; /* End of text section */
3199 +
3200 RO_DATA(PAGE_SIZE)
3201
3202 . = ALIGN(4);
3203 @@ -142,7 +153,9 @@ SECTIONS
3204
3205 NOTES
3206
3207 - _etext = .; /* End of text and rodata section */
3208 +#ifdef CONFIG_PAX_KERNEXEC
3209 + . = ALIGN(1<<SECTION_SHIFT);
3210 +#endif
3211
3212 #ifndef CONFIG_XIP_KERNEL
3213 . = ALIGN(PAGE_SIZE);
3214 @@ -220,6 +233,11 @@ SECTIONS
3215 . = PAGE_OFFSET + TEXT_OFFSET;
3216 #else
3217 __init_end = .;
3218 +
3219 +#ifdef CONFIG_PAX_KERNEXEC
3220 + . = ALIGN(1<<SECTION_SHIFT);
3221 +#endif
3222 +
3223 . = ALIGN(THREAD_SIZE);
3224 __data_loc = .;
3225 #endif
3226 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3227 index 741f66a..8a5615c 100644
3228 --- a/arch/arm/kvm/arm.c
3229 +++ b/arch/arm/kvm/arm.c
3230 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3231 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3232
3233 /* The VMID used in the VTTBR */
3234 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3235 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3236 static u8 kvm_next_vmid;
3237 static DEFINE_SPINLOCK(kvm_vmid_lock);
3238
3239 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3240 */
3241 static bool need_new_vmid_gen(struct kvm *kvm)
3242 {
3243 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3244 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3245 }
3246
3247 /**
3248 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3249
3250 /* First user of a new VMID generation? */
3251 if (unlikely(kvm_next_vmid == 0)) {
3252 - atomic64_inc(&kvm_vmid_gen);
3253 + atomic64_inc_unchecked(&kvm_vmid_gen);
3254 kvm_next_vmid = 1;
3255
3256 /*
3257 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3258 kvm_call_hyp(__kvm_flush_vm_context);
3259 }
3260
3261 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3262 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3263 kvm->arch.vmid = kvm_next_vmid;
3264 kvm_next_vmid++;
3265
3266 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3267 index 14a0d98..7771a7d 100644
3268 --- a/arch/arm/lib/clear_user.S
3269 +++ b/arch/arm/lib/clear_user.S
3270 @@ -12,14 +12,14 @@
3271
3272 .text
3273
3274 -/* Prototype: int __clear_user(void *addr, size_t sz)
3275 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3276 * Purpose : clear some user memory
3277 * Params : addr - user memory address to clear
3278 * : sz - number of bytes to clear
3279 * Returns : number of bytes NOT cleared
3280 */
3281 ENTRY(__clear_user_std)
3282 -WEAK(__clear_user)
3283 +WEAK(___clear_user)
3284 stmfd sp!, {r1, lr}
3285 mov r2, #0
3286 cmp r1, #4
3287 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3288 USER( strnebt r2, [r0])
3289 mov r0, #0
3290 ldmfd sp!, {r1, pc}
3291 -ENDPROC(__clear_user)
3292 +ENDPROC(___clear_user)
3293 ENDPROC(__clear_user_std)
3294
3295 .pushsection .fixup,"ax"
3296 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3297 index 66a477a..bee61d3 100644
3298 --- a/arch/arm/lib/copy_from_user.S
3299 +++ b/arch/arm/lib/copy_from_user.S
3300 @@ -16,7 +16,7 @@
3301 /*
3302 * Prototype:
3303 *
3304 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3305 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3306 *
3307 * Purpose:
3308 *
3309 @@ -84,11 +84,11 @@
3310
3311 .text
3312
3313 -ENTRY(__copy_from_user)
3314 +ENTRY(___copy_from_user)
3315
3316 #include "copy_template.S"
3317
3318 -ENDPROC(__copy_from_user)
3319 +ENDPROC(___copy_from_user)
3320
3321 .pushsection .fixup,"ax"
3322 .align 0
3323 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3324 index 6ee2f67..d1cce76 100644
3325 --- a/arch/arm/lib/copy_page.S
3326 +++ b/arch/arm/lib/copy_page.S
3327 @@ -10,6 +10,7 @@
3328 * ASM optimised string functions
3329 */
3330 #include <linux/linkage.h>
3331 +#include <linux/const.h>
3332 #include <asm/assembler.h>
3333 #include <asm/asm-offsets.h>
3334 #include <asm/cache.h>
3335 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3336 index d066df6..df28194 100644
3337 --- a/arch/arm/lib/copy_to_user.S
3338 +++ b/arch/arm/lib/copy_to_user.S
3339 @@ -16,7 +16,7 @@
3340 /*
3341 * Prototype:
3342 *
3343 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3344 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3345 *
3346 * Purpose:
3347 *
3348 @@ -88,11 +88,11 @@
3349 .text
3350
3351 ENTRY(__copy_to_user_std)
3352 -WEAK(__copy_to_user)
3353 +WEAK(___copy_to_user)
3354
3355 #include "copy_template.S"
3356
3357 -ENDPROC(__copy_to_user)
3358 +ENDPROC(___copy_to_user)
3359 ENDPROC(__copy_to_user_std)
3360
3361 .pushsection .fixup,"ax"
3362 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3363 index 7d08b43..f7ca7ea 100644
3364 --- a/arch/arm/lib/csumpartialcopyuser.S
3365 +++ b/arch/arm/lib/csumpartialcopyuser.S
3366 @@ -57,8 +57,8 @@
3367 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3368 */
3369
3370 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3371 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3372 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3373 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3374
3375 #include "csumpartialcopygeneric.S"
3376
3377 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3378 index 5306de3..aed6d03 100644
3379 --- a/arch/arm/lib/delay.c
3380 +++ b/arch/arm/lib/delay.c
3381 @@ -28,7 +28,7 @@
3382 /*
3383 * Default to the loop-based delay implementation.
3384 */
3385 -struct arm_delay_ops arm_delay_ops = {
3386 +struct arm_delay_ops arm_delay_ops __read_only = {
3387 .delay = __loop_delay,
3388 .const_udelay = __loop_const_udelay,
3389 .udelay = __loop_udelay,
3390 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3391 index 025f742..a9e5b3b 100644
3392 --- a/arch/arm/lib/uaccess_with_memcpy.c
3393 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3394 @@ -104,7 +104,7 @@ out:
3395 }
3396
3397 unsigned long
3398 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3399 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3400 {
3401 /*
3402 * This test is stubbed out of the main function above to keep
3403 @@ -155,7 +155,7 @@ out:
3404 return n;
3405 }
3406
3407 -unsigned long __clear_user(void __user *addr, unsigned long n)
3408 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3409 {
3410 /* See rational for this in __copy_to_user() above. */
3411 if (n < 64)
3412 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3413 index e9238b5..6ed904a 100644
3414 --- a/arch/arm/mach-kirkwood/common.c
3415 +++ b/arch/arm/mach-kirkwood/common.c
3416 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3417 clk_gate_ops.disable(hw);
3418 }
3419
3420 -static struct clk_ops clk_gate_fn_ops;
3421 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3422 +{
3423 + return clk_gate_ops.is_enabled(hw);
3424 +}
3425 +
3426 +static struct clk_ops clk_gate_fn_ops = {
3427 + .enable = clk_gate_fn_enable,
3428 + .disable = clk_gate_fn_disable,
3429 + .is_enabled = clk_gate_fn_is_enabled,
3430 +};
3431
3432 static struct clk __init *clk_register_gate_fn(struct device *dev,
3433 const char *name,
3434 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3435 gate_fn->fn_en = fn_en;
3436 gate_fn->fn_dis = fn_dis;
3437
3438 - /* ops is the gate ops, but with our enable/disable functions */
3439 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3440 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3441 - clk_gate_fn_ops = clk_gate_ops;
3442 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3443 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3444 - }
3445 -
3446 clk = clk_register(dev, &gate_fn->gate.hw);
3447
3448 if (IS_ERR(clk))
3449 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3450 index 827d1500..2885dc6 100644
3451 --- a/arch/arm/mach-omap2/board-n8x0.c
3452 +++ b/arch/arm/mach-omap2/board-n8x0.c
3453 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3454 }
3455 #endif
3456
3457 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3458 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3459 .late_init = n8x0_menelaus_late_init,
3460 };
3461
3462 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3463 index f3fdd6a..3564800 100644
3464 --- a/arch/arm/mach-omap2/gpmc.c
3465 +++ b/arch/arm/mach-omap2/gpmc.c
3466 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3467 };
3468
3469 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3470 -static struct irq_chip gpmc_irq_chip;
3471 static unsigned gpmc_irq_start;
3472
3473 static struct resource gpmc_mem_root;
3474 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3475
3476 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3477
3478 +static struct irq_chip gpmc_irq_chip = {
3479 + .name = "gpmc",
3480 + .irq_startup = gpmc_irq_noop_ret,
3481 + .irq_enable = gpmc_irq_enable,
3482 + .irq_disable = gpmc_irq_disable,
3483 + .irq_shutdown = gpmc_irq_noop,
3484 + .irq_ack = gpmc_irq_noop,
3485 + .irq_mask = gpmc_irq_noop,
3486 + .irq_unmask = gpmc_irq_noop,
3487 +
3488 +};
3489 +
3490 static int gpmc_setup_irq(void)
3491 {
3492 int i;
3493 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3494 return gpmc_irq_start;
3495 }
3496
3497 - gpmc_irq_chip.name = "gpmc";
3498 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3499 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3500 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3501 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3502 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3503 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3504 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3505 -
3506 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3507 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3508
3509 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3510 index f991016..145ebeb 100644
3511 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3512 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3513 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3514 int (*finish_suspend)(unsigned long cpu_state);
3515 void (*resume)(void);
3516 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3517 -};
3518 +} __no_const;
3519
3520 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3521 static struct powerdomain *mpuss_pd;
3522 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3523 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3524 {}
3525
3526 -struct cpu_pm_ops omap_pm_ops = {
3527 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3528 .finish_suspend = default_finish_suspend,
3529 .resume = dummy_cpu_resume,
3530 .scu_prepare = dummy_scu_prepare,
3531 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3532 index 813c615..ce467c6 100644
3533 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3534 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3535 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3536 return NOTIFY_OK;
3537 }
3538
3539 -static struct notifier_block __refdata irq_hotplug_notifier = {
3540 +static struct notifier_block irq_hotplug_notifier = {
3541 .notifier_call = irq_cpu_hotplug_notify,
3542 };
3543
3544 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3545 index f99f68e..e573e20 100644
3546 --- a/arch/arm/mach-omap2/omap_device.c
3547 +++ b/arch/arm/mach-omap2/omap_device.c
3548 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3549 struct platform_device __init *omap_device_build(const char *pdev_name,
3550 int pdev_id,
3551 struct omap_hwmod *oh,
3552 - void *pdata, int pdata_len)
3553 + const void *pdata, int pdata_len)
3554 {
3555 struct omap_hwmod *ohs[] = { oh };
3556
3557 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3558 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3559 int pdev_id,
3560 struct omap_hwmod **ohs,
3561 - int oh_cnt, void *pdata,
3562 + int oh_cnt, const void *pdata,
3563 int pdata_len)
3564 {
3565 int ret = -ENOMEM;
3566 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3567 index 17ca1ae..beba869 100644
3568 --- a/arch/arm/mach-omap2/omap_device.h
3569 +++ b/arch/arm/mach-omap2/omap_device.h
3570 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3571 /* Core code interface */
3572
3573 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3574 - struct omap_hwmod *oh, void *pdata,
3575 + struct omap_hwmod *oh, const void *pdata,
3576 int pdata_len);
3577
3578 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3579 struct omap_hwmod **oh, int oh_cnt,
3580 - void *pdata, int pdata_len);
3581 + const void *pdata, int pdata_len);
3582
3583 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3584 struct omap_hwmod **ohs, int oh_cnt);
3585 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3586 index 7f4db12..0243012 100644
3587 --- a/arch/arm/mach-omap2/omap_hwmod.c
3588 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3589 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3590 int (*init_clkdm)(struct omap_hwmod *oh);
3591 void (*update_context_lost)(struct omap_hwmod *oh);
3592 int (*get_context_lost)(struct omap_hwmod *oh);
3593 -};
3594 +} __no_const;
3595
3596 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3597 -static struct omap_hwmod_soc_ops soc_ops;
3598 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3599
3600 /* omap_hwmod_list contains all registered struct omap_hwmods */
3601 static LIST_HEAD(omap_hwmod_list);
3602 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3603 index d15c7bb..b2d1f0c 100644
3604 --- a/arch/arm/mach-omap2/wd_timer.c
3605 +++ b/arch/arm/mach-omap2/wd_timer.c
3606 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3607 struct omap_hwmod *oh;
3608 char *oh_name = "wd_timer2";
3609 char *dev_name = "omap_wdt";
3610 - struct omap_wd_timer_platform_data pdata;
3611 + static struct omap_wd_timer_platform_data pdata = {
3612 + .read_reset_sources = prm_read_reset_sources
3613 + };
3614
3615 if (!cpu_class_is_omap2() || of_have_populated_dt())
3616 return 0;
3617 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3618 return -EINVAL;
3619 }
3620
3621 - pdata.read_reset_sources = prm_read_reset_sources;
3622 -
3623 pdev = omap_device_build(dev_name, id, oh, &pdata,
3624 sizeof(struct omap_wd_timer_platform_data));
3625 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3626 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3627 index 706aa42..f85e9131 100644
3628 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3629 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3630 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3631 bool entered_lp2 = false;
3632
3633 if (tegra_pending_sgi())
3634 - ACCESS_ONCE(abort_flag) = true;
3635 + ACCESS_ONCE_RW(abort_flag) = true;
3636
3637 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3638
3639 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3640 index cad3ca86..1d79e0f 100644
3641 --- a/arch/arm/mach-ux500/setup.h
3642 +++ b/arch/arm/mach-ux500/setup.h
3643 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3644 .type = MT_DEVICE, \
3645 }
3646
3647 -#define __MEM_DEV_DESC(x, sz) { \
3648 - .virtual = IO_ADDRESS(x), \
3649 - .pfn = __phys_to_pfn(x), \
3650 - .length = sz, \
3651 - .type = MT_MEMORY, \
3652 -}
3653 -
3654 extern struct smp_operations ux500_smp_ops;
3655 extern void ux500_cpu_die(unsigned int cpu);
3656
3657 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3658 index cd2c88e..7430282 100644
3659 --- a/arch/arm/mm/Kconfig
3660 +++ b/arch/arm/mm/Kconfig
3661 @@ -446,7 +446,7 @@ config CPU_32v5
3662
3663 config CPU_32v6
3664 bool
3665 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3666 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3667 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3668
3669 config CPU_32v6K
3670 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3671
3672 config CPU_USE_DOMAINS
3673 bool
3674 + depends on !ARM_LPAE && !PAX_KERNEXEC
3675 help
3676 This option enables or disables the use of domain switching
3677 via the set_fs() function.
3678 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3679 config KUSER_HELPERS
3680 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3681 default y
3682 + depends on !(CPU_V6 || CPU_V6K || CPU_V7)
3683 help
3684 Warning: disabling this option may break user programs.
3685
3686 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3687 See Documentation/arm/kernel_user_helpers.txt for details.
3688
3689 However, the fixed address nature of these helpers can be used
3690 - by ROP (return orientated programming) authors when creating
3691 + by ROP (Return Oriented Programming) authors when creating
3692 exploits.
3693
3694 If all of the binaries and libraries which run on your platform
3695 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3696 index 6f4585b..7b6f52b 100644
3697 --- a/arch/arm/mm/alignment.c
3698 +++ b/arch/arm/mm/alignment.c
3699 @@ -211,10 +211,12 @@ union offset_union {
3700 #define __get16_unaligned_check(ins,val,addr) \
3701 do { \
3702 unsigned int err = 0, v, a = addr; \
3703 + pax_open_userland(); \
3704 __get8_unaligned_check(ins,v,a,err); \
3705 val = v << ((BE) ? 8 : 0); \
3706 __get8_unaligned_check(ins,v,a,err); \
3707 val |= v << ((BE) ? 0 : 8); \
3708 + pax_close_userland(); \
3709 if (err) \
3710 goto fault; \
3711 } while (0)
3712 @@ -228,6 +230,7 @@ union offset_union {
3713 #define __get32_unaligned_check(ins,val,addr) \
3714 do { \
3715 unsigned int err = 0, v, a = addr; \
3716 + pax_open_userland(); \
3717 __get8_unaligned_check(ins,v,a,err); \
3718 val = v << ((BE) ? 24 : 0); \
3719 __get8_unaligned_check(ins,v,a,err); \
3720 @@ -236,6 +239,7 @@ union offset_union {
3721 val |= v << ((BE) ? 8 : 16); \
3722 __get8_unaligned_check(ins,v,a,err); \
3723 val |= v << ((BE) ? 0 : 24); \
3724 + pax_close_userland(); \
3725 if (err) \
3726 goto fault; \
3727 } while (0)
3728 @@ -249,6 +253,7 @@ union offset_union {
3729 #define __put16_unaligned_check(ins,val,addr) \
3730 do { \
3731 unsigned int err = 0, v = val, a = addr; \
3732 + pax_open_userland(); \
3733 __asm__( FIRST_BYTE_16 \
3734 ARM( "1: "ins" %1, [%2], #1\n" ) \
3735 THUMB( "1: "ins" %1, [%2]\n" ) \
3736 @@ -268,6 +273,7 @@ union offset_union {
3737 " .popsection\n" \
3738 : "=r" (err), "=&r" (v), "=&r" (a) \
3739 : "0" (err), "1" (v), "2" (a)); \
3740 + pax_close_userland(); \
3741 if (err) \
3742 goto fault; \
3743 } while (0)
3744 @@ -281,6 +287,7 @@ union offset_union {
3745 #define __put32_unaligned_check(ins,val,addr) \
3746 do { \
3747 unsigned int err = 0, v = val, a = addr; \
3748 + pax_open_userland(); \
3749 __asm__( FIRST_BYTE_32 \
3750 ARM( "1: "ins" %1, [%2], #1\n" ) \
3751 THUMB( "1: "ins" %1, [%2]\n" ) \
3752 @@ -310,6 +317,7 @@ union offset_union {
3753 " .popsection\n" \
3754 : "=r" (err), "=&r" (v), "=&r" (a) \
3755 : "0" (err), "1" (v), "2" (a)); \
3756 + pax_close_userland(); \
3757 if (err) \
3758 goto fault; \
3759 } while (0)
3760 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3761 index 4a05444..d21968c 100644
3762 --- a/arch/arm/mm/context.c
3763 +++ b/arch/arm/mm/context.c
3764 @@ -43,7 +43,7 @@
3765 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3766
3767 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3768 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3769 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3770 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3771
3772 static DEFINE_PER_CPU(atomic64_t, active_asids);
3773 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3774 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3775 {
3776 u64 asid = atomic64_read(&mm->context.id);
3777 - u64 generation = atomic64_read(&asid_generation);
3778 + u64 generation = atomic64_read_unchecked(&asid_generation);
3779
3780 if (asid != 0 && is_reserved_asid(asid)) {
3781 /*
3782 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3783 */
3784 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3785 if (asid == NUM_USER_ASIDS) {
3786 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3787 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3788 &asid_generation);
3789 flush_context(cpu);
3790 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3791 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3792 cpu_set_reserved_ttbr0();
3793
3794 asid = atomic64_read(&mm->context.id);
3795 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3796 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3797 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3798 goto switch_mm_fastpath;
3799
3800 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3801 /* Check that our ASID belongs to the current generation. */
3802 asid = atomic64_read(&mm->context.id);
3803 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3804 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3805 asid = new_context(mm, cpu);
3806 atomic64_set(&mm->context.id, asid);
3807 }
3808 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3809 index c97f794..6461880 100644
3810 --- a/arch/arm/mm/fault.c
3811 +++ b/arch/arm/mm/fault.c
3812 @@ -25,6 +25,7 @@
3813 #include <asm/system_misc.h>
3814 #include <asm/system_info.h>
3815 #include <asm/tlbflush.h>
3816 +#include <asm/sections.h>
3817
3818 #include "fault.h"
3819
3820 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3821 if (fixup_exception(regs))
3822 return;
3823
3824 +#ifdef CONFIG_PAX_KERNEXEC
3825 + if ((fsr & FSR_WRITE) &&
3826 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3827 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3828 + {
3829 + if (current->signal->curr_ip)
3830 + 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),
3831 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3832 + else
3833 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3834 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3835 + }
3836 +#endif
3837 +
3838 /*
3839 * No handler, we'll have to terminate things with extreme prejudice.
3840 */
3841 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3842 }
3843 #endif
3844
3845 +#ifdef CONFIG_PAX_PAGEEXEC
3846 + if (fsr & FSR_LNX_PF) {
3847 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3848 + do_group_exit(SIGKILL);
3849 + }
3850 +#endif
3851 +
3852 tsk->thread.address = addr;
3853 tsk->thread.error_code = fsr;
3854 tsk->thread.trap_no = 14;
3855 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3856 }
3857 #endif /* CONFIG_MMU */
3858
3859 +#ifdef CONFIG_PAX_PAGEEXEC
3860 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3861 +{
3862 + long i;
3863 +
3864 + printk(KERN_ERR "PAX: bytes at PC: ");
3865 + for (i = 0; i < 20; i++) {
3866 + unsigned char c;
3867 + if (get_user(c, (__force unsigned char __user *)pc+i))
3868 + printk(KERN_CONT "?? ");
3869 + else
3870 + printk(KERN_CONT "%02x ", c);
3871 + }
3872 + printk("\n");
3873 +
3874 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3875 + for (i = -1; i < 20; i++) {
3876 + unsigned long c;
3877 + if (get_user(c, (__force unsigned long __user *)sp+i))
3878 + printk(KERN_CONT "???????? ");
3879 + else
3880 + printk(KERN_CONT "%08lx ", c);
3881 + }
3882 + printk("\n");
3883 +}
3884 +#endif
3885 +
3886 /*
3887 * First Level Translation Fault Handler
3888 *
3889 @@ -545,9 +594,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3890 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3891 struct siginfo info;
3892
3893 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3894 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3895 + if (current->signal->curr_ip)
3896 + 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),
3897 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3898 + else
3899 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3900 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3901 + goto die;
3902 + }
3903 +#endif
3904 +
3905 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3906 return;
3907
3908 +die:
3909 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3910 inf->name, fsr, addr);
3911
3912 @@ -571,15 +633,92 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3913 ifsr_info[nr].name = name;
3914 }
3915
3916 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3917 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3918 +
3919 asmlinkage void __exception
3920 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3921 {
3922 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3923 struct siginfo info;
3924 + unsigned long pc = instruction_pointer(regs);
3925 +
3926 + if (user_mode(regs)) {
3927 + unsigned long sigpage = current->mm->context.sigpage;
3928 +
3929 + if (sigpage <= pc && pc < sigpage + 7*4) {
3930 + if (pc < sigpage + 3*4)
3931 + sys_sigreturn(regs);
3932 + else
3933 + sys_rt_sigreturn(regs);
3934 + return;
3935 + }
3936 + if (pc == 0xffff0f60UL) {
3937 + /*
3938 + * PaX: __kuser_cmpxchg64 emulation
3939 + */
3940 + // TODO
3941 + //regs->ARM_pc = regs->ARM_lr;
3942 + //return;
3943 + }
3944 + if (pc == 0xffff0fa0UL) {
3945 + /*
3946 + * PaX: __kuser_memory_barrier emulation
3947 + */
3948 + // dmb(); implied by the exception
3949 + regs->ARM_pc = regs->ARM_lr;
3950 + return;
3951 + }
3952 + if (pc == 0xffff0fc0UL) {
3953 + /*
3954 + * PaX: __kuser_cmpxchg emulation
3955 + */
3956 + // TODO
3957 + //regs->ARM_pc = regs->ARM_lr;
3958 + //return;
3959 + }
3960 + if (pc == 0xffff0fe0UL) {
3961 + /*
3962 + * PaX: __kuser_get_tls emulation
3963 + */
3964 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3965 + regs->ARM_pc = regs->ARM_lr;
3966 + return;
3967 + }
3968 + }
3969 +
3970 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3971 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3972 + if (current->signal->curr_ip)
3973 + 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),
3974 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3975 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3976 + else
3977 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3978 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3979 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3980 + goto die;
3981 + }
3982 +#endif
3983 +
3984 +#ifdef CONFIG_PAX_REFCOUNT
3985 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3986 + unsigned int bkpt;
3987 +
3988 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3989 + current->thread.error_code = ifsr;
3990 + current->thread.trap_no = 0;
3991 + pax_report_refcount_overflow(regs);
3992 + fixup_exception(regs);
3993 + return;
3994 + }
3995 + }
3996 +#endif
3997
3998 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3999 return;
4000
4001 +die:
4002 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4003 inf->name, ifsr, addr);
4004
4005 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4006 index cf08bdf..772656c 100644
4007 --- a/arch/arm/mm/fault.h
4008 +++ b/arch/arm/mm/fault.h
4009 @@ -3,6 +3,7 @@
4010
4011 /*
4012 * Fault status register encodings. We steal bit 31 for our own purposes.
4013 + * Set when the FSR value is from an instruction fault.
4014 */
4015 #define FSR_LNX_PF (1 << 31)
4016 #define FSR_WRITE (1 << 11)
4017 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4018 }
4019 #endif
4020
4021 +/* valid for LPAE and !LPAE */
4022 +static inline int is_xn_fault(unsigned int fsr)
4023 +{
4024 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4025 +}
4026 +
4027 +static inline int is_domain_fault(unsigned int fsr)
4028 +{
4029 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4030 +}
4031 +
4032 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4033 unsigned long search_exception_table(unsigned long addr);
4034
4035 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4036 index 15225d8..25e2e3c 100644
4037 --- a/arch/arm/mm/init.c
4038 +++ b/arch/arm/mm/init.c
4039 @@ -30,6 +30,8 @@
4040 #include <asm/setup.h>
4041 #include <asm/tlb.h>
4042 #include <asm/fixmap.h>
4043 +#include <asm/system_info.h>
4044 +#include <asm/cp15.h>
4045
4046 #include <asm/mach/arch.h>
4047 #include <asm/mach/map.h>
4048 @@ -683,7 +685,46 @@ void free_initmem(void)
4049 {
4050 #ifdef CONFIG_HAVE_TCM
4051 extern char __tcm_start, __tcm_end;
4052 +#endif
4053
4054 +#ifdef CONFIG_PAX_KERNEXEC
4055 + unsigned long addr;
4056 + pgd_t *pgd;
4057 + pud_t *pud;
4058 + pmd_t *pmd;
4059 + int cpu_arch = cpu_architecture();
4060 + unsigned int cr = get_cr();
4061 +
4062 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4063 + /* make pages tables, etc before .text NX */
4064 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4065 + pgd = pgd_offset_k(addr);
4066 + pud = pud_offset(pgd, addr);
4067 + pmd = pmd_offset(pud, addr);
4068 + __section_update(pmd, addr, PMD_SECT_XN);
4069 + }
4070 + /* make init NX */
4071 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4072 + pgd = pgd_offset_k(addr);
4073 + pud = pud_offset(pgd, addr);
4074 + pmd = pmd_offset(pud, addr);
4075 + __section_update(pmd, addr, PMD_SECT_XN);
4076 + }
4077 + /* make kernel code/rodata RX */
4078 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4079 + pgd = pgd_offset_k(addr);
4080 + pud = pud_offset(pgd, addr);
4081 + pmd = pmd_offset(pud, addr);
4082 +#ifdef CONFIG_ARM_LPAE
4083 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4084 +#else
4085 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4086 +#endif
4087 + }
4088 + }
4089 +#endif
4090 +
4091 +#ifdef CONFIG_HAVE_TCM
4092 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4093 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4094 #endif
4095 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4096 index f123d6e..04bf569 100644
4097 --- a/arch/arm/mm/ioremap.c
4098 +++ b/arch/arm/mm/ioremap.c
4099 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4100 unsigned int mtype;
4101
4102 if (cached)
4103 - mtype = MT_MEMORY;
4104 + mtype = MT_MEMORY_RX;
4105 else
4106 - mtype = MT_MEMORY_NONCACHED;
4107 + mtype = MT_MEMORY_NONCACHED_RX;
4108
4109 return __arm_ioremap_caller(phys_addr, size, mtype,
4110 __builtin_return_address(0));
4111 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4112 index 0c63562..7128a90 100644
4113 --- a/arch/arm/mm/mmap.c
4114 +++ b/arch/arm/mm/mmap.c
4115 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4116 struct vm_area_struct *vma;
4117 int do_align = 0;
4118 int aliasing = cache_is_vipt_aliasing();
4119 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4120 struct vm_unmapped_area_info info;
4121
4122 /*
4123 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4124 if (len > TASK_SIZE)
4125 return -ENOMEM;
4126
4127 +#ifdef CONFIG_PAX_RANDMMAP
4128 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4129 +#endif
4130 +
4131 if (addr) {
4132 if (do_align)
4133 addr = COLOUR_ALIGN(addr, pgoff);
4134 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4135 addr = PAGE_ALIGN(addr);
4136
4137 vma = find_vma(mm, addr);
4138 - if (TASK_SIZE - len >= addr &&
4139 - (!vma || addr + len <= vma->vm_start))
4140 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4141 return addr;
4142 }
4143
4144 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4145 info.high_limit = TASK_SIZE;
4146 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4147 info.align_offset = pgoff << PAGE_SHIFT;
4148 + info.threadstack_offset = offset;
4149 return vm_unmapped_area(&info);
4150 }
4151
4152 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4153 unsigned long addr = addr0;
4154 int do_align = 0;
4155 int aliasing = cache_is_vipt_aliasing();
4156 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4157 struct vm_unmapped_area_info info;
4158
4159 /*
4160 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4161 return addr;
4162 }
4163
4164 +#ifdef CONFIG_PAX_RANDMMAP
4165 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4166 +#endif
4167 +
4168 /* requesting a specific address */
4169 if (addr) {
4170 if (do_align)
4171 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4172 else
4173 addr = PAGE_ALIGN(addr);
4174 vma = find_vma(mm, addr);
4175 - if (TASK_SIZE - len >= addr &&
4176 - (!vma || addr + len <= vma->vm_start))
4177 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4178 return addr;
4179 }
4180
4181 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4182 info.high_limit = mm->mmap_base;
4183 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4184 info.align_offset = pgoff << PAGE_SHIFT;
4185 + info.threadstack_offset = offset;
4186 addr = vm_unmapped_area(&info);
4187
4188 /*
4189 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4190 {
4191 unsigned long random_factor = 0UL;
4192
4193 +#ifdef CONFIG_PAX_RANDMMAP
4194 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4195 +#endif
4196 +
4197 /* 8 bits of randomness in 20 address space bits */
4198 if ((current->flags & PF_RANDOMIZE) &&
4199 !(current->personality & ADDR_NO_RANDOMIZE))
4200 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4201
4202 if (mmap_is_legacy()) {
4203 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4204 +
4205 +#ifdef CONFIG_PAX_RANDMMAP
4206 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4207 + mm->mmap_base += mm->delta_mmap;
4208 +#endif
4209 +
4210 mm->get_unmapped_area = arch_get_unmapped_area;
4211 } else {
4212 mm->mmap_base = mmap_base(random_factor);
4213 +
4214 +#ifdef CONFIG_PAX_RANDMMAP
4215 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4216 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4217 +#endif
4218 +
4219 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4220 }
4221 }
4222 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4223 index 53cdbd3..670f177 100644
4224 --- a/arch/arm/mm/mmu.c
4225 +++ b/arch/arm/mm/mmu.c
4226 @@ -36,6 +36,22 @@
4227 #include "mm.h"
4228 #include "tcm.h"
4229
4230 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4231 +void modify_domain(unsigned int dom, unsigned int type)
4232 +{
4233 + struct thread_info *thread = current_thread_info();
4234 + unsigned int domain = thread->cpu_domain;
4235 + /*
4236 + * DOMAIN_MANAGER might be defined to some other value,
4237 + * use the arch-defined constant
4238 + */
4239 + domain &= ~domain_val(dom, 3);
4240 + thread->cpu_domain = domain | domain_val(dom, type);
4241 + set_domain(thread->cpu_domain);
4242 +}
4243 +EXPORT_SYMBOL(modify_domain);
4244 +#endif
4245 +
4246 /*
4247 * empty_zero_page is a special page that is used for
4248 * zero-initialized data and COW.
4249 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4250
4251 #endif /* ifdef CONFIG_CPU_CP15 / else */
4252
4253 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4254 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4255 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4256
4257 -static struct mem_type mem_types[] = {
4258 +#ifdef CONFIG_PAX_KERNEXEC
4259 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4260 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4261 +#else
4262 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4263 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4264 +#endif
4265 +
4266 +static struct mem_type mem_types[] __read_only = {
4267 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4268 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4269 L_PTE_SHARED,
4270 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4271 [MT_UNCACHED] = {
4272 .prot_pte = PROT_PTE_DEVICE,
4273 .prot_l1 = PMD_TYPE_TABLE,
4274 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4275 + .prot_sect = PROT_SECT_DEVICE,
4276 .domain = DOMAIN_IO,
4277 },
4278 [MT_CACHECLEAN] = {
4279 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4280 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4281 .domain = DOMAIN_KERNEL,
4282 },
4283 #ifndef CONFIG_ARM_LPAE
4284 [MT_MINICLEAN] = {
4285 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4286 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4287 .domain = DOMAIN_KERNEL,
4288 },
4289 #endif
4290 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4291 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4292 L_PTE_RDONLY,
4293 .prot_l1 = PMD_TYPE_TABLE,
4294 - .domain = DOMAIN_USER,
4295 + .domain = DOMAIN_VECTORS,
4296 },
4297 [MT_HIGH_VECTORS] = {
4298 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4299 L_PTE_USER | L_PTE_RDONLY,
4300 .prot_l1 = PMD_TYPE_TABLE,
4301 - .domain = DOMAIN_USER,
4302 + .domain = DOMAIN_VECTORS,
4303 },
4304 - [MT_MEMORY] = {
4305 + [MT_MEMORY_RWX] = {
4306 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4307 .prot_l1 = PMD_TYPE_TABLE,
4308 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4309 .domain = DOMAIN_KERNEL,
4310 },
4311 + [MT_MEMORY_RW] = {
4312 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4313 + .prot_l1 = PMD_TYPE_TABLE,
4314 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4315 + .domain = DOMAIN_KERNEL,
4316 + },
4317 + [MT_MEMORY_RX] = {
4318 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4319 + .prot_l1 = PMD_TYPE_TABLE,
4320 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4321 + .domain = DOMAIN_KERNEL,
4322 + },
4323 [MT_ROM] = {
4324 - .prot_sect = PMD_TYPE_SECT,
4325 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4326 .domain = DOMAIN_KERNEL,
4327 },
4328 - [MT_MEMORY_NONCACHED] = {
4329 + [MT_MEMORY_NONCACHED_RW] = {
4330 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4331 L_PTE_MT_BUFFERABLE,
4332 .prot_l1 = PMD_TYPE_TABLE,
4333 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4334 .domain = DOMAIN_KERNEL,
4335 },
4336 + [MT_MEMORY_NONCACHED_RX] = {
4337 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4338 + L_PTE_MT_BUFFERABLE,
4339 + .prot_l1 = PMD_TYPE_TABLE,
4340 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4341 + .domain = DOMAIN_KERNEL,
4342 + },
4343 [MT_MEMORY_DTCM] = {
4344 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4345 - L_PTE_XN,
4346 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4347 .prot_l1 = PMD_TYPE_TABLE,
4348 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4349 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4350 .domain = DOMAIN_KERNEL,
4351 },
4352 [MT_MEMORY_ITCM] = {
4353 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4354 },
4355 [MT_MEMORY_SO] = {
4356 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4357 - L_PTE_MT_UNCACHED | L_PTE_XN,
4358 + L_PTE_MT_UNCACHED,
4359 .prot_l1 = PMD_TYPE_TABLE,
4360 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4361 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4362 + PMD_SECT_UNCACHED,
4363 .domain = DOMAIN_KERNEL,
4364 },
4365 [MT_MEMORY_DMA_READY] = {
4366 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4367 * to prevent speculative instruction fetches.
4368 */
4369 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4370 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4371 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4372 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4373 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4374 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4375 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4376 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4377 +
4378 + /* Mark other regions on ARMv6+ as execute-never */
4379 +
4380 +#ifdef CONFIG_PAX_KERNEXEC
4381 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4382 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4383 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4384 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4385 +#ifndef CONFIG_ARM_LPAE
4386 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4388 +#endif
4389 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4391 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4392 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4393 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4394 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4395 +#endif
4396 +
4397 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4398 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4399 }
4400 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4401 /*
4402 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4403 * from SVC mode and no access from userspace.
4404 */
4405 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4406 +#ifdef CONFIG_PAX_KERNEXEC
4407 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4408 +#endif
4409 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4410 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4411 #endif
4412 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4413 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4414 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4415 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4416 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4417 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4418 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4419 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4420 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4421 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4422 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4423 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4424 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4425 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4426 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4427 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4428 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4429 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4430 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4431 }
4432 }
4433
4434 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4435 if (cpu_arch >= CPU_ARCH_ARMv6) {
4436 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4437 /* Non-cacheable Normal is XCB = 001 */
4438 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4439 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4440 + PMD_SECT_BUFFERED;
4441 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4442 PMD_SECT_BUFFERED;
4443 } else {
4444 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4445 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4446 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4447 + PMD_SECT_TEX(1);
4448 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4449 PMD_SECT_TEX(1);
4450 }
4451 } else {
4452 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4453 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4454 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4455 }
4456
4457 #ifdef CONFIG_ARM_LPAE
4458 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4459 vecs_pgprot |= PTE_EXT_AF;
4460 #endif
4461
4462 + user_pgprot |= __supported_pte_mask;
4463 +
4464 for (i = 0; i < 16; i++) {
4465 pteval_t v = pgprot_val(protection_map[i]);
4466 protection_map[i] = __pgprot(v | user_pgprot);
4467 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4468
4469 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4470 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4471 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4472 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4473 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4474 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4475 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4476 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4477 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4478 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4479 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4480 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4481 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4482 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4483 mem_types[MT_ROM].prot_sect |= cp->pmd;
4484
4485 switch (cp->pmd) {
4486 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4487 * called function. This means you can't use any function or debugging
4488 * method which may touch any device, otherwise the kernel _will_ crash.
4489 */
4490 +
4491 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4492 +
4493 static void __init devicemaps_init(struct machine_desc *mdesc)
4494 {
4495 struct map_desc map;
4496 unsigned long addr;
4497 - void *vectors;
4498
4499 - /*
4500 - * Allocate the vector page early.
4501 - */
4502 - vectors = early_alloc(PAGE_SIZE * 2);
4503 -
4504 - early_trap_init(vectors);
4505 + early_trap_init(&vectors);
4506
4507 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4508 pmd_clear(pmd_off_k(addr));
4509 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4510 * location (0xffff0000). If we aren't using high-vectors, also
4511 * create a mapping at the low-vectors virtual address.
4512 */
4513 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4514 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4515 map.virtual = 0xffff0000;
4516 map.length = PAGE_SIZE;
4517 #ifdef CONFIG_KUSER_HELPERS
4518 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4519 map.pfn = __phys_to_pfn(start);
4520 map.virtual = __phys_to_virt(start);
4521 map.length = end - start;
4522 - map.type = MT_MEMORY;
4523
4524 +#ifdef CONFIG_PAX_KERNEXEC
4525 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4526 + struct map_desc kernel;
4527 + struct map_desc initmap;
4528 +
4529 + /* when freeing initmem we will make this RW */
4530 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4531 + initmap.virtual = (unsigned long)__init_begin;
4532 + initmap.length = _sdata - __init_begin;
4533 + initmap.type = MT_MEMORY_RWX;
4534 + create_mapping(&initmap);
4535 +
4536 + /* when freeing initmem we will make this RX */
4537 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4538 + kernel.virtual = (unsigned long)_stext;
4539 + kernel.length = __init_begin - _stext;
4540 + kernel.type = MT_MEMORY_RWX;
4541 + create_mapping(&kernel);
4542 +
4543 + if (map.virtual < (unsigned long)_stext) {
4544 + map.length = (unsigned long)_stext - map.virtual;
4545 + map.type = MT_MEMORY_RWX;
4546 + create_mapping(&map);
4547 + }
4548 +
4549 + map.pfn = __phys_to_pfn(__pa(_sdata));
4550 + map.virtual = (unsigned long)_sdata;
4551 + map.length = end - __pa(_sdata);
4552 + }
4553 +#endif
4554 +
4555 + map.type = MT_MEMORY_RW;
4556 create_mapping(&map);
4557 }
4558 }
4559 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4560 index a5bc92d..0bb4730 100644
4561 --- a/arch/arm/plat-omap/sram.c
4562 +++ b/arch/arm/plat-omap/sram.c
4563 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4564 * Looks like we need to preserve some bootloader code at the
4565 * beginning of SRAM for jumping to flash for reboot to work...
4566 */
4567 + pax_open_kernel();
4568 memset_io(omap_sram_base + omap_sram_skip, 0,
4569 omap_sram_size - omap_sram_skip);
4570 + pax_close_kernel();
4571 }
4572 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4573 index ce6d763..cfea917 100644
4574 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4575 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4576 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4577 int (*started)(unsigned ch);
4578 int (*flush)(unsigned ch);
4579 int (*stop)(unsigned ch);
4580 -};
4581 +} __no_const;
4582
4583 extern void *samsung_dmadev_get_ops(void);
4584 extern void *s3c_dma_get_ops(void);
4585 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4586 index c3a58a1..78fbf54 100644
4587 --- a/arch/avr32/include/asm/cache.h
4588 +++ b/arch/avr32/include/asm/cache.h
4589 @@ -1,8 +1,10 @@
4590 #ifndef __ASM_AVR32_CACHE_H
4591 #define __ASM_AVR32_CACHE_H
4592
4593 +#include <linux/const.h>
4594 +
4595 #define L1_CACHE_SHIFT 5
4596 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4597 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4598
4599 /*
4600 * Memory returned by kmalloc() may be used for DMA, so we must make
4601 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4602 index d232888..87c8df1 100644
4603 --- a/arch/avr32/include/asm/elf.h
4604 +++ b/arch/avr32/include/asm/elf.h
4605 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4606 the loader. We need to make sure that it is out of the way of the program
4607 that it will "exec", and that there is sufficient room for the brk. */
4608
4609 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4610 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4611
4612 +#ifdef CONFIG_PAX_ASLR
4613 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4614 +
4615 +#define PAX_DELTA_MMAP_LEN 15
4616 +#define PAX_DELTA_STACK_LEN 15
4617 +#endif
4618
4619 /* This yields a mask that user programs can use to figure out what
4620 instruction set this CPU supports. This could be done in user space,
4621 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4622 index 479330b..53717a8 100644
4623 --- a/arch/avr32/include/asm/kmap_types.h
4624 +++ b/arch/avr32/include/asm/kmap_types.h
4625 @@ -2,9 +2,9 @@
4626 #define __ASM_AVR32_KMAP_TYPES_H
4627
4628 #ifdef CONFIG_DEBUG_HIGHMEM
4629 -# define KM_TYPE_NR 29
4630 +# define KM_TYPE_NR 30
4631 #else
4632 -# define KM_TYPE_NR 14
4633 +# define KM_TYPE_NR 15
4634 #endif
4635
4636 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4637 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4638 index b2f2d2d..d1c85cb 100644
4639 --- a/arch/avr32/mm/fault.c
4640 +++ b/arch/avr32/mm/fault.c
4641 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4642
4643 int exception_trace = 1;
4644
4645 +#ifdef CONFIG_PAX_PAGEEXEC
4646 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4647 +{
4648 + unsigned long i;
4649 +
4650 + printk(KERN_ERR "PAX: bytes at PC: ");
4651 + for (i = 0; i < 20; i++) {
4652 + unsigned char c;
4653 + if (get_user(c, (unsigned char *)pc+i))
4654 + printk(KERN_CONT "???????? ");
4655 + else
4656 + printk(KERN_CONT "%02x ", c);
4657 + }
4658 + printk("\n");
4659 +}
4660 +#endif
4661 +
4662 /*
4663 * This routine handles page faults. It determines the address and the
4664 * problem, and then passes it off to one of the appropriate routines.
4665 @@ -174,6 +191,16 @@ bad_area:
4666 up_read(&mm->mmap_sem);
4667
4668 if (user_mode(regs)) {
4669 +
4670 +#ifdef CONFIG_PAX_PAGEEXEC
4671 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4672 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4673 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4674 + do_group_exit(SIGKILL);
4675 + }
4676 + }
4677 +#endif
4678 +
4679 if (exception_trace && printk_ratelimit())
4680 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4681 "sp %08lx ecr %lu\n",
4682 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4683 index 568885a..f8008df 100644
4684 --- a/arch/blackfin/include/asm/cache.h
4685 +++ b/arch/blackfin/include/asm/cache.h
4686 @@ -7,6 +7,7 @@
4687 #ifndef __ARCH_BLACKFIN_CACHE_H
4688 #define __ARCH_BLACKFIN_CACHE_H
4689
4690 +#include <linux/const.h>
4691 #include <linux/linkage.h> /* for asmlinkage */
4692
4693 /*
4694 @@ -14,7 +15,7 @@
4695 * Blackfin loads 32 bytes for cache
4696 */
4697 #define L1_CACHE_SHIFT 5
4698 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4699 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4700 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4701
4702 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4703 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4704 index aea2718..3639a60 100644
4705 --- a/arch/cris/include/arch-v10/arch/cache.h
4706 +++ b/arch/cris/include/arch-v10/arch/cache.h
4707 @@ -1,8 +1,9 @@
4708 #ifndef _ASM_ARCH_CACHE_H
4709 #define _ASM_ARCH_CACHE_H
4710
4711 +#include <linux/const.h>
4712 /* Etrax 100LX have 32-byte cache-lines. */
4713 -#define L1_CACHE_BYTES 32
4714 #define L1_CACHE_SHIFT 5
4715 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4716
4717 #endif /* _ASM_ARCH_CACHE_H */
4718 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4719 index 7caf25d..ee65ac5 100644
4720 --- a/arch/cris/include/arch-v32/arch/cache.h
4721 +++ b/arch/cris/include/arch-v32/arch/cache.h
4722 @@ -1,11 +1,12 @@
4723 #ifndef _ASM_CRIS_ARCH_CACHE_H
4724 #define _ASM_CRIS_ARCH_CACHE_H
4725
4726 +#include <linux/const.h>
4727 #include <arch/hwregs/dma.h>
4728
4729 /* A cache-line is 32 bytes. */
4730 -#define L1_CACHE_BYTES 32
4731 #define L1_CACHE_SHIFT 5
4732 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4733
4734 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4735
4736 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4737 index b86329d..6709906 100644
4738 --- a/arch/frv/include/asm/atomic.h
4739 +++ b/arch/frv/include/asm/atomic.h
4740 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4741 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4742 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4743
4744 +#define atomic64_read_unchecked(v) atomic64_read(v)
4745 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4746 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4747 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4748 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4749 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4750 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4751 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4752 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4753 +
4754 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4755 {
4756 int c, old;
4757 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4758 index 2797163..c2a401d 100644
4759 --- a/arch/frv/include/asm/cache.h
4760 +++ b/arch/frv/include/asm/cache.h
4761 @@ -12,10 +12,11 @@
4762 #ifndef __ASM_CACHE_H
4763 #define __ASM_CACHE_H
4764
4765 +#include <linux/const.h>
4766
4767 /* bytes per L1 cache line */
4768 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4769 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4770 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4771
4772 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4773 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4774 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4775 index 43901f2..0d8b865 100644
4776 --- a/arch/frv/include/asm/kmap_types.h
4777 +++ b/arch/frv/include/asm/kmap_types.h
4778 @@ -2,6 +2,6 @@
4779 #ifndef _ASM_KMAP_TYPES_H
4780 #define _ASM_KMAP_TYPES_H
4781
4782 -#define KM_TYPE_NR 17
4783 +#define KM_TYPE_NR 18
4784
4785 #endif
4786 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4787 index 836f147..4cf23f5 100644
4788 --- a/arch/frv/mm/elf-fdpic.c
4789 +++ b/arch/frv/mm/elf-fdpic.c
4790 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4791 {
4792 struct vm_area_struct *vma;
4793 struct vm_unmapped_area_info info;
4794 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4795
4796 if (len > TASK_SIZE)
4797 return -ENOMEM;
4798 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4799 if (addr) {
4800 addr = PAGE_ALIGN(addr);
4801 vma = find_vma(current->mm, addr);
4802 - if (TASK_SIZE - len >= addr &&
4803 - (!vma || addr + len <= vma->vm_start))
4804 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4805 goto success;
4806 }
4807
4808 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4809 info.high_limit = (current->mm->start_stack - 0x00200000);
4810 info.align_mask = 0;
4811 info.align_offset = 0;
4812 + info.threadstack_offset = offset;
4813 addr = vm_unmapped_area(&info);
4814 if (!(addr & ~PAGE_MASK))
4815 goto success;
4816 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4817 index f4ca594..adc72fd6 100644
4818 --- a/arch/hexagon/include/asm/cache.h
4819 +++ b/arch/hexagon/include/asm/cache.h
4820 @@ -21,9 +21,11 @@
4821 #ifndef __ASM_CACHE_H
4822 #define __ASM_CACHE_H
4823
4824 +#include <linux/const.h>
4825 +
4826 /* Bytes per L1 cache line */
4827 -#define L1_CACHE_SHIFT (5)
4828 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4829 +#define L1_CACHE_SHIFT 5
4830 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4831
4832 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4833 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4834 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4835 index 6e6fe18..a6ae668 100644
4836 --- a/arch/ia64/include/asm/atomic.h
4837 +++ b/arch/ia64/include/asm/atomic.h
4838 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4839 #define atomic64_inc(v) atomic64_add(1, (v))
4840 #define atomic64_dec(v) atomic64_sub(1, (v))
4841
4842 +#define atomic64_read_unchecked(v) atomic64_read(v)
4843 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4844 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4845 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4846 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4847 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4848 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4849 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4850 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4851 +
4852 /* Atomic operations are already serializing */
4853 #define smp_mb__before_atomic_dec() barrier()
4854 #define smp_mb__after_atomic_dec() barrier()
4855 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4856 index 988254a..e1ee885 100644
4857 --- a/arch/ia64/include/asm/cache.h
4858 +++ b/arch/ia64/include/asm/cache.h
4859 @@ -1,6 +1,7 @@
4860 #ifndef _ASM_IA64_CACHE_H
4861 #define _ASM_IA64_CACHE_H
4862
4863 +#include <linux/const.h>
4864
4865 /*
4866 * Copyright (C) 1998-2000 Hewlett-Packard Co
4867 @@ -9,7 +10,7 @@
4868
4869 /* Bytes per L1 (data) cache line. */
4870 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4871 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4872 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4873
4874 #ifdef CONFIG_SMP
4875 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4876 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4877 index 5a83c5c..4d7f553 100644
4878 --- a/arch/ia64/include/asm/elf.h
4879 +++ b/arch/ia64/include/asm/elf.h
4880 @@ -42,6 +42,13 @@
4881 */
4882 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4883
4884 +#ifdef CONFIG_PAX_ASLR
4885 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4886 +
4887 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4888 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4889 +#endif
4890 +
4891 #define PT_IA_64_UNWIND 0x70000001
4892
4893 /* IA-64 relocations: */
4894 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4895 index 96a8d92..617a1cf 100644
4896 --- a/arch/ia64/include/asm/pgalloc.h
4897 +++ b/arch/ia64/include/asm/pgalloc.h
4898 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4899 pgd_val(*pgd_entry) = __pa(pud);
4900 }
4901
4902 +static inline void
4903 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4904 +{
4905 + pgd_populate(mm, pgd_entry, pud);
4906 +}
4907 +
4908 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4909 {
4910 return quicklist_alloc(0, GFP_KERNEL, NULL);
4911 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4912 pud_val(*pud_entry) = __pa(pmd);
4913 }
4914
4915 +static inline void
4916 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4917 +{
4918 + pud_populate(mm, pud_entry, pmd);
4919 +}
4920 +
4921 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4922 {
4923 return quicklist_alloc(0, GFP_KERNEL, NULL);
4924 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4925 index 7935115..c0eca6a 100644
4926 --- a/arch/ia64/include/asm/pgtable.h
4927 +++ b/arch/ia64/include/asm/pgtable.h
4928 @@ -12,7 +12,7 @@
4929 * David Mosberger-Tang <davidm@hpl.hp.com>
4930 */
4931
4932 -
4933 +#include <linux/const.h>
4934 #include <asm/mman.h>
4935 #include <asm/page.h>
4936 #include <asm/processor.h>
4937 @@ -142,6 +142,17 @@
4938 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4939 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4940 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4941 +
4942 +#ifdef CONFIG_PAX_PAGEEXEC
4943 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4944 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4945 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4946 +#else
4947 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4948 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4949 +# define PAGE_COPY_NOEXEC PAGE_COPY
4950 +#endif
4951 +
4952 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4953 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4954 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4955 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4956 index 54ff557..70c88b7 100644
4957 --- a/arch/ia64/include/asm/spinlock.h
4958 +++ b/arch/ia64/include/asm/spinlock.h
4959 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4960 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4961
4962 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4963 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4964 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4965 }
4966
4967 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4968 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4969 index 449c8c0..18965fb 100644
4970 --- a/arch/ia64/include/asm/uaccess.h
4971 +++ b/arch/ia64/include/asm/uaccess.h
4972 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4973 static inline unsigned long
4974 __copy_to_user (void __user *to, const void *from, unsigned long count)
4975 {
4976 + if (count > INT_MAX)
4977 + return count;
4978 +
4979 + if (!__builtin_constant_p(count))
4980 + check_object_size(from, count, true);
4981 +
4982 return __copy_user(to, (__force void __user *) from, count);
4983 }
4984
4985 static inline unsigned long
4986 __copy_from_user (void *to, const void __user *from, unsigned long count)
4987 {
4988 + if (count > INT_MAX)
4989 + return count;
4990 +
4991 + if (!__builtin_constant_p(count))
4992 + check_object_size(to, count, false);
4993 +
4994 return __copy_user((__force void __user *) to, from, count);
4995 }
4996
4997 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4998 ({ \
4999 void __user *__cu_to = (to); \
5000 const void *__cu_from = (from); \
5001 - long __cu_len = (n); \
5002 + unsigned long __cu_len = (n); \
5003 \
5004 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5005 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5006 + if (!__builtin_constant_p(n)) \
5007 + check_object_size(__cu_from, __cu_len, true); \
5008 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5009 + } \
5010 __cu_len; \
5011 })
5012
5013 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5014 ({ \
5015 void *__cu_to = (to); \
5016 const void __user *__cu_from = (from); \
5017 - long __cu_len = (n); \
5018 + unsigned long __cu_len = (n); \
5019 \
5020 __chk_user_ptr(__cu_from); \
5021 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5022 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5023 + if (!__builtin_constant_p(n)) \
5024 + check_object_size(__cu_to, __cu_len, false); \
5025 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5026 + } \
5027 __cu_len; \
5028 })
5029
5030 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5031 index 24603be..948052d 100644
5032 --- a/arch/ia64/kernel/module.c
5033 +++ b/arch/ia64/kernel/module.c
5034 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5035 void
5036 module_free (struct module *mod, void *module_region)
5037 {
5038 - if (mod && mod->arch.init_unw_table &&
5039 - module_region == mod->module_init) {
5040 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5041 unw_remove_unwind_table(mod->arch.init_unw_table);
5042 mod->arch.init_unw_table = NULL;
5043 }
5044 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5045 }
5046
5047 static inline int
5048 +in_init_rx (const struct module *mod, uint64_t addr)
5049 +{
5050 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5051 +}
5052 +
5053 +static inline int
5054 +in_init_rw (const struct module *mod, uint64_t addr)
5055 +{
5056 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5057 +}
5058 +
5059 +static inline int
5060 in_init (const struct module *mod, uint64_t addr)
5061 {
5062 - return addr - (uint64_t) mod->module_init < mod->init_size;
5063 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5064 +}
5065 +
5066 +static inline int
5067 +in_core_rx (const struct module *mod, uint64_t addr)
5068 +{
5069 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5070 +}
5071 +
5072 +static inline int
5073 +in_core_rw (const struct module *mod, uint64_t addr)
5074 +{
5075 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5076 }
5077
5078 static inline int
5079 in_core (const struct module *mod, uint64_t addr)
5080 {
5081 - return addr - (uint64_t) mod->module_core < mod->core_size;
5082 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5083 }
5084
5085 static inline int
5086 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5087 break;
5088
5089 case RV_BDREL:
5090 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5091 + if (in_init_rx(mod, val))
5092 + val -= (uint64_t) mod->module_init_rx;
5093 + else if (in_init_rw(mod, val))
5094 + val -= (uint64_t) mod->module_init_rw;
5095 + else if (in_core_rx(mod, val))
5096 + val -= (uint64_t) mod->module_core_rx;
5097 + else if (in_core_rw(mod, val))
5098 + val -= (uint64_t) mod->module_core_rw;
5099 break;
5100
5101 case RV_LTV:
5102 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5103 * addresses have been selected...
5104 */
5105 uint64_t gp;
5106 - if (mod->core_size > MAX_LTOFF)
5107 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5108 /*
5109 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5110 * at the end of the module.
5111 */
5112 - gp = mod->core_size - MAX_LTOFF / 2;
5113 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5114 else
5115 - gp = mod->core_size / 2;
5116 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5117 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5118 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5119 mod->arch.gp = gp;
5120 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5121 }
5122 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5123 index ab33328..f39506c 100644
5124 --- a/arch/ia64/kernel/palinfo.c
5125 +++ b/arch/ia64/kernel/palinfo.c
5126 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5127 return NOTIFY_OK;
5128 }
5129
5130 -static struct notifier_block __refdata palinfo_cpu_notifier =
5131 +static struct notifier_block palinfo_cpu_notifier =
5132 {
5133 .notifier_call = palinfo_cpu_callback,
5134 .priority = 0,
5135 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5136 index 41e33f8..65180b2 100644
5137 --- a/arch/ia64/kernel/sys_ia64.c
5138 +++ b/arch/ia64/kernel/sys_ia64.c
5139 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5140 unsigned long align_mask = 0;
5141 struct mm_struct *mm = current->mm;
5142 struct vm_unmapped_area_info info;
5143 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5144
5145 if (len > RGN_MAP_LIMIT)
5146 return -ENOMEM;
5147 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5148 if (REGION_NUMBER(addr) == RGN_HPAGE)
5149 addr = 0;
5150 #endif
5151 +
5152 +#ifdef CONFIG_PAX_RANDMMAP
5153 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5154 + addr = mm->free_area_cache;
5155 + else
5156 +#endif
5157 +
5158 if (!addr)
5159 addr = TASK_UNMAPPED_BASE;
5160
5161 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5162 info.high_limit = TASK_SIZE;
5163 info.align_mask = align_mask;
5164 info.align_offset = 0;
5165 + info.threadstack_offset = offset;
5166 return vm_unmapped_area(&info);
5167 }
5168
5169 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5170 index 0ccb28f..8992469 100644
5171 --- a/arch/ia64/kernel/vmlinux.lds.S
5172 +++ b/arch/ia64/kernel/vmlinux.lds.S
5173 @@ -198,7 +198,7 @@ SECTIONS {
5174 /* Per-cpu data: */
5175 . = ALIGN(PERCPU_PAGE_SIZE);
5176 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5177 - __phys_per_cpu_start = __per_cpu_load;
5178 + __phys_per_cpu_start = per_cpu_load;
5179 /*
5180 * ensure percpu data fits
5181 * into percpu page size
5182 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5183 index 6cf0341..d352594 100644
5184 --- a/arch/ia64/mm/fault.c
5185 +++ b/arch/ia64/mm/fault.c
5186 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5187 return pte_present(pte);
5188 }
5189
5190 +#ifdef CONFIG_PAX_PAGEEXEC
5191 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5192 +{
5193 + unsigned long i;
5194 +
5195 + printk(KERN_ERR "PAX: bytes at PC: ");
5196 + for (i = 0; i < 8; i++) {
5197 + unsigned int c;
5198 + if (get_user(c, (unsigned int *)pc+i))
5199 + printk(KERN_CONT "???????? ");
5200 + else
5201 + printk(KERN_CONT "%08x ", c);
5202 + }
5203 + printk("\n");
5204 +}
5205 +#endif
5206 +
5207 # define VM_READ_BIT 0
5208 # define VM_WRITE_BIT 1
5209 # define VM_EXEC_BIT 2
5210 @@ -149,8 +166,21 @@ retry:
5211 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5212 goto bad_area;
5213
5214 - if ((vma->vm_flags & mask) != mask)
5215 + if ((vma->vm_flags & mask) != mask) {
5216 +
5217 +#ifdef CONFIG_PAX_PAGEEXEC
5218 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5219 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5220 + goto bad_area;
5221 +
5222 + up_read(&mm->mmap_sem);
5223 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5224 + do_group_exit(SIGKILL);
5225 + }
5226 +#endif
5227 +
5228 goto bad_area;
5229 + }
5230
5231 /*
5232 * If for any reason at all we couldn't handle the fault, make
5233 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5234 index 76069c1..c2aa816 100644
5235 --- a/arch/ia64/mm/hugetlbpage.c
5236 +++ b/arch/ia64/mm/hugetlbpage.c
5237 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5238 unsigned long pgoff, unsigned long flags)
5239 {
5240 struct vm_unmapped_area_info info;
5241 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5242
5243 if (len > RGN_MAP_LIMIT)
5244 return -ENOMEM;
5245 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5246 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5247 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5248 info.align_offset = 0;
5249 + info.threadstack_offset = offset;
5250 return vm_unmapped_area(&info);
5251 }
5252
5253 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5254 index b6f7f43..c04320d 100644
5255 --- a/arch/ia64/mm/init.c
5256 +++ b/arch/ia64/mm/init.c
5257 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5258 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5259 vma->vm_end = vma->vm_start + PAGE_SIZE;
5260 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5261 +
5262 +#ifdef CONFIG_PAX_PAGEEXEC
5263 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5264 + vma->vm_flags &= ~VM_EXEC;
5265 +
5266 +#ifdef CONFIG_PAX_MPROTECT
5267 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5268 + vma->vm_flags &= ~VM_MAYEXEC;
5269 +#endif
5270 +
5271 + }
5272 +#endif
5273 +
5274 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5275 down_write(&current->mm->mmap_sem);
5276 if (insert_vm_struct(current->mm, vma)) {
5277 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5278 index 40b3ee9..8c2c112 100644
5279 --- a/arch/m32r/include/asm/cache.h
5280 +++ b/arch/m32r/include/asm/cache.h
5281 @@ -1,8 +1,10 @@
5282 #ifndef _ASM_M32R_CACHE_H
5283 #define _ASM_M32R_CACHE_H
5284
5285 +#include <linux/const.h>
5286 +
5287 /* L1 cache line size */
5288 #define L1_CACHE_SHIFT 4
5289 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5290 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5291
5292 #endif /* _ASM_M32R_CACHE_H */
5293 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5294 index 82abd15..d95ae5d 100644
5295 --- a/arch/m32r/lib/usercopy.c
5296 +++ b/arch/m32r/lib/usercopy.c
5297 @@ -14,6 +14,9 @@
5298 unsigned long
5299 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5300 {
5301 + if ((long)n < 0)
5302 + return n;
5303 +
5304 prefetch(from);
5305 if (access_ok(VERIFY_WRITE, to, n))
5306 __copy_user(to,from,n);
5307 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5308 unsigned long
5309 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5310 {
5311 + if ((long)n < 0)
5312 + return n;
5313 +
5314 prefetchw(to);
5315 if (access_ok(VERIFY_READ, from, n))
5316 __copy_user_zeroing(to,from,n);
5317 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5318 index 0395c51..5f26031 100644
5319 --- a/arch/m68k/include/asm/cache.h
5320 +++ b/arch/m68k/include/asm/cache.h
5321 @@ -4,9 +4,11 @@
5322 #ifndef __ARCH_M68K_CACHE_H
5323 #define __ARCH_M68K_CACHE_H
5324
5325 +#include <linux/const.h>
5326 +
5327 /* bytes per L1 cache line */
5328 #define L1_CACHE_SHIFT 4
5329 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5330 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5331
5332 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5333
5334 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5335 index 3c52fa6..11b2ad8 100644
5336 --- a/arch/metag/mm/hugetlbpage.c
5337 +++ b/arch/metag/mm/hugetlbpage.c
5338 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5339 info.high_limit = TASK_SIZE;
5340 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5341 info.align_offset = 0;
5342 + info.threadstack_offset = 0;
5343 return vm_unmapped_area(&info);
5344 }
5345
5346 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5347 index 4efe96a..60e8699 100644
5348 --- a/arch/microblaze/include/asm/cache.h
5349 +++ b/arch/microblaze/include/asm/cache.h
5350 @@ -13,11 +13,12 @@
5351 #ifndef _ASM_MICROBLAZE_CACHE_H
5352 #define _ASM_MICROBLAZE_CACHE_H
5353
5354 +#include <linux/const.h>
5355 #include <asm/registers.h>
5356
5357 #define L1_CACHE_SHIFT 5
5358 /* word-granular cache in microblaze */
5359 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5360 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5361
5362 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5363
5364 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5365 index 08b6079..8b554d2 100644
5366 --- a/arch/mips/include/asm/atomic.h
5367 +++ b/arch/mips/include/asm/atomic.h
5368 @@ -21,15 +21,39 @@
5369 #include <asm/cmpxchg.h>
5370 #include <asm/war.h>
5371
5372 +#ifdef CONFIG_GENERIC_ATOMIC64
5373 +#include <asm-generic/atomic64.h>
5374 +#endif
5375 +
5376 #define ATOMIC_INIT(i) { (i) }
5377
5378 +#ifdef CONFIG_64BIT
5379 +#define _ASM_EXTABLE(from, to) \
5380 +" .section __ex_table,\"a\"\n" \
5381 +" .dword " #from ", " #to"\n" \
5382 +" .previous\n"
5383 +#else
5384 +#define _ASM_EXTABLE(from, to) \
5385 +" .section __ex_table,\"a\"\n" \
5386 +" .word " #from ", " #to"\n" \
5387 +" .previous\n"
5388 +#endif
5389 +
5390 /*
5391 * atomic_read - read atomic variable
5392 * @v: pointer of type atomic_t
5393 *
5394 * Atomically reads the value of @v.
5395 */
5396 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5397 +static inline int atomic_read(const atomic_t *v)
5398 +{
5399 + return (*(volatile const int *) &v->counter);
5400 +}
5401 +
5402 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5403 +{
5404 + return (*(volatile const int *) &v->counter);
5405 +}
5406
5407 /*
5408 * atomic_set - set atomic variable
5409 @@ -38,7 +62,15 @@
5410 *
5411 * Atomically sets the value of @v to @i.
5412 */
5413 -#define atomic_set(v, i) ((v)->counter = (i))
5414 +static inline void atomic_set(atomic_t *v, int i)
5415 +{
5416 + v->counter = i;
5417 +}
5418 +
5419 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5420 +{
5421 + v->counter = i;
5422 +}
5423
5424 /*
5425 * atomic_add - add integer to atomic variable
5426 @@ -47,7 +79,67 @@
5427 *
5428 * Atomically adds @i to @v.
5429 */
5430 -static __inline__ void atomic_add(int i, atomic_t * v)
5431 +static __inline__ void atomic_add(int i, atomic_t *v)
5432 +{
5433 + int temp;
5434 +
5435 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5436 + __asm__ __volatile__(
5437 + " .set mips3 \n"
5438 + "1: ll %0, %1 # atomic_add \n"
5439 +#ifdef CONFIG_PAX_REFCOUNT
5440 + /* Exception on overflow. */
5441 + "2: add %0, %2 \n"
5442 +#else
5443 + " addu %0, %2 \n"
5444 +#endif
5445 + " sc %0, %1 \n"
5446 + " beqzl %0, 1b \n"
5447 +#ifdef CONFIG_PAX_REFCOUNT
5448 + "3: \n"
5449 + _ASM_EXTABLE(2b, 3b)
5450 +#endif
5451 + " .set mips0 \n"
5452 + : "=&r" (temp), "+m" (v->counter)
5453 + : "Ir" (i));
5454 + } else if (kernel_uses_llsc) {
5455 + __asm__ __volatile__(
5456 + " .set mips3 \n"
5457 + "1: ll %0, %1 # atomic_add \n"
5458 +#ifdef CONFIG_PAX_REFCOUNT
5459 + /* Exception on overflow. */
5460 + "2: add %0, %2 \n"
5461 +#else
5462 + " addu %0, %2 \n"
5463 +#endif
5464 + " sc %0, %1 \n"
5465 + " beqz %0, 1b \n"
5466 +#ifdef CONFIG_PAX_REFCOUNT
5467 + "3: \n"
5468 + _ASM_EXTABLE(2b, 3b)
5469 +#endif
5470 + " .set mips0 \n"
5471 + : "=&r" (temp), "+m" (v->counter)
5472 + : "Ir" (i));
5473 + } else {
5474 + unsigned long flags;
5475 +
5476 + raw_local_irq_save(flags);
5477 + __asm__ __volatile__(
5478 +#ifdef CONFIG_PAX_REFCOUNT
5479 + /* Exception on overflow. */
5480 + "1: add %0, %1 \n"
5481 + "2: \n"
5482 + _ASM_EXTABLE(1b, 2b)
5483 +#else
5484 + " addu %0, %1 \n"
5485 +#endif
5486 + : "+r" (v->counter) : "Ir" (i));
5487 + raw_local_irq_restore(flags);
5488 + }
5489 +}
5490 +
5491 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5492 {
5493 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5494 int temp;
5495 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5496 *
5497 * Atomically subtracts @i from @v.
5498 */
5499 -static __inline__ void atomic_sub(int i, atomic_t * v)
5500 +static __inline__ void atomic_sub(int i, atomic_t *v)
5501 +{
5502 + int temp;
5503 +
5504 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5505 + __asm__ __volatile__(
5506 + " .set mips3 \n"
5507 + "1: ll %0, %1 # atomic64_sub \n"
5508 +#ifdef CONFIG_PAX_REFCOUNT
5509 + /* Exception on overflow. */
5510 + "2: sub %0, %2 \n"
5511 +#else
5512 + " subu %0, %2 \n"
5513 +#endif
5514 + " sc %0, %1 \n"
5515 + " beqzl %0, 1b \n"
5516 +#ifdef CONFIG_PAX_REFCOUNT
5517 + "3: \n"
5518 + _ASM_EXTABLE(2b, 3b)
5519 +#endif
5520 + " .set mips0 \n"
5521 + : "=&r" (temp), "+m" (v->counter)
5522 + : "Ir" (i));
5523 + } else if (kernel_uses_llsc) {
5524 + __asm__ __volatile__(
5525 + " .set mips3 \n"
5526 + "1: ll %0, %1 # atomic64_sub \n"
5527 +#ifdef CONFIG_PAX_REFCOUNT
5528 + /* Exception on overflow. */
5529 + "2: sub %0, %2 \n"
5530 +#else
5531 + " subu %0, %2 \n"
5532 +#endif
5533 + " sc %0, %1 \n"
5534 + " beqz %0, 1b \n"
5535 +#ifdef CONFIG_PAX_REFCOUNT
5536 + "3: \n"
5537 + _ASM_EXTABLE(2b, 3b)
5538 +#endif
5539 + " .set mips0 \n"
5540 + : "=&r" (temp), "+m" (v->counter)
5541 + : "Ir" (i));
5542 + } else {
5543 + unsigned long flags;
5544 +
5545 + raw_local_irq_save(flags);
5546 + __asm__ __volatile__(
5547 +#ifdef CONFIG_PAX_REFCOUNT
5548 + /* Exception on overflow. */
5549 + "1: sub %0, %1 \n"
5550 + "2: \n"
5551 + _ASM_EXTABLE(1b, 2b)
5552 +#else
5553 + " subu %0, %1 \n"
5554 +#endif
5555 + : "+r" (v->counter) : "Ir" (i));
5556 + raw_local_irq_restore(flags);
5557 + }
5558 +}
5559 +
5560 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5561 {
5562 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5563 int temp;
5564 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5565 /*
5566 * Same as above, but return the result value
5567 */
5568 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5569 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5570 +{
5571 + int result;
5572 + int temp;
5573 +
5574 + smp_mb__before_llsc();
5575 +
5576 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5577 + __asm__ __volatile__(
5578 + " .set mips3 \n"
5579 + "1: ll %1, %2 # atomic_add_return \n"
5580 +#ifdef CONFIG_PAX_REFCOUNT
5581 + "2: add %0, %1, %3 \n"
5582 +#else
5583 + " addu %0, %1, %3 \n"
5584 +#endif
5585 + " sc %0, %2 \n"
5586 + " beqzl %0, 1b \n"
5587 +#ifdef CONFIG_PAX_REFCOUNT
5588 + " b 4f \n"
5589 + " .set noreorder \n"
5590 + "3: b 5f \n"
5591 + " move %0, %1 \n"
5592 + " .set reorder \n"
5593 + _ASM_EXTABLE(2b, 3b)
5594 +#endif
5595 + "4: addu %0, %1, %3 \n"
5596 +#ifdef CONFIG_PAX_REFCOUNT
5597 + "5: \n"
5598 +#endif
5599 + " .set mips0 \n"
5600 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5601 + : "Ir" (i));
5602 + } else if (kernel_uses_llsc) {
5603 + __asm__ __volatile__(
5604 + " .set mips3 \n"
5605 + "1: ll %1, %2 # atomic_add_return \n"
5606 +#ifdef CONFIG_PAX_REFCOUNT
5607 + "2: add %0, %1, %3 \n"
5608 +#else
5609 + " addu %0, %1, %3 \n"
5610 +#endif
5611 + " sc %0, %2 \n"
5612 + " bnez %0, 4f \n"
5613 + " b 1b \n"
5614 +#ifdef CONFIG_PAX_REFCOUNT
5615 + " .set noreorder \n"
5616 + "3: b 5f \n"
5617 + " move %0, %1 \n"
5618 + " .set reorder \n"
5619 + _ASM_EXTABLE(2b, 3b)
5620 +#endif
5621 + "4: addu %0, %1, %3 \n"
5622 +#ifdef CONFIG_PAX_REFCOUNT
5623 + "5: \n"
5624 +#endif
5625 + " .set mips0 \n"
5626 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5627 + : "Ir" (i));
5628 + } else {
5629 + unsigned long flags;
5630 +
5631 + raw_local_irq_save(flags);
5632 + __asm__ __volatile__(
5633 + " lw %0, %1 \n"
5634 +#ifdef CONFIG_PAX_REFCOUNT
5635 + /* Exception on overflow. */
5636 + "1: add %0, %2 \n"
5637 +#else
5638 + " addu %0, %2 \n"
5639 +#endif
5640 + " sw %0, %1 \n"
5641 +#ifdef CONFIG_PAX_REFCOUNT
5642 + /* Note: Dest reg is not modified on overflow */
5643 + "2: \n"
5644 + _ASM_EXTABLE(1b, 2b)
5645 +#endif
5646 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5647 + raw_local_irq_restore(flags);
5648 + }
5649 +
5650 + smp_llsc_mb();
5651 +
5652 + return result;
5653 +}
5654 +
5655 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5656 {
5657 int result;
5658
5659 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5660 return result;
5661 }
5662
5663 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5664 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5665 +{
5666 + int result;
5667 + int temp;
5668 +
5669 + smp_mb__before_llsc();
5670 +
5671 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5672 + __asm__ __volatile__(
5673 + " .set mips3 \n"
5674 + "1: ll %1, %2 # atomic_sub_return \n"
5675 +#ifdef CONFIG_PAX_REFCOUNT
5676 + "2: sub %0, %1, %3 \n"
5677 +#else
5678 + " subu %0, %1, %3 \n"
5679 +#endif
5680 + " sc %0, %2 \n"
5681 + " beqzl %0, 1b \n"
5682 +#ifdef CONFIG_PAX_REFCOUNT
5683 + " b 4f \n"
5684 + " .set noreorder \n"
5685 + "3: b 5f \n"
5686 + " move %0, %1 \n"
5687 + " .set reorder \n"
5688 + _ASM_EXTABLE(2b, 3b)
5689 +#endif
5690 + "4: subu %0, %1, %3 \n"
5691 +#ifdef CONFIG_PAX_REFCOUNT
5692 + "5: \n"
5693 +#endif
5694 + " .set mips0 \n"
5695 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5696 + : "Ir" (i), "m" (v->counter)
5697 + : "memory");
5698 + } else if (kernel_uses_llsc) {
5699 + __asm__ __volatile__(
5700 + " .set mips3 \n"
5701 + "1: ll %1, %2 # atomic_sub_return \n"
5702 +#ifdef CONFIG_PAX_REFCOUNT
5703 + "2: sub %0, %1, %3 \n"
5704 +#else
5705 + " subu %0, %1, %3 \n"
5706 +#endif
5707 + " sc %0, %2 \n"
5708 + " bnez %0, 4f \n"
5709 + " b 1b \n"
5710 +#ifdef CONFIG_PAX_REFCOUNT
5711 + " .set noreorder \n"
5712 + "3: b 5f \n"
5713 + " move %0, %1 \n"
5714 + " .set reorder \n"
5715 + _ASM_EXTABLE(2b, 3b)
5716 +#endif
5717 + "4: subu %0, %1, %3 \n"
5718 +#ifdef CONFIG_PAX_REFCOUNT
5719 + "5: \n"
5720 +#endif
5721 + " .set mips0 \n"
5722 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5723 + : "Ir" (i));
5724 + } else {
5725 + unsigned long flags;
5726 +
5727 + raw_local_irq_save(flags);
5728 + __asm__ __volatile__(
5729 + " lw %0, %1 \n"
5730 +#ifdef CONFIG_PAX_REFCOUNT
5731 + /* Exception on overflow. */
5732 + "1: sub %0, %2 \n"
5733 +#else
5734 + " subu %0, %2 \n"
5735 +#endif
5736 + " sw %0, %1 \n"
5737 +#ifdef CONFIG_PAX_REFCOUNT
5738 + /* Note: Dest reg is not modified on overflow */
5739 + "2: \n"
5740 + _ASM_EXTABLE(1b, 2b)
5741 +#endif
5742 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5743 + raw_local_irq_restore(flags);
5744 + }
5745 +
5746 + smp_llsc_mb();
5747 +
5748 + return result;
5749 +}
5750 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5751 {
5752 int result;
5753
5754 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5755 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5756 * The function returns the old value of @v minus @i.
5757 */
5758 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5759 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5760 {
5761 int result;
5762
5763 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5764 return result;
5765 }
5766
5767 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5768 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5769 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5770 +{
5771 + return cmpxchg(&v->counter, old, new);
5772 +}
5773 +
5774 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5775 + int new)
5776 +{
5777 + return cmpxchg(&(v->counter), old, new);
5778 +}
5779 +
5780 +static inline int atomic_xchg(atomic_t *v, int new)
5781 +{
5782 + return xchg(&v->counter, new);
5783 +}
5784 +
5785 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5786 +{
5787 + return xchg(&(v->counter), new);
5788 +}
5789
5790 /**
5791 * __atomic_add_unless - add unless the number is a given value
5792 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5793
5794 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5795 #define atomic_inc_return(v) atomic_add_return(1, (v))
5796 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5797 +{
5798 + return atomic_add_return_unchecked(1, v);
5799 +}
5800
5801 /*
5802 * atomic_sub_and_test - subtract value from variable and test result
5803 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5804 * other cases.
5805 */
5806 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5807 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5808 +{
5809 + return atomic_add_return_unchecked(1, v) == 0;
5810 +}
5811
5812 /*
5813 * atomic_dec_and_test - decrement by 1 and test
5814 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5815 * Atomically increments @v by 1.
5816 */
5817 #define atomic_inc(v) atomic_add(1, (v))
5818 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5819 +{
5820 + atomic_add_unchecked(1, v);
5821 +}
5822
5823 /*
5824 * atomic_dec - decrement and test
5825 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5826 * Atomically decrements @v by 1.
5827 */
5828 #define atomic_dec(v) atomic_sub(1, (v))
5829 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5830 +{
5831 + atomic_sub_unchecked(1, v);
5832 +}
5833
5834 /*
5835 * atomic_add_negative - add and test if negative
5836 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5837 * @v: pointer of type atomic64_t
5838 *
5839 */
5840 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5841 +static inline long atomic64_read(const atomic64_t *v)
5842 +{
5843 + return (*(volatile const long *) &v->counter);
5844 +}
5845 +
5846 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5847 +{
5848 + return (*(volatile const long *) &v->counter);
5849 +}
5850
5851 /*
5852 * atomic64_set - set atomic variable
5853 * @v: pointer of type atomic64_t
5854 * @i: required value
5855 */
5856 -#define atomic64_set(v, i) ((v)->counter = (i))
5857 +static inline void atomic64_set(atomic64_t *v, long i)
5858 +{
5859 + v->counter = i;
5860 +}
5861 +
5862 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5863 +{
5864 + v->counter = i;
5865 +}
5866
5867 /*
5868 * atomic64_add - add integer to atomic variable
5869 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5870 *
5871 * Atomically adds @i to @v.
5872 */
5873 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5874 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5875 +{
5876 + long temp;
5877 +
5878 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5879 + __asm__ __volatile__(
5880 + " .set mips3 \n"
5881 + "1: lld %0, %1 # atomic64_add \n"
5882 +#ifdef CONFIG_PAX_REFCOUNT
5883 + /* Exception on overflow. */
5884 + "2: dadd %0, %2 \n"
5885 +#else
5886 + " daddu %0, %2 \n"
5887 +#endif
5888 + " scd %0, %1 \n"
5889 + " beqzl %0, 1b \n"
5890 +#ifdef CONFIG_PAX_REFCOUNT
5891 + "3: \n"
5892 + _ASM_EXTABLE(2b, 3b)
5893 +#endif
5894 + " .set mips0 \n"
5895 + : "=&r" (temp), "+m" (v->counter)
5896 + : "Ir" (i));
5897 + } else if (kernel_uses_llsc) {
5898 + __asm__ __volatile__(
5899 + " .set mips3 \n"
5900 + "1: lld %0, %1 # atomic64_add \n"
5901 +#ifdef CONFIG_PAX_REFCOUNT
5902 + /* Exception on overflow. */
5903 + "2: dadd %0, %2 \n"
5904 +#else
5905 + " daddu %0, %2 \n"
5906 +#endif
5907 + " scd %0, %1 \n"
5908 + " beqz %0, 1b \n"
5909 +#ifdef CONFIG_PAX_REFCOUNT
5910 + "3: \n"
5911 + _ASM_EXTABLE(2b, 3b)
5912 +#endif
5913 + " .set mips0 \n"
5914 + : "=&r" (temp), "+m" (v->counter)
5915 + : "Ir" (i));
5916 + } else {
5917 + unsigned long flags;
5918 +
5919 + raw_local_irq_save(flags);
5920 + __asm__ __volatile__(
5921 +#ifdef CONFIG_PAX_REFCOUNT
5922 + /* Exception on overflow. */
5923 + "1: dadd %0, %1 \n"
5924 + "2: \n"
5925 + _ASM_EXTABLE(1b, 2b)
5926 +#else
5927 + " daddu %0, %1 \n"
5928 +#endif
5929 + : "+r" (v->counter) : "Ir" (i));
5930 + raw_local_irq_restore(flags);
5931 + }
5932 +}
5933 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5934 {
5935 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5936 long temp;
5937 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5938 *
5939 * Atomically subtracts @i from @v.
5940 */
5941 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5942 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5943 +{
5944 + long temp;
5945 +
5946 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5947 + __asm__ __volatile__(
5948 + " .set mips3 \n"
5949 + "1: lld %0, %1 # atomic64_sub \n"
5950 +#ifdef CONFIG_PAX_REFCOUNT
5951 + /* Exception on overflow. */
5952 + "2: dsub %0, %2 \n"
5953 +#else
5954 + " dsubu %0, %2 \n"
5955 +#endif
5956 + " scd %0, %1 \n"
5957 + " beqzl %0, 1b \n"
5958 +#ifdef CONFIG_PAX_REFCOUNT
5959 + "3: \n"
5960 + _ASM_EXTABLE(2b, 3b)
5961 +#endif
5962 + " .set mips0 \n"
5963 + : "=&r" (temp), "+m" (v->counter)
5964 + : "Ir" (i));
5965 + } else if (kernel_uses_llsc) {
5966 + __asm__ __volatile__(
5967 + " .set mips3 \n"
5968 + "1: lld %0, %1 # atomic64_sub \n"
5969 +#ifdef CONFIG_PAX_REFCOUNT
5970 + /* Exception on overflow. */
5971 + "2: dsub %0, %2 \n"
5972 +#else
5973 + " dsubu %0, %2 \n"
5974 +#endif
5975 + " scd %0, %1 \n"
5976 + " beqz %0, 1b \n"
5977 +#ifdef CONFIG_PAX_REFCOUNT
5978 + "3: \n"
5979 + _ASM_EXTABLE(2b, 3b)
5980 +#endif
5981 + " .set mips0 \n"
5982 + : "=&r" (temp), "+m" (v->counter)
5983 + : "Ir" (i));
5984 + } else {
5985 + unsigned long flags;
5986 +
5987 + raw_local_irq_save(flags);
5988 + __asm__ __volatile__(
5989 +#ifdef CONFIG_PAX_REFCOUNT
5990 + /* Exception on overflow. */
5991 + "1: dsub %0, %1 \n"
5992 + "2: \n"
5993 + _ASM_EXTABLE(1b, 2b)
5994 +#else
5995 + " dsubu %0, %1 \n"
5996 +#endif
5997 + : "+r" (v->counter) : "Ir" (i));
5998 + raw_local_irq_restore(flags);
5999 + }
6000 +}
6001 +
6002 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6003 {
6004 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6005 long temp;
6006 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6007 /*
6008 * Same as above, but return the result value
6009 */
6010 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6011 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6012 +{
6013 + long result;
6014 + long temp;
6015 +
6016 + smp_mb__before_llsc();
6017 +
6018 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6019 + __asm__ __volatile__(
6020 + " .set mips3 \n"
6021 + "1: lld %1, %2 # atomic64_add_return \n"
6022 +#ifdef CONFIG_PAX_REFCOUNT
6023 + "2: dadd %0, %1, %3 \n"
6024 +#else
6025 + " daddu %0, %1, %3 \n"
6026 +#endif
6027 + " scd %0, %2 \n"
6028 + " beqzl %0, 1b \n"
6029 +#ifdef CONFIG_PAX_REFCOUNT
6030 + " b 4f \n"
6031 + " .set noreorder \n"
6032 + "3: b 5f \n"
6033 + " move %0, %1 \n"
6034 + " .set reorder \n"
6035 + _ASM_EXTABLE(2b, 3b)
6036 +#endif
6037 + "4: daddu %0, %1, %3 \n"
6038 +#ifdef CONFIG_PAX_REFCOUNT
6039 + "5: \n"
6040 +#endif
6041 + " .set mips0 \n"
6042 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6043 + : "Ir" (i));
6044 + } else if (kernel_uses_llsc) {
6045 + __asm__ __volatile__(
6046 + " .set mips3 \n"
6047 + "1: lld %1, %2 # atomic64_add_return \n"
6048 +#ifdef CONFIG_PAX_REFCOUNT
6049 + "2: dadd %0, %1, %3 \n"
6050 +#else
6051 + " daddu %0, %1, %3 \n"
6052 +#endif
6053 + " scd %0, %2 \n"
6054 + " bnez %0, 4f \n"
6055 + " b 1b \n"
6056 +#ifdef CONFIG_PAX_REFCOUNT
6057 + " .set noreorder \n"
6058 + "3: b 5f \n"
6059 + " move %0, %1 \n"
6060 + " .set reorder \n"
6061 + _ASM_EXTABLE(2b, 3b)
6062 +#endif
6063 + "4: daddu %0, %1, %3 \n"
6064 +#ifdef CONFIG_PAX_REFCOUNT
6065 + "5: \n"
6066 +#endif
6067 + " .set mips0 \n"
6068 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6069 + : "Ir" (i), "m" (v->counter)
6070 + : "memory");
6071 + } else {
6072 + unsigned long flags;
6073 +
6074 + raw_local_irq_save(flags);
6075 + __asm__ __volatile__(
6076 + " ld %0, %1 \n"
6077 +#ifdef CONFIG_PAX_REFCOUNT
6078 + /* Exception on overflow. */
6079 + "1: dadd %0, %2 \n"
6080 +#else
6081 + " daddu %0, %2 \n"
6082 +#endif
6083 + " sd %0, %1 \n"
6084 +#ifdef CONFIG_PAX_REFCOUNT
6085 + /* Note: Dest reg is not modified on overflow */
6086 + "2: \n"
6087 + _ASM_EXTABLE(1b, 2b)
6088 +#endif
6089 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6090 + raw_local_irq_restore(flags);
6091 + }
6092 +
6093 + smp_llsc_mb();
6094 +
6095 + return result;
6096 +}
6097 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6098 {
6099 long result;
6100
6101 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6102 return result;
6103 }
6104
6105 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6106 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6107 +{
6108 + long result;
6109 + long temp;
6110 +
6111 + smp_mb__before_llsc();
6112 +
6113 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6114 + long temp;
6115 +
6116 + __asm__ __volatile__(
6117 + " .set mips3 \n"
6118 + "1: lld %1, %2 # atomic64_sub_return \n"
6119 +#ifdef CONFIG_PAX_REFCOUNT
6120 + "2: dsub %0, %1, %3 \n"
6121 +#else
6122 + " dsubu %0, %1, %3 \n"
6123 +#endif
6124 + " scd %0, %2 \n"
6125 + " beqzl %0, 1b \n"
6126 +#ifdef CONFIG_PAX_REFCOUNT
6127 + " b 4f \n"
6128 + " .set noreorder \n"
6129 + "3: b 5f \n"
6130 + " move %0, %1 \n"
6131 + " .set reorder \n"
6132 + _ASM_EXTABLE(2b, 3b)
6133 +#endif
6134 + "4: dsubu %0, %1, %3 \n"
6135 +#ifdef CONFIG_PAX_REFCOUNT
6136 + "5: \n"
6137 +#endif
6138 + " .set mips0 \n"
6139 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6140 + : "Ir" (i), "m" (v->counter)
6141 + : "memory");
6142 + } else if (kernel_uses_llsc) {
6143 + __asm__ __volatile__(
6144 + " .set mips3 \n"
6145 + "1: lld %1, %2 # atomic64_sub_return \n"
6146 +#ifdef CONFIG_PAX_REFCOUNT
6147 + "2: dsub %0, %1, %3 \n"
6148 +#else
6149 + " dsubu %0, %1, %3 \n"
6150 +#endif
6151 + " scd %0, %2 \n"
6152 + " bnez %0, 4f \n"
6153 + " b 1b \n"
6154 +#ifdef CONFIG_PAX_REFCOUNT
6155 + " .set noreorder \n"
6156 + "3: b 5f \n"
6157 + " move %0, %1 \n"
6158 + " .set reorder \n"
6159 + _ASM_EXTABLE(2b, 3b)
6160 +#endif
6161 + "4: dsubu %0, %1, %3 \n"
6162 +#ifdef CONFIG_PAX_REFCOUNT
6163 + "5: \n"
6164 +#endif
6165 + " .set mips0 \n"
6166 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6167 + : "Ir" (i), "m" (v->counter)
6168 + : "memory");
6169 + } else {
6170 + unsigned long flags;
6171 +
6172 + raw_local_irq_save(flags);
6173 + __asm__ __volatile__(
6174 + " ld %0, %1 \n"
6175 +#ifdef CONFIG_PAX_REFCOUNT
6176 + /* Exception on overflow. */
6177 + "1: dsub %0, %2 \n"
6178 +#else
6179 + " dsubu %0, %2 \n"
6180 +#endif
6181 + " sd %0, %1 \n"
6182 +#ifdef CONFIG_PAX_REFCOUNT
6183 + /* Note: Dest reg is not modified on overflow */
6184 + "2: \n"
6185 + _ASM_EXTABLE(1b, 2b)
6186 +#endif
6187 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6188 + raw_local_irq_restore(flags);
6189 + }
6190 +
6191 + smp_llsc_mb();
6192 +
6193 + return result;
6194 +}
6195 +
6196 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6197 {
6198 long result;
6199
6200 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6201 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6202 * The function returns the old value of @v minus @i.
6203 */
6204 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6205 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6206 {
6207 long result;
6208
6209 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6210 return result;
6211 }
6212
6213 -#define atomic64_cmpxchg(v, o, n) \
6214 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6215 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6216 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6217 +{
6218 + return cmpxchg(&v->counter, old, new);
6219 +}
6220 +
6221 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6222 + long new)
6223 +{
6224 + return cmpxchg(&(v->counter), old, new);
6225 +}
6226 +
6227 +static inline long atomic64_xchg(atomic64_t *v, long new)
6228 +{
6229 + return xchg(&v->counter, new);
6230 +}
6231 +
6232 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6233 +{
6234 + return xchg(&(v->counter), new);
6235 +}
6236
6237 /**
6238 * atomic64_add_unless - add unless the number is a given value
6239 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6240
6241 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6242 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6243 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6244
6245 /*
6246 * atomic64_sub_and_test - subtract value from variable and test result
6247 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6248 * other cases.
6249 */
6250 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6251 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6252
6253 /*
6254 * atomic64_dec_and_test - decrement by 1 and test
6255 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6256 * Atomically increments @v by 1.
6257 */
6258 #define atomic64_inc(v) atomic64_add(1, (v))
6259 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6260
6261 /*
6262 * atomic64_dec - decrement and test
6263 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6264 * Atomically decrements @v by 1.
6265 */
6266 #define atomic64_dec(v) atomic64_sub(1, (v))
6267 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6268
6269 /*
6270 * atomic64_add_negative - add and test if negative
6271 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6272 index b4db69f..8f3b093 100644
6273 --- a/arch/mips/include/asm/cache.h
6274 +++ b/arch/mips/include/asm/cache.h
6275 @@ -9,10 +9,11 @@
6276 #ifndef _ASM_CACHE_H
6277 #define _ASM_CACHE_H
6278
6279 +#include <linux/const.h>
6280 #include <kmalloc.h>
6281
6282 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6283 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6284 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6285
6286 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6287 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6288 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6289 index cf3ae24..238d22f 100644
6290 --- a/arch/mips/include/asm/elf.h
6291 +++ b/arch/mips/include/asm/elf.h
6292 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6293 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6294 #endif
6295
6296 +#ifdef CONFIG_PAX_ASLR
6297 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6298 +
6299 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6300 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6301 +#endif
6302 +
6303 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6304 struct linux_binprm;
6305 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6306 int uses_interp);
6307
6308 -struct mm_struct;
6309 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6310 -#define arch_randomize_brk arch_randomize_brk
6311 -
6312 #endif /* _ASM_ELF_H */
6313 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6314 index c1f6afa..38cc6e9 100644
6315 --- a/arch/mips/include/asm/exec.h
6316 +++ b/arch/mips/include/asm/exec.h
6317 @@ -12,6 +12,6 @@
6318 #ifndef _ASM_EXEC_H
6319 #define _ASM_EXEC_H
6320
6321 -extern unsigned long arch_align_stack(unsigned long sp);
6322 +#define arch_align_stack(x) ((x) & ~0xfUL)
6323
6324 #endif /* _ASM_EXEC_H */
6325 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6326 index d44622c..64990d2 100644
6327 --- a/arch/mips/include/asm/local.h
6328 +++ b/arch/mips/include/asm/local.h
6329 @@ -12,15 +12,25 @@ typedef struct
6330 atomic_long_t a;
6331 } local_t;
6332
6333 +typedef struct {
6334 + atomic_long_unchecked_t a;
6335 +} local_unchecked_t;
6336 +
6337 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6338
6339 #define local_read(l) atomic_long_read(&(l)->a)
6340 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6341 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6342 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6343
6344 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6345 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6346 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6347 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6348 #define local_inc(l) atomic_long_inc(&(l)->a)
6349 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6350 #define local_dec(l) atomic_long_dec(&(l)->a)
6351 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6352
6353 /*
6354 * Same as above, but return the result value
6355 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6356 return result;
6357 }
6358
6359 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6360 +{
6361 + unsigned long result;
6362 +
6363 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6364 + unsigned long temp;
6365 +
6366 + __asm__ __volatile__(
6367 + " .set mips3 \n"
6368 + "1:" __LL "%1, %2 # local_add_return \n"
6369 + " addu %0, %1, %3 \n"
6370 + __SC "%0, %2 \n"
6371 + " beqzl %0, 1b \n"
6372 + " addu %0, %1, %3 \n"
6373 + " .set mips0 \n"
6374 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6375 + : "Ir" (i), "m" (l->a.counter)
6376 + : "memory");
6377 + } else if (kernel_uses_llsc) {
6378 + unsigned long temp;
6379 +
6380 + __asm__ __volatile__(
6381 + " .set mips3 \n"
6382 + "1:" __LL "%1, %2 # local_add_return \n"
6383 + " addu %0, %1, %3 \n"
6384 + __SC "%0, %2 \n"
6385 + " beqz %0, 1b \n"
6386 + " addu %0, %1, %3 \n"
6387 + " .set mips0 \n"
6388 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6389 + : "Ir" (i), "m" (l->a.counter)
6390 + : "memory");
6391 + } else {
6392 + unsigned long flags;
6393 +
6394 + local_irq_save(flags);
6395 + result = l->a.counter;
6396 + result += i;
6397 + l->a.counter = result;
6398 + local_irq_restore(flags);
6399 + }
6400 +
6401 + return result;
6402 +}
6403 +
6404 static __inline__ long local_sub_return(long i, local_t * l)
6405 {
6406 unsigned long result;
6407 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6408
6409 #define local_cmpxchg(l, o, n) \
6410 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6411 +#define local_cmpxchg_unchecked(l, o, n) \
6412 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6413 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6414
6415 /**
6416 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6417 index f6be474..12ad554 100644
6418 --- a/arch/mips/include/asm/page.h
6419 +++ b/arch/mips/include/asm/page.h
6420 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6421 #ifdef CONFIG_CPU_MIPS32
6422 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6423 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6424 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6425 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6426 #else
6427 typedef struct { unsigned long long pte; } pte_t;
6428 #define pte_val(x) ((x).pte)
6429 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6430 index 881d18b..cea38bc 100644
6431 --- a/arch/mips/include/asm/pgalloc.h
6432 +++ b/arch/mips/include/asm/pgalloc.h
6433 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6434 {
6435 set_pud(pud, __pud((unsigned long)pmd));
6436 }
6437 +
6438 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6439 +{
6440 + pud_populate(mm, pud, pmd);
6441 +}
6442 #endif
6443
6444 /*
6445 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6446 index 25da651..ae2a259 100644
6447 --- a/arch/mips/include/asm/smtc_proc.h
6448 +++ b/arch/mips/include/asm/smtc_proc.h
6449 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6450
6451 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6452
6453 -extern atomic_t smtc_fpu_recoveries;
6454 +extern atomic_unchecked_t smtc_fpu_recoveries;
6455
6456 #endif /* __ASM_SMTC_PROC_H */
6457 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6458 index 61215a3..213ee0e 100644
6459 --- a/arch/mips/include/asm/thread_info.h
6460 +++ b/arch/mips/include/asm/thread_info.h
6461 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6462 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6463 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6464 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6465 +/* li takes a 32bit immediate */
6466 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6467 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6468
6469 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6470 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6471 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6472 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6473 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6474 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6475
6476 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6477 - _TIF_SYSCALL_AUDIT)
6478 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6479
6480 /* work to do in syscall_trace_leave() */
6481 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6482 - _TIF_SYSCALL_AUDIT)
6483 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6484
6485 /* work to do on interrupt/exception return */
6486 #define _TIF_WORK_MASK \
6487 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6488 /* work to do on any return to u-space */
6489 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6490 - _TIF_WORK_SYSCALL_EXIT)
6491 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6492
6493 #endif /* __KERNEL__ */
6494
6495 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6496 index 1188e00..41cf144 100644
6497 --- a/arch/mips/kernel/binfmt_elfn32.c
6498 +++ b/arch/mips/kernel/binfmt_elfn32.c
6499 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6500 #undef ELF_ET_DYN_BASE
6501 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6502
6503 +#ifdef CONFIG_PAX_ASLR
6504 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6505 +
6506 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6507 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6508 +#endif
6509 +
6510 #include <asm/processor.h>
6511 #include <linux/module.h>
6512 #include <linux/elfcore.h>
6513 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6514 index 202e581..689ca79 100644
6515 --- a/arch/mips/kernel/binfmt_elfo32.c
6516 +++ b/arch/mips/kernel/binfmt_elfo32.c
6517 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6518 #undef ELF_ET_DYN_BASE
6519 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6520
6521 +#ifdef CONFIG_PAX_ASLR
6522 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6523 +
6524 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6525 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6526 +#endif
6527 +
6528 #include <asm/processor.h>
6529
6530 /*
6531 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6532 index d1fea7a..45602ea 100644
6533 --- a/arch/mips/kernel/irq.c
6534 +++ b/arch/mips/kernel/irq.c
6535 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6536 printk("unexpected IRQ # %d\n", irq);
6537 }
6538
6539 -atomic_t irq_err_count;
6540 +atomic_unchecked_t irq_err_count;
6541
6542 int arch_show_interrupts(struct seq_file *p, int prec)
6543 {
6544 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6545 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6546 return 0;
6547 }
6548
6549 asmlinkage void spurious_interrupt(void)
6550 {
6551 - atomic_inc(&irq_err_count);
6552 + atomic_inc_unchecked(&irq_err_count);
6553 }
6554
6555 void __init init_IRQ(void)
6556 diff --git a/arch/mips/kernel/octeon_switch.S b/arch/mips/kernel/octeon_switch.S
6557 index 4204d76..029e002 100644
6558 --- a/arch/mips/kernel/octeon_switch.S
6559 +++ b/arch/mips/kernel/octeon_switch.S
6560 @@ -73,7 +73,7 @@
6561 3:
6562
6563 #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
6564 - PTR_L t8, __stack_chk_guard
6565 + PTR_LA t8, __stack_chk_guard
6566 LONG_L t9, TASK_STACK_CANARY(a1)
6567 LONG_S t9, 0(t8)
6568 #endif
6569 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6570 index ddc7610..8c58f17 100644
6571 --- a/arch/mips/kernel/process.c
6572 +++ b/arch/mips/kernel/process.c
6573 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6574 out:
6575 return pc;
6576 }
6577 -
6578 -/*
6579 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6580 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6581 - */
6582 -unsigned long arch_align_stack(unsigned long sp)
6583 -{
6584 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6585 - sp -= get_random_int() & ~PAGE_MASK;
6586 -
6587 - return sp & ALMASK;
6588 -}
6589 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6590 index 8ae1ebe..1bcbf47 100644
6591 --- a/arch/mips/kernel/ptrace.c
6592 +++ b/arch/mips/kernel/ptrace.c
6593 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6594 return arch;
6595 }
6596
6597 +#ifdef CONFIG_GRKERNSEC_SETXID
6598 +extern void gr_delayed_cred_worker(void);
6599 +#endif
6600 +
6601 /*
6602 * Notification of system call entry/exit
6603 * - triggered by current->work.syscall_trace
6604 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6605 /* do the secure computing check first */
6606 secure_computing_strict(regs->regs[2]);
6607
6608 +#ifdef CONFIG_GRKERNSEC_SETXID
6609 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6610 + gr_delayed_cred_worker();
6611 +#endif
6612 +
6613 if (!(current->ptrace & PT_PTRACED))
6614 goto out;
6615
6616 diff --git a/arch/mips/kernel/r2300_switch.S b/arch/mips/kernel/r2300_switch.S
6617 index 38af83f..20b7b04 100644
6618 --- a/arch/mips/kernel/r2300_switch.S
6619 +++ b/arch/mips/kernel/r2300_switch.S
6620 @@ -67,7 +67,7 @@ LEAF(resume)
6621 1:
6622
6623 #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
6624 - PTR_L t8, __stack_chk_guard
6625 + PTR_LA t8, __stack_chk_guard
6626 LONG_L t9, TASK_STACK_CANARY(a1)
6627 LONG_S t9, 0(t8)
6628 #endif
6629 diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
6630 index 921238a..078de5e 100644
6631 --- a/arch/mips/kernel/r4k_switch.S
6632 +++ b/arch/mips/kernel/r4k_switch.S
6633 @@ -69,7 +69,7 @@
6634 1:
6635
6636 #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
6637 - PTR_L t8, __stack_chk_guard
6638 + PTR_LA t8, __stack_chk_guard
6639 LONG_L t9, TASK_STACK_CANARY(a1)
6640 LONG_S t9, 0(t8)
6641 #endif
6642 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6643 index c10aa84..9ec2e60 100644
6644 --- a/arch/mips/kernel/smtc-proc.c
6645 +++ b/arch/mips/kernel/smtc-proc.c
6646 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6647
6648 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6649
6650 -atomic_t smtc_fpu_recoveries;
6651 +atomic_unchecked_t smtc_fpu_recoveries;
6652
6653 static int smtc_proc_show(struct seq_file *m, void *v)
6654 {
6655 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6656 for(i = 0; i < NR_CPUS; i++)
6657 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6658 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6659 - atomic_read(&smtc_fpu_recoveries));
6660 + atomic_read_unchecked(&smtc_fpu_recoveries));
6661 return 0;
6662 }
6663
6664 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6665 smtc_cpu_stats[i].selfipis = 0;
6666 }
6667
6668 - atomic_set(&smtc_fpu_recoveries, 0);
6669 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6670
6671 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6672 }
6673 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6674 index dfc1b91..11a2c07 100644
6675 --- a/arch/mips/kernel/smtc.c
6676 +++ b/arch/mips/kernel/smtc.c
6677 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6678 }
6679 smtc_ipi_qdump();
6680 printk("%d Recoveries of \"stolen\" FPU\n",
6681 - atomic_read(&smtc_fpu_recoveries));
6682 + atomic_read_unchecked(&smtc_fpu_recoveries));
6683 }
6684
6685
6686 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6687 index 84536bf..79caa4d 100644
6688 --- a/arch/mips/kernel/sync-r4k.c
6689 +++ b/arch/mips/kernel/sync-r4k.c
6690 @@ -21,8 +21,8 @@
6691 #include <asm/mipsregs.h>
6692
6693 static atomic_t count_start_flag = ATOMIC_INIT(0);
6694 -static atomic_t count_count_start = ATOMIC_INIT(0);
6695 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6696 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6697 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6698 static atomic_t count_reference = ATOMIC_INIT(0);
6699
6700 #define COUNTON 100
6701 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6702
6703 for (i = 0; i < NR_LOOPS; i++) {
6704 /* slaves loop on '!= 2' */
6705 - while (atomic_read(&count_count_start) != 1)
6706 + while (atomic_read_unchecked(&count_count_start) != 1)
6707 mb();
6708 - atomic_set(&count_count_stop, 0);
6709 + atomic_set_unchecked(&count_count_stop, 0);
6710 smp_wmb();
6711
6712 /* this lets the slaves write their count register */
6713 - atomic_inc(&count_count_start);
6714 + atomic_inc_unchecked(&count_count_start);
6715
6716 /*
6717 * Everyone initialises count in the last loop:
6718 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6719 /*
6720 * Wait for all slaves to leave the synchronization point:
6721 */
6722 - while (atomic_read(&count_count_stop) != 1)
6723 + while (atomic_read_unchecked(&count_count_stop) != 1)
6724 mb();
6725 - atomic_set(&count_count_start, 0);
6726 + atomic_set_unchecked(&count_count_start, 0);
6727 smp_wmb();
6728 - atomic_inc(&count_count_stop);
6729 + atomic_inc_unchecked(&count_count_stop);
6730 }
6731 /* Arrange for an interrupt in a short while */
6732 write_c0_compare(read_c0_count() + COUNTON);
6733 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6734 initcount = atomic_read(&count_reference);
6735
6736 for (i = 0; i < NR_LOOPS; i++) {
6737 - atomic_inc(&count_count_start);
6738 - while (atomic_read(&count_count_start) != 2)
6739 + atomic_inc_unchecked(&count_count_start);
6740 + while (atomic_read_unchecked(&count_count_start) != 2)
6741 mb();
6742
6743 /*
6744 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6745 if (i == NR_LOOPS-1)
6746 write_c0_count(initcount);
6747
6748 - atomic_inc(&count_count_stop);
6749 - while (atomic_read(&count_count_stop) != 2)
6750 + atomic_inc_unchecked(&count_count_stop);
6751 + while (atomic_read_unchecked(&count_count_stop) != 2)
6752 mb();
6753 }
6754 /* Arrange for an interrupt in a short while */
6755 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6756 index aec3408..74d79d3 100644
6757 --- a/arch/mips/kernel/traps.c
6758 +++ b/arch/mips/kernel/traps.c
6759 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6760 siginfo_t info;
6761
6762 prev_state = exception_enter();
6763 - die_if_kernel("Integer overflow", regs);
6764 + if (unlikely(!user_mode(regs))) {
6765 +
6766 +#ifdef CONFIG_PAX_REFCOUNT
6767 + if (fixup_exception(regs)) {
6768 + pax_report_refcount_overflow(regs);
6769 + exception_exit(prev_state);
6770 + return;
6771 + }
6772 +#endif
6773 +
6774 + die("Integer overflow", regs);
6775 + }
6776
6777 info.si_code = FPE_INTOVF;
6778 info.si_signo = SIGFPE;
6779 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6780 index 85df1cd..4f0a4de 100644
6781 --- a/arch/mips/mm/fault.c
6782 +++ b/arch/mips/mm/fault.c
6783 @@ -28,6 +28,23 @@
6784 #include <asm/highmem.h> /* For VMALLOC_END */
6785 #include <linux/kdebug.h>
6786
6787 +#ifdef CONFIG_PAX_PAGEEXEC
6788 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6789 +{
6790 + unsigned long i;
6791 +
6792 + printk(KERN_ERR "PAX: bytes at PC: ");
6793 + for (i = 0; i < 5; i++) {
6794 + unsigned int c;
6795 + if (get_user(c, (unsigned int *)pc+i))
6796 + printk(KERN_CONT "???????? ");
6797 + else
6798 + printk(KERN_CONT "%08x ", c);
6799 + }
6800 + printk("\n");
6801 +}
6802 +#endif
6803 +
6804 /*
6805 * This routine handles page faults. It determines the address,
6806 * and the problem, and then passes it off to one of the appropriate
6807 @@ -197,6 +214,14 @@ bad_area:
6808 bad_area_nosemaphore:
6809 /* User mode accesses just cause a SIGSEGV */
6810 if (user_mode(regs)) {
6811 +
6812 +#ifdef CONFIG_PAX_PAGEEXEC
6813 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6814 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6815 + do_group_exit(SIGKILL);
6816 + }
6817 +#endif
6818 +
6819 tsk->thread.cp0_badvaddr = address;
6820 tsk->thread.error_code = write;
6821 #if 0
6822 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6823 index f1baadd..8537544 100644
6824 --- a/arch/mips/mm/mmap.c
6825 +++ b/arch/mips/mm/mmap.c
6826 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6827 struct vm_area_struct *vma;
6828 unsigned long addr = addr0;
6829 int do_color_align;
6830 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6831 struct vm_unmapped_area_info info;
6832
6833 if (unlikely(len > TASK_SIZE))
6834 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6835 do_color_align = 1;
6836
6837 /* requesting a specific address */
6838 +
6839 +#ifdef CONFIG_PAX_RANDMMAP
6840 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6841 +#endif
6842 +
6843 if (addr) {
6844 if (do_color_align)
6845 addr = COLOUR_ALIGN(addr, pgoff);
6846 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6847 addr = PAGE_ALIGN(addr);
6848
6849 vma = find_vma(mm, addr);
6850 - if (TASK_SIZE - len >= addr &&
6851 - (!vma || addr + len <= vma->vm_start))
6852 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6853 return addr;
6854 }
6855
6856 info.length = len;
6857 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6858 info.align_offset = pgoff << PAGE_SHIFT;
6859 + info.threadstack_offset = offset;
6860
6861 if (dir == DOWN) {
6862 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6863 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6864 {
6865 unsigned long random_factor = 0UL;
6866
6867 +#ifdef CONFIG_PAX_RANDMMAP
6868 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6869 +#endif
6870 +
6871 if (current->flags & PF_RANDOMIZE) {
6872 random_factor = get_random_int();
6873 random_factor = random_factor << PAGE_SHIFT;
6874 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6875
6876 if (mmap_is_legacy()) {
6877 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6878 +
6879 +#ifdef CONFIG_PAX_RANDMMAP
6880 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6881 + mm->mmap_base += mm->delta_mmap;
6882 +#endif
6883 +
6884 mm->get_unmapped_area = arch_get_unmapped_area;
6885 } else {
6886 mm->mmap_base = mmap_base(random_factor);
6887 +
6888 +#ifdef CONFIG_PAX_RANDMMAP
6889 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6890 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6891 +#endif
6892 +
6893 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6894 }
6895 }
6896
6897 -static inline unsigned long brk_rnd(void)
6898 -{
6899 - unsigned long rnd = get_random_int();
6900 -
6901 - rnd = rnd << PAGE_SHIFT;
6902 - /* 8MB for 32bit, 256MB for 64bit */
6903 - if (TASK_IS_32BIT_ADDR)
6904 - rnd = rnd & 0x7ffffful;
6905 - else
6906 - rnd = rnd & 0xffffffful;
6907 -
6908 - return rnd;
6909 -}
6910 -
6911 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6912 -{
6913 - unsigned long base = mm->brk;
6914 - unsigned long ret;
6915 -
6916 - ret = PAGE_ALIGN(base + brk_rnd());
6917 -
6918 - if (ret < mm->brk)
6919 - return mm->brk;
6920 -
6921 - return ret;
6922 -}
6923 -
6924 int __virt_addr_valid(const volatile void *kaddr)
6925 {
6926 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6927 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6928 index a2358b4..7cead4f 100644
6929 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6930 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6931 @@ -187,9 +187,9 @@ void
6932 cont_nmi_dump(void)
6933 {
6934 #ifndef REAL_NMI_SIGNAL
6935 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6936 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6937
6938 - atomic_inc(&nmied_cpus);
6939 + atomic_inc_unchecked(&nmied_cpus);
6940 #endif
6941 /*
6942 * Only allow 1 cpu to proceed
6943 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6944 udelay(10000);
6945 }
6946 #else
6947 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6948 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6949 #endif
6950
6951 /*
6952 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6953 index 967d144..db12197 100644
6954 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6955 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6956 @@ -11,12 +11,14 @@
6957 #ifndef _ASM_PROC_CACHE_H
6958 #define _ASM_PROC_CACHE_H
6959
6960 +#include <linux/const.h>
6961 +
6962 /* L1 cache */
6963
6964 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6965 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6966 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6967 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6968 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6969 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6970
6971 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6972 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6973 index bcb5df2..84fabd2 100644
6974 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6975 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6976 @@ -16,13 +16,15 @@
6977 #ifndef _ASM_PROC_CACHE_H
6978 #define _ASM_PROC_CACHE_H
6979
6980 +#include <linux/const.h>
6981 +
6982 /*
6983 * L1 cache
6984 */
6985 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6986 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6987 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6988 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6989 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6990 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6991
6992 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6993 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6994 index 4ce7a01..449202a 100644
6995 --- a/arch/openrisc/include/asm/cache.h
6996 +++ b/arch/openrisc/include/asm/cache.h
6997 @@ -19,11 +19,13 @@
6998 #ifndef __ASM_OPENRISC_CACHE_H
6999 #define __ASM_OPENRISC_CACHE_H
7000
7001 +#include <linux/const.h>
7002 +
7003 /* FIXME: How can we replace these with values from the CPU...
7004 * they shouldn't be hard-coded!
7005 */
7006
7007 -#define L1_CACHE_BYTES 16
7008 #define L1_CACHE_SHIFT 4
7009 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7010
7011 #endif /* __ASM_OPENRISC_CACHE_H */
7012 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7013 index 472886c..00e7df9 100644
7014 --- a/arch/parisc/include/asm/atomic.h
7015 +++ b/arch/parisc/include/asm/atomic.h
7016 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7017 return dec;
7018 }
7019
7020 +#define atomic64_read_unchecked(v) atomic64_read(v)
7021 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7022 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7023 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7024 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7025 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7026 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7027 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7028 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7029 +
7030 #endif /* !CONFIG_64BIT */
7031
7032
7033 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7034 index 47f11c7..3420df2 100644
7035 --- a/arch/parisc/include/asm/cache.h
7036 +++ b/arch/parisc/include/asm/cache.h
7037 @@ -5,6 +5,7 @@
7038 #ifndef __ARCH_PARISC_CACHE_H
7039 #define __ARCH_PARISC_CACHE_H
7040
7041 +#include <linux/const.h>
7042
7043 /*
7044 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7045 @@ -15,13 +16,13 @@
7046 * just ruin performance.
7047 */
7048 #ifdef CONFIG_PA20
7049 -#define L1_CACHE_BYTES 64
7050 #define L1_CACHE_SHIFT 6
7051 #else
7052 -#define L1_CACHE_BYTES 32
7053 #define L1_CACHE_SHIFT 5
7054 #endif
7055
7056 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7057 +
7058 #ifndef __ASSEMBLY__
7059
7060 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7061 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7062 index ad2b503..bdf1651 100644
7063 --- a/arch/parisc/include/asm/elf.h
7064 +++ b/arch/parisc/include/asm/elf.h
7065 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7066
7067 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7068
7069 +#ifdef CONFIG_PAX_ASLR
7070 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7071 +
7072 +#define PAX_DELTA_MMAP_LEN 16
7073 +#define PAX_DELTA_STACK_LEN 16
7074 +#endif
7075 +
7076 /* This yields a mask that user programs can use to figure out what
7077 instruction set this CPU supports. This could be done in user space,
7078 but it's not easy, and we've already done it here. */
7079 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7080 index fc987a1..6e068ef 100644
7081 --- a/arch/parisc/include/asm/pgalloc.h
7082 +++ b/arch/parisc/include/asm/pgalloc.h
7083 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7084 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7085 }
7086
7087 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7088 +{
7089 + pgd_populate(mm, pgd, pmd);
7090 +}
7091 +
7092 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7093 {
7094 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7095 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7096 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7097 #define pmd_free(mm, x) do { } while (0)
7098 #define pgd_populate(mm, pmd, pte) BUG()
7099 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7100
7101 #endif
7102
7103 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7104 index 34899b5..02dd060 100644
7105 --- a/arch/parisc/include/asm/pgtable.h
7106 +++ b/arch/parisc/include/asm/pgtable.h
7107 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7108 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7109 #define PAGE_COPY PAGE_EXECREAD
7110 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7111 +
7112 +#ifdef CONFIG_PAX_PAGEEXEC
7113 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7114 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7115 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7116 +#else
7117 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7118 +# define PAGE_COPY_NOEXEC PAGE_COPY
7119 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7120 +#endif
7121 +
7122 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7123 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7124 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7125 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7126 index e0a8235..ce2f1e1 100644
7127 --- a/arch/parisc/include/asm/uaccess.h
7128 +++ b/arch/parisc/include/asm/uaccess.h
7129 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7130 const void __user *from,
7131 unsigned long n)
7132 {
7133 - int sz = __compiletime_object_size(to);
7134 + size_t sz = __compiletime_object_size(to);
7135 int ret = -EFAULT;
7136
7137 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7138 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7139 ret = __copy_from_user(to, from, n);
7140 else
7141 copy_from_user_overflow();
7142 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7143 index 2a625fb..9908930 100644
7144 --- a/arch/parisc/kernel/module.c
7145 +++ b/arch/parisc/kernel/module.c
7146 @@ -98,16 +98,38 @@
7147
7148 /* three functions to determine where in the module core
7149 * or init pieces the location is */
7150 +static inline int in_init_rx(struct module *me, void *loc)
7151 +{
7152 + return (loc >= me->module_init_rx &&
7153 + loc < (me->module_init_rx + me->init_size_rx));
7154 +}
7155 +
7156 +static inline int in_init_rw(struct module *me, void *loc)
7157 +{
7158 + return (loc >= me->module_init_rw &&
7159 + loc < (me->module_init_rw + me->init_size_rw));
7160 +}
7161 +
7162 static inline int in_init(struct module *me, void *loc)
7163 {
7164 - return (loc >= me->module_init &&
7165 - loc <= (me->module_init + me->init_size));
7166 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7167 +}
7168 +
7169 +static inline int in_core_rx(struct module *me, void *loc)
7170 +{
7171 + return (loc >= me->module_core_rx &&
7172 + loc < (me->module_core_rx + me->core_size_rx));
7173 +}
7174 +
7175 +static inline int in_core_rw(struct module *me, void *loc)
7176 +{
7177 + return (loc >= me->module_core_rw &&
7178 + loc < (me->module_core_rw + me->core_size_rw));
7179 }
7180
7181 static inline int in_core(struct module *me, void *loc)
7182 {
7183 - return (loc >= me->module_core &&
7184 - loc <= (me->module_core + me->core_size));
7185 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7186 }
7187
7188 static inline int in_local(struct module *me, void *loc)
7189 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7190 }
7191
7192 /* align things a bit */
7193 - me->core_size = ALIGN(me->core_size, 16);
7194 - me->arch.got_offset = me->core_size;
7195 - me->core_size += gots * sizeof(struct got_entry);
7196 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7197 + me->arch.got_offset = me->core_size_rw;
7198 + me->core_size_rw += gots * sizeof(struct got_entry);
7199
7200 - me->core_size = ALIGN(me->core_size, 16);
7201 - me->arch.fdesc_offset = me->core_size;
7202 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7203 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7204 + me->arch.fdesc_offset = me->core_size_rw;
7205 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7206
7207 me->arch.got_max = gots;
7208 me->arch.fdesc_max = fdescs;
7209 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7210
7211 BUG_ON(value == 0);
7212
7213 - got = me->module_core + me->arch.got_offset;
7214 + got = me->module_core_rw + me->arch.got_offset;
7215 for (i = 0; got[i].addr; i++)
7216 if (got[i].addr == value)
7217 goto out;
7218 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7219 #ifdef CONFIG_64BIT
7220 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7221 {
7222 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7223 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7224
7225 if (!value) {
7226 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7227 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7228
7229 /* Create new one */
7230 fdesc->addr = value;
7231 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7232 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7233 return (Elf_Addr)fdesc;
7234 }
7235 #endif /* CONFIG_64BIT */
7236 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7237
7238 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7239 end = table + sechdrs[me->arch.unwind_section].sh_size;
7240 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7241 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7242
7243 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7244 me->arch.unwind_section, table, end, gp);
7245 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7246 index 5dfd248..64914ac 100644
7247 --- a/arch/parisc/kernel/sys_parisc.c
7248 +++ b/arch/parisc/kernel/sys_parisc.c
7249 @@ -33,9 +33,11 @@
7250 #include <linux/utsname.h>
7251 #include <linux/personality.h>
7252
7253 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7254 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7255 + unsigned long flags)
7256 {
7257 struct vm_unmapped_area_info info;
7258 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7259
7260 info.flags = 0;
7261 info.length = len;
7262 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7263 info.high_limit = TASK_SIZE;
7264 info.align_mask = 0;
7265 info.align_offset = 0;
7266 + info.threadstack_offset = offset;
7267 return vm_unmapped_area(&info);
7268 }
7269
7270 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7271 return (unsigned long) mapping >> 8;
7272 }
7273
7274 -static unsigned long get_shared_area(struct address_space *mapping,
7275 - unsigned long addr, unsigned long len, unsigned long pgoff)
7276 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7277 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7278 {
7279 struct vm_unmapped_area_info info;
7280 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7281
7282 info.flags = 0;
7283 info.length = len;
7284 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7285 info.high_limit = TASK_SIZE;
7286 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7287 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7288 + info.threadstack_offset = offset;
7289 return vm_unmapped_area(&info);
7290 }
7291
7292 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7293 return -EINVAL;
7294 return addr;
7295 }
7296 - if (!addr)
7297 + if (!addr) {
7298 addr = TASK_UNMAPPED_BASE;
7299
7300 +#ifdef CONFIG_PAX_RANDMMAP
7301 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7302 + addr += current->mm->delta_mmap;
7303 +#endif
7304 +
7305 + }
7306 +
7307 if (filp) {
7308 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7309 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7310 } else if(flags & MAP_SHARED) {
7311 - addr = get_shared_area(NULL, addr, len, pgoff);
7312 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7313 } else {
7314 - addr = get_unshared_area(addr, len);
7315 + addr = get_unshared_area(filp, addr, len, flags);
7316 }
7317 return addr;
7318 }
7319 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7320 index 04e47c6..7a8faf6 100644
7321 --- a/arch/parisc/kernel/traps.c
7322 +++ b/arch/parisc/kernel/traps.c
7323 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7324
7325 down_read(&current->mm->mmap_sem);
7326 vma = find_vma(current->mm,regs->iaoq[0]);
7327 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7328 - && (vma->vm_flags & VM_EXEC)) {
7329 -
7330 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7331 fault_address = regs->iaoq[0];
7332 fault_space = regs->iasq[0];
7333
7334 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7335 index f247a34..dc0f219 100644
7336 --- a/arch/parisc/mm/fault.c
7337 +++ b/arch/parisc/mm/fault.c
7338 @@ -15,6 +15,7 @@
7339 #include <linux/sched.h>
7340 #include <linux/interrupt.h>
7341 #include <linux/module.h>
7342 +#include <linux/unistd.h>
7343
7344 #include <asm/uaccess.h>
7345 #include <asm/traps.h>
7346 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7347 static unsigned long
7348 parisc_acctyp(unsigned long code, unsigned int inst)
7349 {
7350 - if (code == 6 || code == 16)
7351 + if (code == 6 || code == 7 || code == 16)
7352 return VM_EXEC;
7353
7354 switch (inst & 0xf0000000) {
7355 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7356 }
7357 #endif
7358
7359 +#ifdef CONFIG_PAX_PAGEEXEC
7360 +/*
7361 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7362 + *
7363 + * returns 1 when task should be killed
7364 + * 2 when rt_sigreturn trampoline was detected
7365 + * 3 when unpatched PLT trampoline was detected
7366 + */
7367 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7368 +{
7369 +
7370 +#ifdef CONFIG_PAX_EMUPLT
7371 + int err;
7372 +
7373 + do { /* PaX: unpatched PLT emulation */
7374 + unsigned int bl, depwi;
7375 +
7376 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7377 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7378 +
7379 + if (err)
7380 + break;
7381 +
7382 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7383 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7384 +
7385 + err = get_user(ldw, (unsigned int *)addr);
7386 + err |= get_user(bv, (unsigned int *)(addr+4));
7387 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7388 +
7389 + if (err)
7390 + break;
7391 +
7392 + if (ldw == 0x0E801096U &&
7393 + bv == 0xEAC0C000U &&
7394 + ldw2 == 0x0E881095U)
7395 + {
7396 + unsigned int resolver, map;
7397 +
7398 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7399 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7400 + if (err)
7401 + break;
7402 +
7403 + regs->gr[20] = instruction_pointer(regs)+8;
7404 + regs->gr[21] = map;
7405 + regs->gr[22] = resolver;
7406 + regs->iaoq[0] = resolver | 3UL;
7407 + regs->iaoq[1] = regs->iaoq[0] + 4;
7408 + return 3;
7409 + }
7410 + }
7411 + } while (0);
7412 +#endif
7413 +
7414 +#ifdef CONFIG_PAX_EMUTRAMP
7415 +
7416 +#ifndef CONFIG_PAX_EMUSIGRT
7417 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7418 + return 1;
7419 +#endif
7420 +
7421 + do { /* PaX: rt_sigreturn emulation */
7422 + unsigned int ldi1, ldi2, bel, nop;
7423 +
7424 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7425 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7426 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7427 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7428 +
7429 + if (err)
7430 + break;
7431 +
7432 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7433 + ldi2 == 0x3414015AU &&
7434 + bel == 0xE4008200U &&
7435 + nop == 0x08000240U)
7436 + {
7437 + regs->gr[25] = (ldi1 & 2) >> 1;
7438 + regs->gr[20] = __NR_rt_sigreturn;
7439 + regs->gr[31] = regs->iaoq[1] + 16;
7440 + regs->sr[0] = regs->iasq[1];
7441 + regs->iaoq[0] = 0x100UL;
7442 + regs->iaoq[1] = regs->iaoq[0] + 4;
7443 + regs->iasq[0] = regs->sr[2];
7444 + regs->iasq[1] = regs->sr[2];
7445 + return 2;
7446 + }
7447 + } while (0);
7448 +#endif
7449 +
7450 + return 1;
7451 +}
7452 +
7453 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7454 +{
7455 + unsigned long i;
7456 +
7457 + printk(KERN_ERR "PAX: bytes at PC: ");
7458 + for (i = 0; i < 5; i++) {
7459 + unsigned int c;
7460 + if (get_user(c, (unsigned int *)pc+i))
7461 + printk(KERN_CONT "???????? ");
7462 + else
7463 + printk(KERN_CONT "%08x ", c);
7464 + }
7465 + printk("\n");
7466 +}
7467 +#endif
7468 +
7469 int fixup_exception(struct pt_regs *regs)
7470 {
7471 const struct exception_table_entry *fix;
7472 @@ -194,8 +305,33 @@ good_area:
7473
7474 acc_type = parisc_acctyp(code,regs->iir);
7475
7476 - if ((vma->vm_flags & acc_type) != acc_type)
7477 + if ((vma->vm_flags & acc_type) != acc_type) {
7478 +
7479 +#ifdef CONFIG_PAX_PAGEEXEC
7480 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7481 + (address & ~3UL) == instruction_pointer(regs))
7482 + {
7483 + up_read(&mm->mmap_sem);
7484 + switch (pax_handle_fetch_fault(regs)) {
7485 +
7486 +#ifdef CONFIG_PAX_EMUPLT
7487 + case 3:
7488 + return;
7489 +#endif
7490 +
7491 +#ifdef CONFIG_PAX_EMUTRAMP
7492 + case 2:
7493 + return;
7494 +#endif
7495 +
7496 + }
7497 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7498 + do_group_exit(SIGKILL);
7499 + }
7500 +#endif
7501 +
7502 goto bad_area;
7503 + }
7504
7505 /*
7506 * If for any reason at all we couldn't handle the fault, make
7507 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7508 index e3b1d41..8e81edf 100644
7509 --- a/arch/powerpc/include/asm/atomic.h
7510 +++ b/arch/powerpc/include/asm/atomic.h
7511 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7512 return t1;
7513 }
7514
7515 +#define atomic64_read_unchecked(v) atomic64_read(v)
7516 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7517 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7518 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7519 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7520 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7521 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7522 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7523 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7524 +
7525 #endif /* __powerpc64__ */
7526
7527 #endif /* __KERNEL__ */
7528 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7529 index 9e495c9..b6878e5 100644
7530 --- a/arch/powerpc/include/asm/cache.h
7531 +++ b/arch/powerpc/include/asm/cache.h
7532 @@ -3,6 +3,7 @@
7533
7534 #ifdef __KERNEL__
7535
7536 +#include <linux/const.h>
7537
7538 /* bytes per L1 cache line */
7539 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7540 @@ -22,7 +23,7 @@
7541 #define L1_CACHE_SHIFT 7
7542 #endif
7543
7544 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7545 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7546
7547 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7548
7549 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7550 index cc0655a..13eac2e 100644
7551 --- a/arch/powerpc/include/asm/elf.h
7552 +++ b/arch/powerpc/include/asm/elf.h
7553 @@ -28,8 +28,19 @@
7554 the loader. We need to make sure that it is out of the way of the program
7555 that it will "exec", and that there is sufficient room for the brk. */
7556
7557 -extern unsigned long randomize_et_dyn(unsigned long base);
7558 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7559 +#define ELF_ET_DYN_BASE (0x20000000)
7560 +
7561 +#ifdef CONFIG_PAX_ASLR
7562 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7563 +
7564 +#ifdef __powerpc64__
7565 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7566 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7567 +#else
7568 +#define PAX_DELTA_MMAP_LEN 15
7569 +#define PAX_DELTA_STACK_LEN 15
7570 +#endif
7571 +#endif
7572
7573 /*
7574 * Our registers are always unsigned longs, whether we're a 32 bit
7575 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7576 (0x7ff >> (PAGE_SHIFT - 12)) : \
7577 (0x3ffff >> (PAGE_SHIFT - 12)))
7578
7579 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7580 -#define arch_randomize_brk arch_randomize_brk
7581 -
7582 -
7583 #ifdef CONFIG_SPU_BASE
7584 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7585 #define NT_SPU 1
7586 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7587 index 8196e9c..d83a9f3 100644
7588 --- a/arch/powerpc/include/asm/exec.h
7589 +++ b/arch/powerpc/include/asm/exec.h
7590 @@ -4,6 +4,6 @@
7591 #ifndef _ASM_POWERPC_EXEC_H
7592 #define _ASM_POWERPC_EXEC_H
7593
7594 -extern unsigned long arch_align_stack(unsigned long sp);
7595 +#define arch_align_stack(x) ((x) & ~0xfUL)
7596
7597 #endif /* _ASM_POWERPC_EXEC_H */
7598 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7599 index 5acabbd..7ea14fa 100644
7600 --- a/arch/powerpc/include/asm/kmap_types.h
7601 +++ b/arch/powerpc/include/asm/kmap_types.h
7602 @@ -10,7 +10,7 @@
7603 * 2 of the License, or (at your option) any later version.
7604 */
7605
7606 -#define KM_TYPE_NR 16
7607 +#define KM_TYPE_NR 17
7608
7609 #endif /* __KERNEL__ */
7610 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7611 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7612 index 8565c25..2865190 100644
7613 --- a/arch/powerpc/include/asm/mman.h
7614 +++ b/arch/powerpc/include/asm/mman.h
7615 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7616 }
7617 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7618
7619 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7620 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7621 {
7622 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7623 }
7624 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7625 index b9f4262..dcf04f7 100644
7626 --- a/arch/powerpc/include/asm/page.h
7627 +++ b/arch/powerpc/include/asm/page.h
7628 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7629 * and needs to be executable. This means the whole heap ends
7630 * up being executable.
7631 */
7632 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7633 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7634 +#define VM_DATA_DEFAULT_FLAGS32 \
7635 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7636 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7637
7638 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7639 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7640 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7641 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7642 #endif
7643
7644 +#define ktla_ktva(addr) (addr)
7645 +#define ktva_ktla(addr) (addr)
7646 +
7647 #ifndef CONFIG_PPC_BOOK3S_64
7648 /*
7649 * Use the top bit of the higher-level page table entries to indicate whether
7650 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7651 index 88693ce..ac6f9ab 100644
7652 --- a/arch/powerpc/include/asm/page_64.h
7653 +++ b/arch/powerpc/include/asm/page_64.h
7654 @@ -153,15 +153,18 @@ do { \
7655 * stack by default, so in the absence of a PT_GNU_STACK program header
7656 * we turn execute permission off.
7657 */
7658 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7659 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7660 +#define VM_STACK_DEFAULT_FLAGS32 \
7661 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7662 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7663
7664 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7665 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7666
7667 +#ifndef CONFIG_PAX_PAGEEXEC
7668 #define VM_STACK_DEFAULT_FLAGS \
7669 (is_32bit_task() ? \
7670 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7671 +#endif
7672
7673 #include <asm-generic/getorder.h>
7674
7675 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7676 index f65e27b..23ffb5b 100644
7677 --- a/arch/powerpc/include/asm/pgalloc-64.h
7678 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7679 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7680 #ifndef CONFIG_PPC_64K_PAGES
7681
7682 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7683 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7684
7685 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7686 {
7687 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7688 pud_set(pud, (unsigned long)pmd);
7689 }
7690
7691 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7692 +{
7693 + pud_populate(mm, pud, pmd);
7694 +}
7695 +
7696 #define pmd_populate(mm, pmd, pte_page) \
7697 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7698 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7699 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7700 #endif
7701
7702 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7703 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7704
7705 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7706 pte_t *pte)
7707 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7708 index 7d6eacf..14c0240 100644
7709 --- a/arch/powerpc/include/asm/pgtable.h
7710 +++ b/arch/powerpc/include/asm/pgtable.h
7711 @@ -2,6 +2,7 @@
7712 #define _ASM_POWERPC_PGTABLE_H
7713 #ifdef __KERNEL__
7714
7715 +#include <linux/const.h>
7716 #ifndef __ASSEMBLY__
7717 #include <asm/processor.h> /* For TASK_SIZE */
7718 #include <asm/mmu.h>
7719 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7720 index 4aad413..85d86bf 100644
7721 --- a/arch/powerpc/include/asm/pte-hash32.h
7722 +++ b/arch/powerpc/include/asm/pte-hash32.h
7723 @@ -21,6 +21,7 @@
7724 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7725 #define _PAGE_USER 0x004 /* usermode access allowed */
7726 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7727 +#define _PAGE_EXEC _PAGE_GUARDED
7728 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7729 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7730 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7731 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7732 index 99222e2..f629aef 100644
7733 --- a/arch/powerpc/include/asm/reg.h
7734 +++ b/arch/powerpc/include/asm/reg.h
7735 @@ -234,6 +234,7 @@
7736 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7737 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7738 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7739 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7740 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7741 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7742 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7743 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7744 index 48cfc85..891382f 100644
7745 --- a/arch/powerpc/include/asm/smp.h
7746 +++ b/arch/powerpc/include/asm/smp.h
7747 @@ -50,7 +50,7 @@ struct smp_ops_t {
7748 int (*cpu_disable)(void);
7749 void (*cpu_die)(unsigned int nr);
7750 int (*cpu_bootable)(unsigned int nr);
7751 -};
7752 +} __no_const;
7753
7754 extern void smp_send_debugger_break(void);
7755 extern void start_secondary_resume(void);
7756 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7757 index ba7b197..d292e26 100644
7758 --- a/arch/powerpc/include/asm/thread_info.h
7759 +++ b/arch/powerpc/include/asm/thread_info.h
7760 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7761 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7762 TIF_NEED_RESCHED */
7763 #define TIF_32BIT 4 /* 32 bit binary */
7764 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7765 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7766 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7767 #define TIF_SINGLESTEP 8 /* singlestepping active */
7768 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7769 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7770 for stack store? */
7771 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7772 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7773 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7774 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7775
7776 /* as above, but as bit values */
7777 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7778 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7779 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7780 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7781 #define _TIF_NOHZ (1<<TIF_NOHZ)
7782 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7783 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7784 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7785 - _TIF_NOHZ)
7786 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7787
7788 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7789 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7790 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7791 index 9485b43..4718d50 100644
7792 --- a/arch/powerpc/include/asm/uaccess.h
7793 +++ b/arch/powerpc/include/asm/uaccess.h
7794 @@ -318,52 +318,6 @@ do { \
7795 extern unsigned long __copy_tofrom_user(void __user *to,
7796 const void __user *from, unsigned long size);
7797
7798 -#ifndef __powerpc64__
7799 -
7800 -static inline unsigned long copy_from_user(void *to,
7801 - const void __user *from, unsigned long n)
7802 -{
7803 - unsigned long over;
7804 -
7805 - if (access_ok(VERIFY_READ, from, n))
7806 - return __copy_tofrom_user((__force void __user *)to, from, n);
7807 - if ((unsigned long)from < TASK_SIZE) {
7808 - over = (unsigned long)from + n - TASK_SIZE;
7809 - return __copy_tofrom_user((__force void __user *)to, from,
7810 - n - over) + over;
7811 - }
7812 - return n;
7813 -}
7814 -
7815 -static inline unsigned long copy_to_user(void __user *to,
7816 - const void *from, unsigned long n)
7817 -{
7818 - unsigned long over;
7819 -
7820 - if (access_ok(VERIFY_WRITE, to, n))
7821 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7822 - if ((unsigned long)to < TASK_SIZE) {
7823 - over = (unsigned long)to + n - TASK_SIZE;
7824 - return __copy_tofrom_user(to, (__force void __user *)from,
7825 - n - over) + over;
7826 - }
7827 - return n;
7828 -}
7829 -
7830 -#else /* __powerpc64__ */
7831 -
7832 -#define __copy_in_user(to, from, size) \
7833 - __copy_tofrom_user((to), (from), (size))
7834 -
7835 -extern unsigned long copy_from_user(void *to, const void __user *from,
7836 - unsigned long n);
7837 -extern unsigned long copy_to_user(void __user *to, const void *from,
7838 - unsigned long n);
7839 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7840 - unsigned long n);
7841 -
7842 -#endif /* __powerpc64__ */
7843 -
7844 static inline unsigned long __copy_from_user_inatomic(void *to,
7845 const void __user *from, unsigned long n)
7846 {
7847 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7848 if (ret == 0)
7849 return 0;
7850 }
7851 +
7852 + if (!__builtin_constant_p(n))
7853 + check_object_size(to, n, false);
7854 +
7855 return __copy_tofrom_user((__force void __user *)to, from, n);
7856 }
7857
7858 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7859 if (ret == 0)
7860 return 0;
7861 }
7862 +
7863 + if (!__builtin_constant_p(n))
7864 + check_object_size(from, n, true);
7865 +
7866 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7867 }
7868
7869 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7870 return __copy_to_user_inatomic(to, from, size);
7871 }
7872
7873 +#ifndef __powerpc64__
7874 +
7875 +static inline unsigned long __must_check copy_from_user(void *to,
7876 + const void __user *from, unsigned long n)
7877 +{
7878 + unsigned long over;
7879 +
7880 + if ((long)n < 0)
7881 + return n;
7882 +
7883 + if (access_ok(VERIFY_READ, from, n)) {
7884 + if (!__builtin_constant_p(n))
7885 + check_object_size(to, n, false);
7886 + return __copy_tofrom_user((__force void __user *)to, from, n);
7887 + }
7888 + if ((unsigned long)from < TASK_SIZE) {
7889 + over = (unsigned long)from + n - TASK_SIZE;
7890 + if (!__builtin_constant_p(n - over))
7891 + check_object_size(to, n - over, false);
7892 + return __copy_tofrom_user((__force void __user *)to, from,
7893 + n - over) + over;
7894 + }
7895 + return n;
7896 +}
7897 +
7898 +static inline unsigned long __must_check copy_to_user(void __user *to,
7899 + const void *from, unsigned long n)
7900 +{
7901 + unsigned long over;
7902 +
7903 + if ((long)n < 0)
7904 + return n;
7905 +
7906 + if (access_ok(VERIFY_WRITE, to, n)) {
7907 + if (!__builtin_constant_p(n))
7908 + check_object_size(from, n, true);
7909 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7910 + }
7911 + if ((unsigned long)to < TASK_SIZE) {
7912 + over = (unsigned long)to + n - TASK_SIZE;
7913 + if (!__builtin_constant_p(n))
7914 + check_object_size(from, n - over, true);
7915 + return __copy_tofrom_user(to, (__force void __user *)from,
7916 + n - over) + over;
7917 + }
7918 + return n;
7919 +}
7920 +
7921 +#else /* __powerpc64__ */
7922 +
7923 +#define __copy_in_user(to, from, size) \
7924 + __copy_tofrom_user((to), (from), (size))
7925 +
7926 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7927 +{
7928 + if ((long)n < 0 || n > INT_MAX)
7929 + return n;
7930 +
7931 + if (!__builtin_constant_p(n))
7932 + check_object_size(to, n, false);
7933 +
7934 + if (likely(access_ok(VERIFY_READ, from, n)))
7935 + n = __copy_from_user(to, from, n);
7936 + else
7937 + memset(to, 0, n);
7938 + return n;
7939 +}
7940 +
7941 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7942 +{
7943 + if ((long)n < 0 || n > INT_MAX)
7944 + return n;
7945 +
7946 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7947 + if (!__builtin_constant_p(n))
7948 + check_object_size(from, n, true);
7949 + n = __copy_to_user(to, from, n);
7950 + }
7951 + return n;
7952 +}
7953 +
7954 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7955 + unsigned long n);
7956 +
7957 +#endif /* __powerpc64__ */
7958 +
7959 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7960
7961 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7962 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7963 index 645170a..6cf0271 100644
7964 --- a/arch/powerpc/kernel/exceptions-64e.S
7965 +++ b/arch/powerpc/kernel/exceptions-64e.S
7966 @@ -757,6 +757,7 @@ storage_fault_common:
7967 std r14,_DAR(r1)
7968 std r15,_DSISR(r1)
7969 addi r3,r1,STACK_FRAME_OVERHEAD
7970 + bl .save_nvgprs
7971 mr r4,r14
7972 mr r5,r15
7973 ld r14,PACA_EXGEN+EX_R14(r13)
7974 @@ -765,8 +766,7 @@ storage_fault_common:
7975 cmpdi r3,0
7976 bne- 1f
7977 b .ret_from_except_lite
7978 -1: bl .save_nvgprs
7979 - mr r5,r3
7980 +1: mr r5,r3
7981 addi r3,r1,STACK_FRAME_OVERHEAD
7982 ld r4,_DAR(r1)
7983 bl .bad_page_fault
7984 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7985 index 902ca3c..e942155 100644
7986 --- a/arch/powerpc/kernel/exceptions-64s.S
7987 +++ b/arch/powerpc/kernel/exceptions-64s.S
7988 @@ -1357,10 +1357,10 @@ handle_page_fault:
7989 11: ld r4,_DAR(r1)
7990 ld r5,_DSISR(r1)
7991 addi r3,r1,STACK_FRAME_OVERHEAD
7992 + bl .save_nvgprs
7993 bl .do_page_fault
7994 cmpdi r3,0
7995 beq+ 12f
7996 - bl .save_nvgprs
7997 mr r5,r3
7998 addi r3,r1,STACK_FRAME_OVERHEAD
7999 lwz r4,_DAR(r1)
8000 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8001 index 2e3200c..72095ce 100644
8002 --- a/arch/powerpc/kernel/module_32.c
8003 +++ b/arch/powerpc/kernel/module_32.c
8004 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8005 me->arch.core_plt_section = i;
8006 }
8007 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8008 - printk("Module doesn't contain .plt or .init.plt sections.\n");
8009 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
8010 return -ENOEXEC;
8011 }
8012
8013 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
8014
8015 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
8016 /* Init, or core PLT? */
8017 - if (location >= mod->module_core
8018 - && location < mod->module_core + mod->core_size)
8019 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
8020 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
8021 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
8022 - else
8023 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
8024 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
8025 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
8026 + else {
8027 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
8028 + return ~0UL;
8029 + }
8030
8031 /* Find this entry, or if that fails, the next avail. entry */
8032 while (entry->jump[0]) {
8033 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
8034 index 8083be2..10aa352 100644
8035 --- a/arch/powerpc/kernel/process.c
8036 +++ b/arch/powerpc/kernel/process.c
8037 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
8038 * Lookup NIP late so we have the best change of getting the
8039 * above info out without failing
8040 */
8041 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8042 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8043 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8044 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8045 #endif
8046 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8047 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8048 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8049 newsp = stack[0];
8050 ip = stack[STACK_FRAME_LR_SAVE];
8051 if (!firstframe || ip != lr) {
8052 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8053 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8054 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8055 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8056 - printk(" (%pS)",
8057 + printk(" (%pA)",
8058 (void *)current->ret_stack[curr_frame].ret);
8059 curr_frame--;
8060 }
8061 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8062 struct pt_regs *regs = (struct pt_regs *)
8063 (sp + STACK_FRAME_OVERHEAD);
8064 lr = regs->link;
8065 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8066 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8067 regs->trap, (void *)regs->nip, (void *)lr);
8068 firstframe = 1;
8069 }
8070 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
8071 mtspr(SPRN_CTRLT, ctrl);
8072 }
8073 #endif /* CONFIG_PPC64 */
8074 -
8075 -unsigned long arch_align_stack(unsigned long sp)
8076 -{
8077 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8078 - sp -= get_random_int() & ~PAGE_MASK;
8079 - return sp & ~0xf;
8080 -}
8081 -
8082 -static inline unsigned long brk_rnd(void)
8083 -{
8084 - unsigned long rnd = 0;
8085 -
8086 - /* 8MB for 32bit, 1GB for 64bit */
8087 - if (is_32bit_task())
8088 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8089 - else
8090 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8091 -
8092 - return rnd << PAGE_SHIFT;
8093 -}
8094 -
8095 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8096 -{
8097 - unsigned long base = mm->brk;
8098 - unsigned long ret;
8099 -
8100 -#ifdef CONFIG_PPC_STD_MMU_64
8101 - /*
8102 - * If we are using 1TB segments and we are allowed to randomise
8103 - * the heap, we can put it above 1TB so it is backed by a 1TB
8104 - * segment. Otherwise the heap will be in the bottom 1TB
8105 - * which always uses 256MB segments and this may result in a
8106 - * performance penalty.
8107 - */
8108 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8109 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8110 -#endif
8111 -
8112 - ret = PAGE_ALIGN(base + brk_rnd());
8113 -
8114 - if (ret < mm->brk)
8115 - return mm->brk;
8116 -
8117 - return ret;
8118 -}
8119 -
8120 -unsigned long randomize_et_dyn(unsigned long base)
8121 -{
8122 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8123 -
8124 - if (ret < base)
8125 - return base;
8126 -
8127 - return ret;
8128 -}
8129 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8130 index 9a0d24c..e7fbedf 100644
8131 --- a/arch/powerpc/kernel/ptrace.c
8132 +++ b/arch/powerpc/kernel/ptrace.c
8133 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8134 return ret;
8135 }
8136
8137 +#ifdef CONFIG_GRKERNSEC_SETXID
8138 +extern void gr_delayed_cred_worker(void);
8139 +#endif
8140 +
8141 /*
8142 * We must return the syscall number to actually look up in the table.
8143 * This can be -1L to skip running any syscall at all.
8144 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8145
8146 secure_computing_strict(regs->gpr[0]);
8147
8148 +#ifdef CONFIG_GRKERNSEC_SETXID
8149 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8150 + gr_delayed_cred_worker();
8151 +#endif
8152 +
8153 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8154 tracehook_report_syscall_entry(regs))
8155 /*
8156 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8157 {
8158 int step;
8159
8160 +#ifdef CONFIG_GRKERNSEC_SETXID
8161 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8162 + gr_delayed_cred_worker();
8163 +#endif
8164 +
8165 audit_syscall_exit(regs);
8166
8167 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8168 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8169 index 0f83122..c0aca6a 100644
8170 --- a/arch/powerpc/kernel/signal_32.c
8171 +++ b/arch/powerpc/kernel/signal_32.c
8172 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8173 /* Save user registers on the stack */
8174 frame = &rt_sf->uc.uc_mcontext;
8175 addr = frame;
8176 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8177 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8178 sigret = 0;
8179 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8180 } else {
8181 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8182 index 887e99d..310bc11 100644
8183 --- a/arch/powerpc/kernel/signal_64.c
8184 +++ b/arch/powerpc/kernel/signal_64.c
8185 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8186 #endif
8187
8188 /* Set up to return from userspace. */
8189 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8190 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8191 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8192 } else {
8193 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8194 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8195 index e435bc0..41c2964 100644
8196 --- a/arch/powerpc/kernel/traps.c
8197 +++ b/arch/powerpc/kernel/traps.c
8198 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8199 return flags;
8200 }
8201
8202 +extern void gr_handle_kernel_exploit(void);
8203 +
8204 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8205 int signr)
8206 {
8207 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8208 panic("Fatal exception in interrupt");
8209 if (panic_on_oops)
8210 panic("Fatal exception");
8211 +
8212 + gr_handle_kernel_exploit();
8213 +
8214 do_exit(signr);
8215 }
8216
8217 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8218 index 1d9c926..25f4741 100644
8219 --- a/arch/powerpc/kernel/vdso.c
8220 +++ b/arch/powerpc/kernel/vdso.c
8221 @@ -34,6 +34,7 @@
8222 #include <asm/firmware.h>
8223 #include <asm/vdso.h>
8224 #include <asm/vdso_datapage.h>
8225 +#include <asm/mman.h>
8226
8227 #include "setup.h"
8228
8229 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8230 vdso_base = VDSO32_MBASE;
8231 #endif
8232
8233 - current->mm->context.vdso_base = 0;
8234 + current->mm->context.vdso_base = ~0UL;
8235
8236 /* vDSO has a problem and was disabled, just don't "enable" it for the
8237 * process
8238 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8239 vdso_base = get_unmapped_area(NULL, vdso_base,
8240 (vdso_pages << PAGE_SHIFT) +
8241 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8242 - 0, 0);
8243 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8244 if (IS_ERR_VALUE(vdso_base)) {
8245 rc = vdso_base;
8246 goto fail_mmapsem;
8247 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8248 index 5eea6f3..5d10396 100644
8249 --- a/arch/powerpc/lib/usercopy_64.c
8250 +++ b/arch/powerpc/lib/usercopy_64.c
8251 @@ -9,22 +9,6 @@
8252 #include <linux/module.h>
8253 #include <asm/uaccess.h>
8254
8255 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8256 -{
8257 - if (likely(access_ok(VERIFY_READ, from, n)))
8258 - n = __copy_from_user(to, from, n);
8259 - else
8260 - memset(to, 0, n);
8261 - return n;
8262 -}
8263 -
8264 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8265 -{
8266 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8267 - n = __copy_to_user(to, from, n);
8268 - return n;
8269 -}
8270 -
8271 unsigned long copy_in_user(void __user *to, const void __user *from,
8272 unsigned long n)
8273 {
8274 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8275 return n;
8276 }
8277
8278 -EXPORT_SYMBOL(copy_from_user);
8279 -EXPORT_SYMBOL(copy_to_user);
8280 EXPORT_SYMBOL(copy_in_user);
8281
8282 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8283 index 8726779..a33c512 100644
8284 --- a/arch/powerpc/mm/fault.c
8285 +++ b/arch/powerpc/mm/fault.c
8286 @@ -33,6 +33,10 @@
8287 #include <linux/magic.h>
8288 #include <linux/ratelimit.h>
8289 #include <linux/context_tracking.h>
8290 +#include <linux/slab.h>
8291 +#include <linux/pagemap.h>
8292 +#include <linux/compiler.h>
8293 +#include <linux/unistd.h>
8294
8295 #include <asm/firmware.h>
8296 #include <asm/page.h>
8297 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8298 }
8299 #endif
8300
8301 +#ifdef CONFIG_PAX_PAGEEXEC
8302 +/*
8303 + * PaX: decide what to do with offenders (regs->nip = fault address)
8304 + *
8305 + * returns 1 when task should be killed
8306 + */
8307 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8308 +{
8309 + return 1;
8310 +}
8311 +
8312 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8313 +{
8314 + unsigned long i;
8315 +
8316 + printk(KERN_ERR "PAX: bytes at PC: ");
8317 + for (i = 0; i < 5; i++) {
8318 + unsigned int c;
8319 + if (get_user(c, (unsigned int __user *)pc+i))
8320 + printk(KERN_CONT "???????? ");
8321 + else
8322 + printk(KERN_CONT "%08x ", c);
8323 + }
8324 + printk("\n");
8325 +}
8326 +#endif
8327 +
8328 /*
8329 * Check whether the instruction at regs->nip is a store using
8330 * an update addressing form which will update r1.
8331 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8332 * indicate errors in DSISR but can validly be set in SRR1.
8333 */
8334 if (trap == 0x400)
8335 - error_code &= 0x48200000;
8336 + error_code &= 0x58200000;
8337 else
8338 is_write = error_code & DSISR_ISSTORE;
8339 #else
8340 @@ -371,7 +402,7 @@ good_area:
8341 * "undefined". Of those that can be set, this is the only
8342 * one which seems bad.
8343 */
8344 - if (error_code & 0x10000000)
8345 + if (error_code & DSISR_GUARDED)
8346 /* Guarded storage error. */
8347 goto bad_area;
8348 #endif /* CONFIG_8xx */
8349 @@ -386,7 +417,7 @@ good_area:
8350 * processors use the same I/D cache coherency mechanism
8351 * as embedded.
8352 */
8353 - if (error_code & DSISR_PROTFAULT)
8354 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8355 goto bad_area;
8356 #endif /* CONFIG_PPC_STD_MMU */
8357
8358 @@ -471,6 +502,23 @@ bad_area:
8359 bad_area_nosemaphore:
8360 /* User mode accesses cause a SIGSEGV */
8361 if (user_mode(regs)) {
8362 +
8363 +#ifdef CONFIG_PAX_PAGEEXEC
8364 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8365 +#ifdef CONFIG_PPC_STD_MMU
8366 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8367 +#else
8368 + if (is_exec && regs->nip == address) {
8369 +#endif
8370 + switch (pax_handle_fetch_fault(regs)) {
8371 + }
8372 +
8373 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8374 + do_group_exit(SIGKILL);
8375 + }
8376 + }
8377 +#endif
8378 +
8379 _exception(SIGSEGV, regs, code, address);
8380 goto bail;
8381 }
8382 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8383 index cb8bdbe..d770680 100644
8384 --- a/arch/powerpc/mm/mmap.c
8385 +++ b/arch/powerpc/mm/mmap.c
8386 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8387 {
8388 unsigned long rnd = 0;
8389
8390 +#ifdef CONFIG_PAX_RANDMMAP
8391 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8392 +#endif
8393 +
8394 if (current->flags & PF_RANDOMIZE) {
8395 /* 8MB for 32bit, 1GB for 64bit */
8396 if (is_32bit_task())
8397 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8398 */
8399 if (mmap_is_legacy()) {
8400 mm->mmap_base = TASK_UNMAPPED_BASE;
8401 +
8402 +#ifdef CONFIG_PAX_RANDMMAP
8403 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8404 + mm->mmap_base += mm->delta_mmap;
8405 +#endif
8406 +
8407 mm->get_unmapped_area = arch_get_unmapped_area;
8408 } else {
8409 mm->mmap_base = mmap_base();
8410 +
8411 +#ifdef CONFIG_PAX_RANDMMAP
8412 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8413 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8414 +#endif
8415 +
8416 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8417 }
8418 }
8419 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8420 index 3e99c14..f00953c 100644
8421 --- a/arch/powerpc/mm/slice.c
8422 +++ b/arch/powerpc/mm/slice.c
8423 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8424 if ((mm->task_size - len) < addr)
8425 return 0;
8426 vma = find_vma(mm, addr);
8427 - return (!vma || (addr + len) <= vma->vm_start);
8428 + return check_heap_stack_gap(vma, addr, len, 0);
8429 }
8430
8431 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8432 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8433 info.align_offset = 0;
8434
8435 addr = TASK_UNMAPPED_BASE;
8436 +
8437 +#ifdef CONFIG_PAX_RANDMMAP
8438 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8439 + addr += mm->delta_mmap;
8440 +#endif
8441 +
8442 while (addr < TASK_SIZE) {
8443 info.low_limit = addr;
8444 if (!slice_scan_available(addr, available, 1, &addr))
8445 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8446 if (fixed && addr > (mm->task_size - len))
8447 return -EINVAL;
8448
8449 +#ifdef CONFIG_PAX_RANDMMAP
8450 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8451 + addr = 0;
8452 +#endif
8453 +
8454 /* If hint, make sure it matches our alignment restrictions */
8455 if (!fixed && addr) {
8456 addr = _ALIGN_UP(addr, 1ul << pshift);
8457 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8458 index 9098692..3d54cd1 100644
8459 --- a/arch/powerpc/platforms/cell/spufs/file.c
8460 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8461 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8462 return VM_FAULT_NOPAGE;
8463 }
8464
8465 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8466 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8467 unsigned long address,
8468 - void *buf, int len, int write)
8469 + void *buf, size_t len, int write)
8470 {
8471 struct spu_context *ctx = vma->vm_file->private_data;
8472 unsigned long offset = address - vma->vm_start;
8473 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8474 index c797832..ce575c8 100644
8475 --- a/arch/s390/include/asm/atomic.h
8476 +++ b/arch/s390/include/asm/atomic.h
8477 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8478 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8479 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8480
8481 +#define atomic64_read_unchecked(v) atomic64_read(v)
8482 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8483 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8484 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8485 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8486 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8487 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8488 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8489 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8490 +
8491 #define smp_mb__before_atomic_dec() smp_mb()
8492 #define smp_mb__after_atomic_dec() smp_mb()
8493 #define smp_mb__before_atomic_inc() smp_mb()
8494 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8495 index 4d7ccac..d03d0ad 100644
8496 --- a/arch/s390/include/asm/cache.h
8497 +++ b/arch/s390/include/asm/cache.h
8498 @@ -9,8 +9,10 @@
8499 #ifndef __ARCH_S390_CACHE_H
8500 #define __ARCH_S390_CACHE_H
8501
8502 -#define L1_CACHE_BYTES 256
8503 +#include <linux/const.h>
8504 +
8505 #define L1_CACHE_SHIFT 8
8506 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8507 #define NET_SKB_PAD 32
8508
8509 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8510 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8511 index 78f4f87..598ce39 100644
8512 --- a/arch/s390/include/asm/elf.h
8513 +++ b/arch/s390/include/asm/elf.h
8514 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8515 the loader. We need to make sure that it is out of the way of the program
8516 that it will "exec", and that there is sufficient room for the brk. */
8517
8518 -extern unsigned long randomize_et_dyn(unsigned long base);
8519 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8520 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8521 +
8522 +#ifdef CONFIG_PAX_ASLR
8523 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8524 +
8525 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8526 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8527 +#endif
8528
8529 /* This yields a mask that user programs can use to figure out what
8530 instruction set this CPU supports. */
8531 @@ -222,9 +228,6 @@ struct linux_binprm;
8532 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8533 int arch_setup_additional_pages(struct linux_binprm *, int);
8534
8535 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8536 -#define arch_randomize_brk arch_randomize_brk
8537 -
8538 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8539
8540 #endif
8541 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8542 index c4a93d6..4d2a9b4 100644
8543 --- a/arch/s390/include/asm/exec.h
8544 +++ b/arch/s390/include/asm/exec.h
8545 @@ -7,6 +7,6 @@
8546 #ifndef __ASM_EXEC_H
8547 #define __ASM_EXEC_H
8548
8549 -extern unsigned long arch_align_stack(unsigned long sp);
8550 +#define arch_align_stack(x) ((x) & ~0xfUL)
8551
8552 #endif /* __ASM_EXEC_H */
8553 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8554 index 9c33ed4..e40cbef 100644
8555 --- a/arch/s390/include/asm/uaccess.h
8556 +++ b/arch/s390/include/asm/uaccess.h
8557 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8558 copy_to_user(void __user *to, const void *from, unsigned long n)
8559 {
8560 might_fault();
8561 +
8562 + if ((long)n < 0)
8563 + return n;
8564 +
8565 return __copy_to_user(to, from, n);
8566 }
8567
8568 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8569 static inline unsigned long __must_check
8570 __copy_from_user(void *to, const void __user *from, unsigned long n)
8571 {
8572 + if ((long)n < 0)
8573 + return n;
8574 +
8575 if (__builtin_constant_p(n) && (n <= 256))
8576 return uaccess.copy_from_user_small(n, from, to);
8577 else
8578 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8579 static inline unsigned long __must_check
8580 copy_from_user(void *to, const void __user *from, unsigned long n)
8581 {
8582 - unsigned int sz = __compiletime_object_size(to);
8583 + size_t sz = __compiletime_object_size(to);
8584
8585 might_fault();
8586 - if (unlikely(sz != -1 && sz < n)) {
8587 +
8588 + if ((long)n < 0)
8589 + return n;
8590 +
8591 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8592 copy_from_user_overflow();
8593 return n;
8594 }
8595 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8596 index 7845e15..59c4353 100644
8597 --- a/arch/s390/kernel/module.c
8598 +++ b/arch/s390/kernel/module.c
8599 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8600
8601 /* Increase core size by size of got & plt and set start
8602 offsets for got and plt. */
8603 - me->core_size = ALIGN(me->core_size, 4);
8604 - me->arch.got_offset = me->core_size;
8605 - me->core_size += me->arch.got_size;
8606 - me->arch.plt_offset = me->core_size;
8607 - me->core_size += me->arch.plt_size;
8608 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8609 + me->arch.got_offset = me->core_size_rw;
8610 + me->core_size_rw += me->arch.got_size;
8611 + me->arch.plt_offset = me->core_size_rx;
8612 + me->core_size_rx += me->arch.plt_size;
8613 return 0;
8614 }
8615
8616 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8617 if (info->got_initialized == 0) {
8618 Elf_Addr *gotent;
8619
8620 - gotent = me->module_core + me->arch.got_offset +
8621 + gotent = me->module_core_rw + me->arch.got_offset +
8622 info->got_offset;
8623 *gotent = val;
8624 info->got_initialized = 1;
8625 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8626 rc = apply_rela_bits(loc, val, 0, 64, 0);
8627 else if (r_type == R_390_GOTENT ||
8628 r_type == R_390_GOTPLTENT) {
8629 - val += (Elf_Addr) me->module_core - loc;
8630 + val += (Elf_Addr) me->module_core_rw - loc;
8631 rc = apply_rela_bits(loc, val, 1, 32, 1);
8632 }
8633 break;
8634 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8635 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8636 if (info->plt_initialized == 0) {
8637 unsigned int *ip;
8638 - ip = me->module_core + me->arch.plt_offset +
8639 + ip = me->module_core_rx + me->arch.plt_offset +
8640 info->plt_offset;
8641 #ifndef CONFIG_64BIT
8642 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8643 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8644 val - loc + 0xffffUL < 0x1ffffeUL) ||
8645 (r_type == R_390_PLT32DBL &&
8646 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8647 - val = (Elf_Addr) me->module_core +
8648 + val = (Elf_Addr) me->module_core_rx +
8649 me->arch.plt_offset +
8650 info->plt_offset;
8651 val += rela->r_addend - loc;
8652 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8653 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8654 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8655 val = val + rela->r_addend -
8656 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8657 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8658 if (r_type == R_390_GOTOFF16)
8659 rc = apply_rela_bits(loc, val, 0, 16, 0);
8660 else if (r_type == R_390_GOTOFF32)
8661 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8662 break;
8663 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8664 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8665 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8666 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8667 rela->r_addend - loc;
8668 if (r_type == R_390_GOTPC)
8669 rc = apply_rela_bits(loc, val, 1, 32, 0);
8670 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8671 index 2bc3edd..ab9d598 100644
8672 --- a/arch/s390/kernel/process.c
8673 +++ b/arch/s390/kernel/process.c
8674 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8675 }
8676 return 0;
8677 }
8678 -
8679 -unsigned long arch_align_stack(unsigned long sp)
8680 -{
8681 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8682 - sp -= get_random_int() & ~PAGE_MASK;
8683 - return sp & ~0xf;
8684 -}
8685 -
8686 -static inline unsigned long brk_rnd(void)
8687 -{
8688 - /* 8MB for 32bit, 1GB for 64bit */
8689 - if (is_32bit_task())
8690 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8691 - else
8692 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8693 -}
8694 -
8695 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8696 -{
8697 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8698 -
8699 - if (ret < mm->brk)
8700 - return mm->brk;
8701 - return ret;
8702 -}
8703 -
8704 -unsigned long randomize_et_dyn(unsigned long base)
8705 -{
8706 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8707 -
8708 - if (!(current->flags & PF_RANDOMIZE))
8709 - return base;
8710 - if (ret < base)
8711 - return base;
8712 - return ret;
8713 -}
8714 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8715 index 4002329..99b67cb 100644
8716 --- a/arch/s390/mm/mmap.c
8717 +++ b/arch/s390/mm/mmap.c
8718 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8719 */
8720 if (mmap_is_legacy()) {
8721 mm->mmap_base = TASK_UNMAPPED_BASE;
8722 +
8723 +#ifdef CONFIG_PAX_RANDMMAP
8724 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8725 + mm->mmap_base += mm->delta_mmap;
8726 +#endif
8727 +
8728 mm->get_unmapped_area = arch_get_unmapped_area;
8729 } else {
8730 mm->mmap_base = mmap_base();
8731 +
8732 +#ifdef CONFIG_PAX_RANDMMAP
8733 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8734 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8735 +#endif
8736 +
8737 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8738 }
8739 }
8740 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8741 */
8742 if (mmap_is_legacy()) {
8743 mm->mmap_base = TASK_UNMAPPED_BASE;
8744 +
8745 +#ifdef CONFIG_PAX_RANDMMAP
8746 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8747 + mm->mmap_base += mm->delta_mmap;
8748 +#endif
8749 +
8750 mm->get_unmapped_area = s390_get_unmapped_area;
8751 } else {
8752 mm->mmap_base = mmap_base();
8753 +
8754 +#ifdef CONFIG_PAX_RANDMMAP
8755 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8756 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8757 +#endif
8758 +
8759 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8760 }
8761 }
8762 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8763 index ae3d59f..f65f075 100644
8764 --- a/arch/score/include/asm/cache.h
8765 +++ b/arch/score/include/asm/cache.h
8766 @@ -1,7 +1,9 @@
8767 #ifndef _ASM_SCORE_CACHE_H
8768 #define _ASM_SCORE_CACHE_H
8769
8770 +#include <linux/const.h>
8771 +
8772 #define L1_CACHE_SHIFT 4
8773 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8774 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8775
8776 #endif /* _ASM_SCORE_CACHE_H */
8777 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8778 index f9f3cd5..58ff438 100644
8779 --- a/arch/score/include/asm/exec.h
8780 +++ b/arch/score/include/asm/exec.h
8781 @@ -1,6 +1,6 @@
8782 #ifndef _ASM_SCORE_EXEC_H
8783 #define _ASM_SCORE_EXEC_H
8784
8785 -extern unsigned long arch_align_stack(unsigned long sp);
8786 +#define arch_align_stack(x) (x)
8787
8788 #endif /* _ASM_SCORE_EXEC_H */
8789 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8790 index f4c6d02..e9355c3 100644
8791 --- a/arch/score/kernel/process.c
8792 +++ b/arch/score/kernel/process.c
8793 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8794
8795 return task_pt_regs(task)->cp0_epc;
8796 }
8797 -
8798 -unsigned long arch_align_stack(unsigned long sp)
8799 -{
8800 - return sp;
8801 -}
8802 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8803 index ef9e555..331bd29 100644
8804 --- a/arch/sh/include/asm/cache.h
8805 +++ b/arch/sh/include/asm/cache.h
8806 @@ -9,10 +9,11 @@
8807 #define __ASM_SH_CACHE_H
8808 #ifdef __KERNEL__
8809
8810 +#include <linux/const.h>
8811 #include <linux/init.h>
8812 #include <cpu/cache.h>
8813
8814 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8815 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8816
8817 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8818
8819 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8820 index 6777177..cb5e44f 100644
8821 --- a/arch/sh/mm/mmap.c
8822 +++ b/arch/sh/mm/mmap.c
8823 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8824 struct mm_struct *mm = current->mm;
8825 struct vm_area_struct *vma;
8826 int do_colour_align;
8827 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8828 struct vm_unmapped_area_info info;
8829
8830 if (flags & MAP_FIXED) {
8831 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8832 if (filp || (flags & MAP_SHARED))
8833 do_colour_align = 1;
8834
8835 +#ifdef CONFIG_PAX_RANDMMAP
8836 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8837 +#endif
8838 +
8839 if (addr) {
8840 if (do_colour_align)
8841 addr = COLOUR_ALIGN(addr, pgoff);
8842 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8843 addr = PAGE_ALIGN(addr);
8844
8845 vma = find_vma(mm, addr);
8846 - if (TASK_SIZE - len >= addr &&
8847 - (!vma || addr + len <= vma->vm_start))
8848 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8849 return addr;
8850 }
8851
8852 info.flags = 0;
8853 info.length = len;
8854 - info.low_limit = TASK_UNMAPPED_BASE;
8855 + info.low_limit = mm->mmap_base;
8856 info.high_limit = TASK_SIZE;
8857 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8858 info.align_offset = pgoff << PAGE_SHIFT;
8859 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8860 struct mm_struct *mm = current->mm;
8861 unsigned long addr = addr0;
8862 int do_colour_align;
8863 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8864 struct vm_unmapped_area_info info;
8865
8866 if (flags & MAP_FIXED) {
8867 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8868 if (filp || (flags & MAP_SHARED))
8869 do_colour_align = 1;
8870
8871 +#ifdef CONFIG_PAX_RANDMMAP
8872 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8873 +#endif
8874 +
8875 /* requesting a specific address */
8876 if (addr) {
8877 if (do_colour_align)
8878 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8879 addr = PAGE_ALIGN(addr);
8880
8881 vma = find_vma(mm, addr);
8882 - if (TASK_SIZE - len >= addr &&
8883 - (!vma || addr + len <= vma->vm_start))
8884 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8885 return addr;
8886 }
8887
8888 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8889 VM_BUG_ON(addr != -ENOMEM);
8890 info.flags = 0;
8891 info.low_limit = TASK_UNMAPPED_BASE;
8892 +
8893 +#ifdef CONFIG_PAX_RANDMMAP
8894 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8895 + info.low_limit += mm->delta_mmap;
8896 +#endif
8897 +
8898 info.high_limit = TASK_SIZE;
8899 addr = vm_unmapped_area(&info);
8900 }
8901 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8902 index be56a24..443328f 100644
8903 --- a/arch/sparc/include/asm/atomic_64.h
8904 +++ b/arch/sparc/include/asm/atomic_64.h
8905 @@ -14,18 +14,40 @@
8906 #define ATOMIC64_INIT(i) { (i) }
8907
8908 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8909 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8910 +{
8911 + return v->counter;
8912 +}
8913 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8914 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8915 +{
8916 + return v->counter;
8917 +}
8918
8919 #define atomic_set(v, i) (((v)->counter) = i)
8920 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8921 +{
8922 + v->counter = i;
8923 +}
8924 #define atomic64_set(v, i) (((v)->counter) = i)
8925 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8926 +{
8927 + v->counter = i;
8928 +}
8929
8930 extern void atomic_add(int, atomic_t *);
8931 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8932 extern void atomic64_add(long, atomic64_t *);
8933 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8934 extern void atomic_sub(int, atomic_t *);
8935 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8936 extern void atomic64_sub(long, atomic64_t *);
8937 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8938
8939 extern int atomic_add_ret(int, atomic_t *);
8940 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8941 extern long atomic64_add_ret(long, atomic64_t *);
8942 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8943 extern int atomic_sub_ret(int, atomic_t *);
8944 extern long atomic64_sub_ret(long, atomic64_t *);
8945
8946 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8947 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8948
8949 #define atomic_inc_return(v) atomic_add_ret(1, v)
8950 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8951 +{
8952 + return atomic_add_ret_unchecked(1, v);
8953 +}
8954 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8955 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8956 +{
8957 + return atomic64_add_ret_unchecked(1, v);
8958 +}
8959
8960 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8961 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8962
8963 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8964 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8965 +{
8966 + return atomic_add_ret_unchecked(i, v);
8967 +}
8968 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8969 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8970 +{
8971 + return atomic64_add_ret_unchecked(i, v);
8972 +}
8973
8974 /*
8975 * atomic_inc_and_test - increment and test
8976 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8977 * other cases.
8978 */
8979 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8980 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8981 +{
8982 + return atomic_inc_return_unchecked(v) == 0;
8983 +}
8984 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8985
8986 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8987 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8988 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8989
8990 #define atomic_inc(v) atomic_add(1, v)
8991 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8992 +{
8993 + atomic_add_unchecked(1, v);
8994 +}
8995 #define atomic64_inc(v) atomic64_add(1, v)
8996 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8997 +{
8998 + atomic64_add_unchecked(1, v);
8999 +}
9000
9001 #define atomic_dec(v) atomic_sub(1, v)
9002 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9003 +{
9004 + atomic_sub_unchecked(1, v);
9005 +}
9006 #define atomic64_dec(v) atomic64_sub(1, v)
9007 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9008 +{
9009 + atomic64_sub_unchecked(1, v);
9010 +}
9011
9012 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
9013 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
9014
9015 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
9016 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9017 +{
9018 + return cmpxchg(&v->counter, old, new);
9019 +}
9020 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
9021 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9022 +{
9023 + return xchg(&v->counter, new);
9024 +}
9025
9026 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9027 {
9028 - int c, old;
9029 + int c, old, new;
9030 c = atomic_read(v);
9031 for (;;) {
9032 - if (unlikely(c == (u)))
9033 + if (unlikely(c == u))
9034 break;
9035 - old = atomic_cmpxchg((v), c, c + (a));
9036 +
9037 + asm volatile("addcc %2, %0, %0\n"
9038 +
9039 +#ifdef CONFIG_PAX_REFCOUNT
9040 + "tvs %%icc, 6\n"
9041 +#endif
9042 +
9043 + : "=r" (new)
9044 + : "0" (c), "ir" (a)
9045 + : "cc");
9046 +
9047 + old = atomic_cmpxchg(v, c, new);
9048 if (likely(old == c))
9049 break;
9050 c = old;
9051 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9052 #define atomic64_cmpxchg(v, o, n) \
9053 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9054 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9055 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9056 +{
9057 + return xchg(&v->counter, new);
9058 +}
9059
9060 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9061 {
9062 - long c, old;
9063 + long c, old, new;
9064 c = atomic64_read(v);
9065 for (;;) {
9066 - if (unlikely(c == (u)))
9067 + if (unlikely(c == u))
9068 break;
9069 - old = atomic64_cmpxchg((v), c, c + (a));
9070 +
9071 + asm volatile("addcc %2, %0, %0\n"
9072 +
9073 +#ifdef CONFIG_PAX_REFCOUNT
9074 + "tvs %%xcc, 6\n"
9075 +#endif
9076 +
9077 + : "=r" (new)
9078 + : "0" (c), "ir" (a)
9079 + : "cc");
9080 +
9081 + old = atomic64_cmpxchg(v, c, new);
9082 if (likely(old == c))
9083 break;
9084 c = old;
9085 }
9086 - return c != (u);
9087 + return c != u;
9088 }
9089
9090 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9091 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9092 index 5bb6991..5c2132e 100644
9093 --- a/arch/sparc/include/asm/cache.h
9094 +++ b/arch/sparc/include/asm/cache.h
9095 @@ -7,10 +7,12 @@
9096 #ifndef _SPARC_CACHE_H
9097 #define _SPARC_CACHE_H
9098
9099 +#include <linux/const.h>
9100 +
9101 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9102
9103 #define L1_CACHE_SHIFT 5
9104 -#define L1_CACHE_BYTES 32
9105 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9106
9107 #ifdef CONFIG_SPARC32
9108 #define SMP_CACHE_BYTES_SHIFT 5
9109 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9110 index a24e41f..47677ff 100644
9111 --- a/arch/sparc/include/asm/elf_32.h
9112 +++ b/arch/sparc/include/asm/elf_32.h
9113 @@ -114,6 +114,13 @@ typedef struct {
9114
9115 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9116
9117 +#ifdef CONFIG_PAX_ASLR
9118 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9119 +
9120 +#define PAX_DELTA_MMAP_LEN 16
9121 +#define PAX_DELTA_STACK_LEN 16
9122 +#endif
9123 +
9124 /* This yields a mask that user programs can use to figure out what
9125 instruction set this cpu supports. This can NOT be done in userspace
9126 on Sparc. */
9127 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9128 index 370ca1e..d4f4a98 100644
9129 --- a/arch/sparc/include/asm/elf_64.h
9130 +++ b/arch/sparc/include/asm/elf_64.h
9131 @@ -189,6 +189,13 @@ typedef struct {
9132 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9133 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9134
9135 +#ifdef CONFIG_PAX_ASLR
9136 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9137 +
9138 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9139 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9140 +#endif
9141 +
9142 extern unsigned long sparc64_elf_hwcap;
9143 #define ELF_HWCAP sparc64_elf_hwcap
9144
9145 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9146 index 9b1c36d..209298b 100644
9147 --- a/arch/sparc/include/asm/pgalloc_32.h
9148 +++ b/arch/sparc/include/asm/pgalloc_32.h
9149 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9150 }
9151
9152 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9153 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9154
9155 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9156 unsigned long address)
9157 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9158 index bcfe063..b333142 100644
9159 --- a/arch/sparc/include/asm/pgalloc_64.h
9160 +++ b/arch/sparc/include/asm/pgalloc_64.h
9161 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9162 }
9163
9164 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9165 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9166
9167 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9168 {
9169 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9170 index 502f632..da1917f 100644
9171 --- a/arch/sparc/include/asm/pgtable_32.h
9172 +++ b/arch/sparc/include/asm/pgtable_32.h
9173 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9174 #define PAGE_SHARED SRMMU_PAGE_SHARED
9175 #define PAGE_COPY SRMMU_PAGE_COPY
9176 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9177 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9178 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9179 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9180 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9181
9182 /* Top-level page directory - dummy used by init-mm.
9183 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9184
9185 /* xwr */
9186 #define __P000 PAGE_NONE
9187 -#define __P001 PAGE_READONLY
9188 -#define __P010 PAGE_COPY
9189 -#define __P011 PAGE_COPY
9190 +#define __P001 PAGE_READONLY_NOEXEC
9191 +#define __P010 PAGE_COPY_NOEXEC
9192 +#define __P011 PAGE_COPY_NOEXEC
9193 #define __P100 PAGE_READONLY
9194 #define __P101 PAGE_READONLY
9195 #define __P110 PAGE_COPY
9196 #define __P111 PAGE_COPY
9197
9198 #define __S000 PAGE_NONE
9199 -#define __S001 PAGE_READONLY
9200 -#define __S010 PAGE_SHARED
9201 -#define __S011 PAGE_SHARED
9202 +#define __S001 PAGE_READONLY_NOEXEC
9203 +#define __S010 PAGE_SHARED_NOEXEC
9204 +#define __S011 PAGE_SHARED_NOEXEC
9205 #define __S100 PAGE_READONLY
9206 #define __S101 PAGE_READONLY
9207 #define __S110 PAGE_SHARED
9208 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9209 index 79da178..c2eede8 100644
9210 --- a/arch/sparc/include/asm/pgtsrmmu.h
9211 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9212 @@ -115,6 +115,11 @@
9213 SRMMU_EXEC | SRMMU_REF)
9214 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9215 SRMMU_EXEC | SRMMU_REF)
9216 +
9217 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9218 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9219 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9220 +
9221 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9222 SRMMU_DIRTY | SRMMU_REF)
9223
9224 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9225 index 9689176..63c18ea 100644
9226 --- a/arch/sparc/include/asm/spinlock_64.h
9227 +++ b/arch/sparc/include/asm/spinlock_64.h
9228 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9229
9230 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9231
9232 -static void inline arch_read_lock(arch_rwlock_t *lock)
9233 +static inline void arch_read_lock(arch_rwlock_t *lock)
9234 {
9235 unsigned long tmp1, tmp2;
9236
9237 __asm__ __volatile__ (
9238 "1: ldsw [%2], %0\n"
9239 " brlz,pn %0, 2f\n"
9240 -"4: add %0, 1, %1\n"
9241 +"4: addcc %0, 1, %1\n"
9242 +
9243 +#ifdef CONFIG_PAX_REFCOUNT
9244 +" tvs %%icc, 6\n"
9245 +#endif
9246 +
9247 " cas [%2], %0, %1\n"
9248 " cmp %0, %1\n"
9249 " bne,pn %%icc, 1b\n"
9250 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9251 " .previous"
9252 : "=&r" (tmp1), "=&r" (tmp2)
9253 : "r" (lock)
9254 - : "memory");
9255 + : "memory", "cc");
9256 }
9257
9258 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9259 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9260 {
9261 int tmp1, tmp2;
9262
9263 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9264 "1: ldsw [%2], %0\n"
9265 " brlz,a,pn %0, 2f\n"
9266 " mov 0, %0\n"
9267 -" add %0, 1, %1\n"
9268 +" addcc %0, 1, %1\n"
9269 +
9270 +#ifdef CONFIG_PAX_REFCOUNT
9271 +" tvs %%icc, 6\n"
9272 +#endif
9273 +
9274 " cas [%2], %0, %1\n"
9275 " cmp %0, %1\n"
9276 " bne,pn %%icc, 1b\n"
9277 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9278 return tmp1;
9279 }
9280
9281 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9282 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9283 {
9284 unsigned long tmp1, tmp2;
9285
9286 __asm__ __volatile__(
9287 "1: lduw [%2], %0\n"
9288 -" sub %0, 1, %1\n"
9289 +" subcc %0, 1, %1\n"
9290 +
9291 +#ifdef CONFIG_PAX_REFCOUNT
9292 +" tvs %%icc, 6\n"
9293 +#endif
9294 +
9295 " cas [%2], %0, %1\n"
9296 " cmp %0, %1\n"
9297 " bne,pn %%xcc, 1b\n"
9298 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9299 : "memory");
9300 }
9301
9302 -static void inline arch_write_lock(arch_rwlock_t *lock)
9303 +static inline void arch_write_lock(arch_rwlock_t *lock)
9304 {
9305 unsigned long mask, tmp1, tmp2;
9306
9307 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9308 : "memory");
9309 }
9310
9311 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9312 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9313 {
9314 __asm__ __volatile__(
9315 " stw %%g0, [%0]"
9316 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9317 : "memory");
9318 }
9319
9320 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9321 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9322 {
9323 unsigned long mask, tmp1, tmp2, result;
9324
9325 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9326 index dd38075..e7cac83 100644
9327 --- a/arch/sparc/include/asm/thread_info_32.h
9328 +++ b/arch/sparc/include/asm/thread_info_32.h
9329 @@ -49,6 +49,8 @@ struct thread_info {
9330 unsigned long w_saved;
9331
9332 struct restart_block restart_block;
9333 +
9334 + unsigned long lowest_stack;
9335 };
9336
9337 /*
9338 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9339 index d5e5042..9bfee76 100644
9340 --- a/arch/sparc/include/asm/thread_info_64.h
9341 +++ b/arch/sparc/include/asm/thread_info_64.h
9342 @@ -63,6 +63,8 @@ struct thread_info {
9343 struct pt_regs *kern_una_regs;
9344 unsigned int kern_una_insn;
9345
9346 + unsigned long lowest_stack;
9347 +
9348 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9349 };
9350
9351 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9352 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9353 /* flag bit 6 is available */
9354 #define TIF_32BIT 7 /* 32-bit binary */
9355 -/* flag bit 8 is available */
9356 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9357 #define TIF_SECCOMP 9 /* secure computing */
9358 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9359 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9360 +
9361 /* NOTE: Thread flags >= 12 should be ones we have no interest
9362 * in using in assembly, else we can't use the mask as
9363 * an immediate value in instructions such as andcc.
9364 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9365 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9366 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9367 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9368 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9369
9370 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9371 _TIF_DO_NOTIFY_RESUME_MASK | \
9372 _TIF_NEED_RESCHED)
9373 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9374
9375 +#define _TIF_WORK_SYSCALL \
9376 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9377 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9378 +
9379 +
9380 /*
9381 * Thread-synchronous status.
9382 *
9383 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9384 index 0167d26..767bb0c 100644
9385 --- a/arch/sparc/include/asm/uaccess.h
9386 +++ b/arch/sparc/include/asm/uaccess.h
9387 @@ -1,5 +1,6 @@
9388 #ifndef ___ASM_SPARC_UACCESS_H
9389 #define ___ASM_SPARC_UACCESS_H
9390 +
9391 #if defined(__sparc__) && defined(__arch64__)
9392 #include <asm/uaccess_64.h>
9393 #else
9394 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9395 index 53a28dd..50c38c3 100644
9396 --- a/arch/sparc/include/asm/uaccess_32.h
9397 +++ b/arch/sparc/include/asm/uaccess_32.h
9398 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9399
9400 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9401 {
9402 - if (n && __access_ok((unsigned long) to, n))
9403 + if ((long)n < 0)
9404 + return n;
9405 +
9406 + if (n && __access_ok((unsigned long) to, n)) {
9407 + if (!__builtin_constant_p(n))
9408 + check_object_size(from, n, true);
9409 return __copy_user(to, (__force void __user *) from, n);
9410 - else
9411 + } else
9412 return n;
9413 }
9414
9415 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9416 {
9417 + if ((long)n < 0)
9418 + return n;
9419 +
9420 + if (!__builtin_constant_p(n))
9421 + check_object_size(from, n, true);
9422 +
9423 return __copy_user(to, (__force void __user *) from, n);
9424 }
9425
9426 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9427 {
9428 - if (n && __access_ok((unsigned long) from, n))
9429 + if ((long)n < 0)
9430 + return n;
9431 +
9432 + if (n && __access_ok((unsigned long) from, n)) {
9433 + if (!__builtin_constant_p(n))
9434 + check_object_size(to, n, false);
9435 return __copy_user((__force void __user *) to, from, n);
9436 - else
9437 + } else
9438 return n;
9439 }
9440
9441 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9442 {
9443 + if ((long)n < 0)
9444 + return n;
9445 +
9446 return __copy_user((__force void __user *) to, from, n);
9447 }
9448
9449 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9450 index e562d3c..191f176 100644
9451 --- a/arch/sparc/include/asm/uaccess_64.h
9452 +++ b/arch/sparc/include/asm/uaccess_64.h
9453 @@ -10,6 +10,7 @@
9454 #include <linux/compiler.h>
9455 #include <linux/string.h>
9456 #include <linux/thread_info.h>
9457 +#include <linux/kernel.h>
9458 #include <asm/asi.h>
9459 #include <asm/spitfire.h>
9460 #include <asm-generic/uaccess-unaligned.h>
9461 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9462 static inline unsigned long __must_check
9463 copy_from_user(void *to, const void __user *from, unsigned long size)
9464 {
9465 - unsigned long ret = ___copy_from_user(to, from, size);
9466 + unsigned long ret;
9467
9468 + if ((long)size < 0 || size > INT_MAX)
9469 + return size;
9470 +
9471 + if (!__builtin_constant_p(size))
9472 + check_object_size(to, size, false);
9473 +
9474 + ret = ___copy_from_user(to, from, size);
9475 if (unlikely(ret))
9476 ret = copy_from_user_fixup(to, from, size);
9477
9478 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9479 static inline unsigned long __must_check
9480 copy_to_user(void __user *to, const void *from, unsigned long size)
9481 {
9482 - unsigned long ret = ___copy_to_user(to, from, size);
9483 + unsigned long ret;
9484
9485 + if ((long)size < 0 || size > INT_MAX)
9486 + return size;
9487 +
9488 + if (!__builtin_constant_p(size))
9489 + check_object_size(from, size, true);
9490 +
9491 + ret = ___copy_to_user(to, from, size);
9492 if (unlikely(ret))
9493 ret = copy_to_user_fixup(to, from, size);
9494 return ret;
9495 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9496 index d432fb2..6056af1 100644
9497 --- a/arch/sparc/kernel/Makefile
9498 +++ b/arch/sparc/kernel/Makefile
9499 @@ -3,7 +3,7 @@
9500 #
9501
9502 asflags-y := -ansi
9503 -ccflags-y := -Werror
9504 +#ccflags-y := -Werror
9505
9506 extra-y := head_$(BITS).o
9507
9508 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9509 index fdd819d..5af08c8 100644
9510 --- a/arch/sparc/kernel/process_32.c
9511 +++ b/arch/sparc/kernel/process_32.c
9512 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9513
9514 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9515 r->psr, r->pc, r->npc, r->y, print_tainted());
9516 - printk("PC: <%pS>\n", (void *) r->pc);
9517 + printk("PC: <%pA>\n", (void *) r->pc);
9518 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9519 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9520 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9521 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9522 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9523 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9524 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9525 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9526
9527 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9528 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9529 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9530 rw = (struct reg_window32 *) fp;
9531 pc = rw->ins[7];
9532 printk("[%08lx : ", pc);
9533 - printk("%pS ] ", (void *) pc);
9534 + printk("%pA ] ", (void *) pc);
9535 fp = rw->ins[6];
9536 } while (++count < 16);
9537 printk("\n");
9538 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9539 index baebab2..9cd13b1 100644
9540 --- a/arch/sparc/kernel/process_64.c
9541 +++ b/arch/sparc/kernel/process_64.c
9542 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9543 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9544 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9545 if (regs->tstate & TSTATE_PRIV)
9546 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9547 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9548 }
9549
9550 void show_regs(struct pt_regs *regs)
9551 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9552
9553 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9554 regs->tpc, regs->tnpc, regs->y, print_tainted());
9555 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9556 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9557 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9558 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9559 regs->u_regs[3]);
9560 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9561 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9562 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9563 regs->u_regs[15]);
9564 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9565 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9566 show_regwindow(regs);
9567 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9568 }
9569 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9570 ((tp && tp->task) ? tp->task->pid : -1));
9571
9572 if (gp->tstate & TSTATE_PRIV) {
9573 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9574 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9575 (void *) gp->tpc,
9576 (void *) gp->o7,
9577 (void *) gp->i7,
9578 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9579 index 79cc0d1..ec62734 100644
9580 --- a/arch/sparc/kernel/prom_common.c
9581 +++ b/arch/sparc/kernel/prom_common.c
9582 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9583
9584 unsigned int prom_early_allocated __initdata;
9585
9586 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9587 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9588 .nextprop = prom_common_nextprop,
9589 .getproplen = prom_getproplen,
9590 .getproperty = prom_getproperty,
9591 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9592 index 7ff45e4..a58f271 100644
9593 --- a/arch/sparc/kernel/ptrace_64.c
9594 +++ b/arch/sparc/kernel/ptrace_64.c
9595 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9596 return ret;
9597 }
9598
9599 +#ifdef CONFIG_GRKERNSEC_SETXID
9600 +extern void gr_delayed_cred_worker(void);
9601 +#endif
9602 +
9603 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9604 {
9605 int ret = 0;
9606 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9607 /* do the secure computing check first */
9608 secure_computing_strict(regs->u_regs[UREG_G1]);
9609
9610 +#ifdef CONFIG_GRKERNSEC_SETXID
9611 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9612 + gr_delayed_cred_worker();
9613 +#endif
9614 +
9615 if (test_thread_flag(TIF_SYSCALL_TRACE))
9616 ret = tracehook_report_syscall_entry(regs);
9617
9618 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9619
9620 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9621 {
9622 +#ifdef CONFIG_GRKERNSEC_SETXID
9623 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9624 + gr_delayed_cred_worker();
9625 +#endif
9626 +
9627 audit_syscall_exit(regs);
9628
9629 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9630 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9631 index e142545..fd29654 100644
9632 --- a/arch/sparc/kernel/smp_64.c
9633 +++ b/arch/sparc/kernel/smp_64.c
9634 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9635 extern unsigned long xcall_flush_dcache_page_spitfire;
9636
9637 #ifdef CONFIG_DEBUG_DCFLUSH
9638 -extern atomic_t dcpage_flushes;
9639 -extern atomic_t dcpage_flushes_xcall;
9640 +extern atomic_unchecked_t dcpage_flushes;
9641 +extern atomic_unchecked_t dcpage_flushes_xcall;
9642 #endif
9643
9644 static inline void __local_flush_dcache_page(struct page *page)
9645 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9646 return;
9647
9648 #ifdef CONFIG_DEBUG_DCFLUSH
9649 - atomic_inc(&dcpage_flushes);
9650 + atomic_inc_unchecked(&dcpage_flushes);
9651 #endif
9652
9653 this_cpu = get_cpu();
9654 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9655 xcall_deliver(data0, __pa(pg_addr),
9656 (u64) pg_addr, cpumask_of(cpu));
9657 #ifdef CONFIG_DEBUG_DCFLUSH
9658 - atomic_inc(&dcpage_flushes_xcall);
9659 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9660 #endif
9661 }
9662 }
9663 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9664 preempt_disable();
9665
9666 #ifdef CONFIG_DEBUG_DCFLUSH
9667 - atomic_inc(&dcpage_flushes);
9668 + atomic_inc_unchecked(&dcpage_flushes);
9669 #endif
9670 data0 = 0;
9671 pg_addr = page_address(page);
9672 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9673 xcall_deliver(data0, __pa(pg_addr),
9674 (u64) pg_addr, cpu_online_mask);
9675 #ifdef CONFIG_DEBUG_DCFLUSH
9676 - atomic_inc(&dcpage_flushes_xcall);
9677 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9678 #endif
9679 }
9680 __local_flush_dcache_page(page);
9681 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9682 index 3a8d184..49498a8 100644
9683 --- a/arch/sparc/kernel/sys_sparc_32.c
9684 +++ b/arch/sparc/kernel/sys_sparc_32.c
9685 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9686 if (len > TASK_SIZE - PAGE_SIZE)
9687 return -ENOMEM;
9688 if (!addr)
9689 - addr = TASK_UNMAPPED_BASE;
9690 + addr = current->mm->mmap_base;
9691
9692 info.flags = 0;
9693 info.length = len;
9694 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9695 index 51561b8..8256764 100644
9696 --- a/arch/sparc/kernel/sys_sparc_64.c
9697 +++ b/arch/sparc/kernel/sys_sparc_64.c
9698 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9699 struct vm_area_struct * vma;
9700 unsigned long task_size = TASK_SIZE;
9701 int do_color_align;
9702 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9703 struct vm_unmapped_area_info info;
9704
9705 if (flags & MAP_FIXED) {
9706 /* We do not accept a shared mapping if it would violate
9707 * cache aliasing constraints.
9708 */
9709 - if ((flags & MAP_SHARED) &&
9710 + if ((filp || (flags & MAP_SHARED)) &&
9711 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9712 return -EINVAL;
9713 return addr;
9714 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9715 if (filp || (flags & MAP_SHARED))
9716 do_color_align = 1;
9717
9718 +#ifdef CONFIG_PAX_RANDMMAP
9719 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9720 +#endif
9721 +
9722 if (addr) {
9723 if (do_color_align)
9724 addr = COLOR_ALIGN(addr, pgoff);
9725 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9726 addr = PAGE_ALIGN(addr);
9727
9728 vma = find_vma(mm, addr);
9729 - if (task_size - len >= addr &&
9730 - (!vma || addr + len <= vma->vm_start))
9731 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9732 return addr;
9733 }
9734
9735 info.flags = 0;
9736 info.length = len;
9737 - info.low_limit = TASK_UNMAPPED_BASE;
9738 + info.low_limit = mm->mmap_base;
9739 info.high_limit = min(task_size, VA_EXCLUDE_START);
9740 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9741 info.align_offset = pgoff << PAGE_SHIFT;
9742 + info.threadstack_offset = offset;
9743 addr = vm_unmapped_area(&info);
9744
9745 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9746 VM_BUG_ON(addr != -ENOMEM);
9747 info.low_limit = VA_EXCLUDE_END;
9748 +
9749 +#ifdef CONFIG_PAX_RANDMMAP
9750 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9751 + info.low_limit += mm->delta_mmap;
9752 +#endif
9753 +
9754 info.high_limit = task_size;
9755 addr = vm_unmapped_area(&info);
9756 }
9757 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9758 unsigned long task_size = STACK_TOP32;
9759 unsigned long addr = addr0;
9760 int do_color_align;
9761 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9762 struct vm_unmapped_area_info info;
9763
9764 /* This should only ever run for 32-bit processes. */
9765 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9766 /* We do not accept a shared mapping if it would violate
9767 * cache aliasing constraints.
9768 */
9769 - if ((flags & MAP_SHARED) &&
9770 + if ((filp || (flags & MAP_SHARED)) &&
9771 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9772 return -EINVAL;
9773 return addr;
9774 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9775 if (filp || (flags & MAP_SHARED))
9776 do_color_align = 1;
9777
9778 +#ifdef CONFIG_PAX_RANDMMAP
9779 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9780 +#endif
9781 +
9782 /* requesting a specific address */
9783 if (addr) {
9784 if (do_color_align)
9785 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9786 addr = PAGE_ALIGN(addr);
9787
9788 vma = find_vma(mm, addr);
9789 - if (task_size - len >= addr &&
9790 - (!vma || addr + len <= vma->vm_start))
9791 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9792 return addr;
9793 }
9794
9795 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9796 info.high_limit = mm->mmap_base;
9797 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9798 info.align_offset = pgoff << PAGE_SHIFT;
9799 + info.threadstack_offset = offset;
9800 addr = vm_unmapped_area(&info);
9801
9802 /*
9803 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9804 VM_BUG_ON(addr != -ENOMEM);
9805 info.flags = 0;
9806 info.low_limit = TASK_UNMAPPED_BASE;
9807 +
9808 +#ifdef CONFIG_PAX_RANDMMAP
9809 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9810 + info.low_limit += mm->delta_mmap;
9811 +#endif
9812 +
9813 info.high_limit = STACK_TOP32;
9814 addr = vm_unmapped_area(&info);
9815 }
9816 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9817 EXPORT_SYMBOL(get_fb_unmapped_area);
9818
9819 /* Essentially the same as PowerPC. */
9820 -static unsigned long mmap_rnd(void)
9821 +static unsigned long mmap_rnd(struct mm_struct *mm)
9822 {
9823 unsigned long rnd = 0UL;
9824
9825 +#ifdef CONFIG_PAX_RANDMMAP
9826 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9827 +#endif
9828 +
9829 if (current->flags & PF_RANDOMIZE) {
9830 unsigned long val = get_random_int();
9831 if (test_thread_flag(TIF_32BIT))
9832 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9833
9834 void arch_pick_mmap_layout(struct mm_struct *mm)
9835 {
9836 - unsigned long random_factor = mmap_rnd();
9837 + unsigned long random_factor = mmap_rnd(mm);
9838 unsigned long gap;
9839
9840 /*
9841 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9842 gap == RLIM_INFINITY ||
9843 sysctl_legacy_va_layout) {
9844 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9845 +
9846 +#ifdef CONFIG_PAX_RANDMMAP
9847 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9848 + mm->mmap_base += mm->delta_mmap;
9849 +#endif
9850 +
9851 mm->get_unmapped_area = arch_get_unmapped_area;
9852 } else {
9853 /* We know it's 32-bit */
9854 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9855 gap = (task_size / 6 * 5);
9856
9857 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9858 +
9859 +#ifdef CONFIG_PAX_RANDMMAP
9860 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9861 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9862 +#endif
9863 +
9864 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9865 }
9866 }
9867 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9868 index 73ec8a7..4611979 100644
9869 --- a/arch/sparc/kernel/syscalls.S
9870 +++ b/arch/sparc/kernel/syscalls.S
9871 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9872 #endif
9873 .align 32
9874 1: ldx [%g6 + TI_FLAGS], %l5
9875 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9876 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9877 be,pt %icc, rtrap
9878 nop
9879 call syscall_trace_leave
9880 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9881
9882 srl %i3, 0, %o3 ! IEU0
9883 srl %i2, 0, %o2 ! IEU0 Group
9884 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9885 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9886 bne,pn %icc, linux_syscall_trace32 ! CTI
9887 mov %i0, %l5 ! IEU1
9888 5: call %l7 ! CTI Group brk forced
9889 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9890
9891 mov %i3, %o3 ! IEU1
9892 mov %i4, %o4 ! IEU0 Group
9893 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9894 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9895 bne,pn %icc, linux_syscall_trace ! CTI Group
9896 mov %i0, %l5 ! IEU0
9897 2: call %l7 ! CTI Group brk forced
9898 @@ -223,7 +223,7 @@ ret_sys_call:
9899
9900 cmp %o0, -ERESTART_RESTARTBLOCK
9901 bgeu,pn %xcc, 1f
9902 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9903 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9904 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9905
9906 2:
9907 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9908 index 6629829..036032d 100644
9909 --- a/arch/sparc/kernel/traps_32.c
9910 +++ b/arch/sparc/kernel/traps_32.c
9911 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9912 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9913 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9914
9915 +extern void gr_handle_kernel_exploit(void);
9916 +
9917 void die_if_kernel(char *str, struct pt_regs *regs)
9918 {
9919 static int die_counter;
9920 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9921 count++ < 30 &&
9922 (((unsigned long) rw) >= PAGE_OFFSET) &&
9923 !(((unsigned long) rw) & 0x7)) {
9924 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9925 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9926 (void *) rw->ins[7]);
9927 rw = (struct reg_window32 *)rw->ins[6];
9928 }
9929 }
9930 printk("Instruction DUMP:");
9931 instruction_dump ((unsigned long *) regs->pc);
9932 - if(regs->psr & PSR_PS)
9933 + if(regs->psr & PSR_PS) {
9934 + gr_handle_kernel_exploit();
9935 do_exit(SIGKILL);
9936 + }
9937 do_exit(SIGSEGV);
9938 }
9939
9940 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9941 index b3f833a..f485f80 100644
9942 --- a/arch/sparc/kernel/traps_64.c
9943 +++ b/arch/sparc/kernel/traps_64.c
9944 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9945 i + 1,
9946 p->trapstack[i].tstate, p->trapstack[i].tpc,
9947 p->trapstack[i].tnpc, p->trapstack[i].tt);
9948 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9949 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9950 }
9951 }
9952
9953 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9954
9955 lvl -= 0x100;
9956 if (regs->tstate & TSTATE_PRIV) {
9957 +
9958 +#ifdef CONFIG_PAX_REFCOUNT
9959 + if (lvl == 6)
9960 + pax_report_refcount_overflow(regs);
9961 +#endif
9962 +
9963 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9964 die_if_kernel(buffer, regs);
9965 }
9966 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9967 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9968 {
9969 char buffer[32];
9970 -
9971 +
9972 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9973 0, lvl, SIGTRAP) == NOTIFY_STOP)
9974 return;
9975
9976 +#ifdef CONFIG_PAX_REFCOUNT
9977 + if (lvl == 6)
9978 + pax_report_refcount_overflow(regs);
9979 +#endif
9980 +
9981 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9982
9983 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9984 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9985 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9986 printk("%s" "ERROR(%d): ",
9987 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9988 - printk("TPC<%pS>\n", (void *) regs->tpc);
9989 + printk("TPC<%pA>\n", (void *) regs->tpc);
9990 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9991 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9992 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9993 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9994 smp_processor_id(),
9995 (type & 0x1) ? 'I' : 'D',
9996 regs->tpc);
9997 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9998 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9999 panic("Irrecoverable Cheetah+ parity error.");
10000 }
10001
10002 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10003 smp_processor_id(),
10004 (type & 0x1) ? 'I' : 'D',
10005 regs->tpc);
10006 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
10007 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
10008 }
10009
10010 struct sun4v_error_entry {
10011 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
10012 /*0x38*/u64 reserved_5;
10013 };
10014
10015 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10016 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10017 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10018 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10019
10020 static const char *sun4v_err_type_to_str(u8 type)
10021 {
10022 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
10023 }
10024
10025 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10026 - int cpu, const char *pfx, atomic_t *ocnt)
10027 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
10028 {
10029 u64 *raw_ptr = (u64 *) ent;
10030 u32 attrs;
10031 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10032
10033 show_regs(regs);
10034
10035 - if ((cnt = atomic_read(ocnt)) != 0) {
10036 - atomic_set(ocnt, 0);
10037 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
10038 + atomic_set_unchecked(ocnt, 0);
10039 wmb();
10040 printk("%s: Queue overflowed %d times.\n",
10041 pfx, cnt);
10042 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10043 */
10044 void sun4v_resum_overflow(struct pt_regs *regs)
10045 {
10046 - atomic_inc(&sun4v_resum_oflow_cnt);
10047 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10048 }
10049
10050 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10051 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10052 /* XXX Actually even this can make not that much sense. Perhaps
10053 * XXX we should just pull the plug and panic directly from here?
10054 */
10055 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10056 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10057 }
10058
10059 unsigned long sun4v_err_itlb_vaddr;
10060 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10061
10062 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10063 regs->tpc, tl);
10064 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10065 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10066 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10067 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10068 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10069 (void *) regs->u_regs[UREG_I7]);
10070 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10071 "pte[%lx] error[%lx]\n",
10072 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10073
10074 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10075 regs->tpc, tl);
10076 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10077 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10078 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10079 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10080 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10081 (void *) regs->u_regs[UREG_I7]);
10082 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10083 "pte[%lx] error[%lx]\n",
10084 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10085 fp = (unsigned long)sf->fp + STACK_BIAS;
10086 }
10087
10088 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10089 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10090 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10091 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10092 int index = tsk->curr_ret_stack;
10093 if (tsk->ret_stack && index >= graph) {
10094 pc = tsk->ret_stack[index - graph].ret;
10095 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10096 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10097 graph++;
10098 }
10099 }
10100 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10101 return (struct reg_window *) (fp + STACK_BIAS);
10102 }
10103
10104 +extern void gr_handle_kernel_exploit(void);
10105 +
10106 void die_if_kernel(char *str, struct pt_regs *regs)
10107 {
10108 static int die_counter;
10109 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10110 while (rw &&
10111 count++ < 30 &&
10112 kstack_valid(tp, (unsigned long) rw)) {
10113 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10114 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10115 (void *) rw->ins[7]);
10116
10117 rw = kernel_stack_up(rw);
10118 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10119 }
10120 user_instruction_dump ((unsigned int __user *) regs->tpc);
10121 }
10122 - if (regs->tstate & TSTATE_PRIV)
10123 + if (regs->tstate & TSTATE_PRIV) {
10124 + gr_handle_kernel_exploit();
10125 do_exit(SIGKILL);
10126 + }
10127 do_exit(SIGSEGV);
10128 }
10129 EXPORT_SYMBOL(die_if_kernel);
10130 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10131 index 8201c25e..072a2a7 100644
10132 --- a/arch/sparc/kernel/unaligned_64.c
10133 +++ b/arch/sparc/kernel/unaligned_64.c
10134 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10135 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10136
10137 if (__ratelimit(&ratelimit)) {
10138 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10139 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10140 regs->tpc, (void *) regs->tpc);
10141 }
10142 }
10143 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10144 index dbe119b..089c7c1 100644
10145 --- a/arch/sparc/lib/Makefile
10146 +++ b/arch/sparc/lib/Makefile
10147 @@ -2,7 +2,7 @@
10148 #
10149
10150 asflags-y := -ansi -DST_DIV0=0x02
10151 -ccflags-y := -Werror
10152 +#ccflags-y := -Werror
10153
10154 lib-$(CONFIG_SPARC32) += ashrdi3.o
10155 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10156 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10157 index 85c233d..68500e0 100644
10158 --- a/arch/sparc/lib/atomic_64.S
10159 +++ b/arch/sparc/lib/atomic_64.S
10160 @@ -17,7 +17,12 @@
10161 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10162 BACKOFF_SETUP(%o2)
10163 1: lduw [%o1], %g1
10164 - add %g1, %o0, %g7
10165 + addcc %g1, %o0, %g7
10166 +
10167 +#ifdef CONFIG_PAX_REFCOUNT
10168 + tvs %icc, 6
10169 +#endif
10170 +
10171 cas [%o1], %g1, %g7
10172 cmp %g1, %g7
10173 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10174 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10175 2: BACKOFF_SPIN(%o2, %o3, 1b)
10176 ENDPROC(atomic_add)
10177
10178 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10179 + BACKOFF_SETUP(%o2)
10180 +1: lduw [%o1], %g1
10181 + add %g1, %o0, %g7
10182 + cas [%o1], %g1, %g7
10183 + cmp %g1, %g7
10184 + bne,pn %icc, 2f
10185 + nop
10186 + retl
10187 + nop
10188 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10189 +ENDPROC(atomic_add_unchecked)
10190 +
10191 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10192 BACKOFF_SETUP(%o2)
10193 1: lduw [%o1], %g1
10194 - sub %g1, %o0, %g7
10195 + subcc %g1, %o0, %g7
10196 +
10197 +#ifdef CONFIG_PAX_REFCOUNT
10198 + tvs %icc, 6
10199 +#endif
10200 +
10201 cas [%o1], %g1, %g7
10202 cmp %g1, %g7
10203 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10204 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10205 2: BACKOFF_SPIN(%o2, %o3, 1b)
10206 ENDPROC(atomic_sub)
10207
10208 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10209 + BACKOFF_SETUP(%o2)
10210 +1: lduw [%o1], %g1
10211 + sub %g1, %o0, %g7
10212 + cas [%o1], %g1, %g7
10213 + cmp %g1, %g7
10214 + bne,pn %icc, 2f
10215 + nop
10216 + retl
10217 + nop
10218 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10219 +ENDPROC(atomic_sub_unchecked)
10220 +
10221 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10222 BACKOFF_SETUP(%o2)
10223 1: lduw [%o1], %g1
10224 - add %g1, %o0, %g7
10225 + addcc %g1, %o0, %g7
10226 +
10227 +#ifdef CONFIG_PAX_REFCOUNT
10228 + tvs %icc, 6
10229 +#endif
10230 +
10231 cas [%o1], %g1, %g7
10232 cmp %g1, %g7
10233 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10234 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10235 2: BACKOFF_SPIN(%o2, %o3, 1b)
10236 ENDPROC(atomic_add_ret)
10237
10238 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10239 + BACKOFF_SETUP(%o2)
10240 +1: lduw [%o1], %g1
10241 + addcc %g1, %o0, %g7
10242 + cas [%o1], %g1, %g7
10243 + cmp %g1, %g7
10244 + bne,pn %icc, 2f
10245 + add %g7, %o0, %g7
10246 + sra %g7, 0, %o0
10247 + retl
10248 + nop
10249 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10250 +ENDPROC(atomic_add_ret_unchecked)
10251 +
10252 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10253 BACKOFF_SETUP(%o2)
10254 1: lduw [%o1], %g1
10255 - sub %g1, %o0, %g7
10256 + subcc %g1, %o0, %g7
10257 +
10258 +#ifdef CONFIG_PAX_REFCOUNT
10259 + tvs %icc, 6
10260 +#endif
10261 +
10262 cas [%o1], %g1, %g7
10263 cmp %g1, %g7
10264 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10265 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10266 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10267 BACKOFF_SETUP(%o2)
10268 1: ldx [%o1], %g1
10269 - add %g1, %o0, %g7
10270 + addcc %g1, %o0, %g7
10271 +
10272 +#ifdef CONFIG_PAX_REFCOUNT
10273 + tvs %xcc, 6
10274 +#endif
10275 +
10276 casx [%o1], %g1, %g7
10277 cmp %g1, %g7
10278 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10279 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10280 2: BACKOFF_SPIN(%o2, %o3, 1b)
10281 ENDPROC(atomic64_add)
10282
10283 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10284 + BACKOFF_SETUP(%o2)
10285 +1: ldx [%o1], %g1
10286 + addcc %g1, %o0, %g7
10287 + casx [%o1], %g1, %g7
10288 + cmp %g1, %g7
10289 + bne,pn %xcc, 2f
10290 + nop
10291 + retl
10292 + nop
10293 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10294 +ENDPROC(atomic64_add_unchecked)
10295 +
10296 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10297 BACKOFF_SETUP(%o2)
10298 1: ldx [%o1], %g1
10299 - sub %g1, %o0, %g7
10300 + subcc %g1, %o0, %g7
10301 +
10302 +#ifdef CONFIG_PAX_REFCOUNT
10303 + tvs %xcc, 6
10304 +#endif
10305 +
10306 casx [%o1], %g1, %g7
10307 cmp %g1, %g7
10308 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10309 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10310 2: BACKOFF_SPIN(%o2, %o3, 1b)
10311 ENDPROC(atomic64_sub)
10312
10313 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10314 + BACKOFF_SETUP(%o2)
10315 +1: ldx [%o1], %g1
10316 + subcc %g1, %o0, %g7
10317 + casx [%o1], %g1, %g7
10318 + cmp %g1, %g7
10319 + bne,pn %xcc, 2f
10320 + nop
10321 + retl
10322 + nop
10323 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10324 +ENDPROC(atomic64_sub_unchecked)
10325 +
10326 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10327 BACKOFF_SETUP(%o2)
10328 1: ldx [%o1], %g1
10329 - add %g1, %o0, %g7
10330 + addcc %g1, %o0, %g7
10331 +
10332 +#ifdef CONFIG_PAX_REFCOUNT
10333 + tvs %xcc, 6
10334 +#endif
10335 +
10336 casx [%o1], %g1, %g7
10337 cmp %g1, %g7
10338 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10339 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10340 2: BACKOFF_SPIN(%o2, %o3, 1b)
10341 ENDPROC(atomic64_add_ret)
10342
10343 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10344 + BACKOFF_SETUP(%o2)
10345 +1: ldx [%o1], %g1
10346 + addcc %g1, %o0, %g7
10347 + casx [%o1], %g1, %g7
10348 + cmp %g1, %g7
10349 + bne,pn %xcc, 2f
10350 + add %g7, %o0, %g7
10351 + mov %g7, %o0
10352 + retl
10353 + nop
10354 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10355 +ENDPROC(atomic64_add_ret_unchecked)
10356 +
10357 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10358 BACKOFF_SETUP(%o2)
10359 1: ldx [%o1], %g1
10360 - sub %g1, %o0, %g7
10361 + subcc %g1, %o0, %g7
10362 +
10363 +#ifdef CONFIG_PAX_REFCOUNT
10364 + tvs %xcc, 6
10365 +#endif
10366 +
10367 casx [%o1], %g1, %g7
10368 cmp %g1, %g7
10369 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10370 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10371 index 323335b..ed85ea2 100644
10372 --- a/arch/sparc/lib/ksyms.c
10373 +++ b/arch/sparc/lib/ksyms.c
10374 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10375
10376 /* Atomic counter implementation. */
10377 EXPORT_SYMBOL(atomic_add);
10378 +EXPORT_SYMBOL(atomic_add_unchecked);
10379 EXPORT_SYMBOL(atomic_add_ret);
10380 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10381 EXPORT_SYMBOL(atomic_sub);
10382 +EXPORT_SYMBOL(atomic_sub_unchecked);
10383 EXPORT_SYMBOL(atomic_sub_ret);
10384 EXPORT_SYMBOL(atomic64_add);
10385 +EXPORT_SYMBOL(atomic64_add_unchecked);
10386 EXPORT_SYMBOL(atomic64_add_ret);
10387 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10388 EXPORT_SYMBOL(atomic64_sub);
10389 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10390 EXPORT_SYMBOL(atomic64_sub_ret);
10391 EXPORT_SYMBOL(atomic64_dec_if_positive);
10392
10393 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10394 index 30c3ecc..736f015 100644
10395 --- a/arch/sparc/mm/Makefile
10396 +++ b/arch/sparc/mm/Makefile
10397 @@ -2,7 +2,7 @@
10398 #
10399
10400 asflags-y := -ansi
10401 -ccflags-y := -Werror
10402 +#ccflags-y := -Werror
10403
10404 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10405 obj-y += fault_$(BITS).o
10406 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10407 index e98bfda..ea8d221 100644
10408 --- a/arch/sparc/mm/fault_32.c
10409 +++ b/arch/sparc/mm/fault_32.c
10410 @@ -21,6 +21,9 @@
10411 #include <linux/perf_event.h>
10412 #include <linux/interrupt.h>
10413 #include <linux/kdebug.h>
10414 +#include <linux/slab.h>
10415 +#include <linux/pagemap.h>
10416 +#include <linux/compiler.h>
10417
10418 #include <asm/page.h>
10419 #include <asm/pgtable.h>
10420 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10421 return safe_compute_effective_address(regs, insn);
10422 }
10423
10424 +#ifdef CONFIG_PAX_PAGEEXEC
10425 +#ifdef CONFIG_PAX_DLRESOLVE
10426 +static void pax_emuplt_close(struct vm_area_struct *vma)
10427 +{
10428 + vma->vm_mm->call_dl_resolve = 0UL;
10429 +}
10430 +
10431 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10432 +{
10433 + unsigned int *kaddr;
10434 +
10435 + vmf->page = alloc_page(GFP_HIGHUSER);
10436 + if (!vmf->page)
10437 + return VM_FAULT_OOM;
10438 +
10439 + kaddr = kmap(vmf->page);
10440 + memset(kaddr, 0, PAGE_SIZE);
10441 + kaddr[0] = 0x9DE3BFA8U; /* save */
10442 + flush_dcache_page(vmf->page);
10443 + kunmap(vmf->page);
10444 + return VM_FAULT_MAJOR;
10445 +}
10446 +
10447 +static const struct vm_operations_struct pax_vm_ops = {
10448 + .close = pax_emuplt_close,
10449 + .fault = pax_emuplt_fault
10450 +};
10451 +
10452 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10453 +{
10454 + int ret;
10455 +
10456 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10457 + vma->vm_mm = current->mm;
10458 + vma->vm_start = addr;
10459 + vma->vm_end = addr + PAGE_SIZE;
10460 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10461 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10462 + vma->vm_ops = &pax_vm_ops;
10463 +
10464 + ret = insert_vm_struct(current->mm, vma);
10465 + if (ret)
10466 + return ret;
10467 +
10468 + ++current->mm->total_vm;
10469 + return 0;
10470 +}
10471 +#endif
10472 +
10473 +/*
10474 + * PaX: decide what to do with offenders (regs->pc = fault address)
10475 + *
10476 + * returns 1 when task should be killed
10477 + * 2 when patched PLT trampoline was detected
10478 + * 3 when unpatched PLT trampoline was detected
10479 + */
10480 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10481 +{
10482 +
10483 +#ifdef CONFIG_PAX_EMUPLT
10484 + int err;
10485 +
10486 + do { /* PaX: patched PLT emulation #1 */
10487 + unsigned int sethi1, sethi2, jmpl;
10488 +
10489 + err = get_user(sethi1, (unsigned int *)regs->pc);
10490 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10491 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10492 +
10493 + if (err)
10494 + break;
10495 +
10496 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10497 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10498 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10499 + {
10500 + unsigned int addr;
10501 +
10502 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10503 + addr = regs->u_regs[UREG_G1];
10504 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10505 + regs->pc = addr;
10506 + regs->npc = addr+4;
10507 + return 2;
10508 + }
10509 + } while (0);
10510 +
10511 + do { /* PaX: patched PLT emulation #2 */
10512 + unsigned int ba;
10513 +
10514 + err = get_user(ba, (unsigned int *)regs->pc);
10515 +
10516 + if (err)
10517 + break;
10518 +
10519 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10520 + unsigned int addr;
10521 +
10522 + if ((ba & 0xFFC00000U) == 0x30800000U)
10523 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10524 + else
10525 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10526 + regs->pc = addr;
10527 + regs->npc = addr+4;
10528 + return 2;
10529 + }
10530 + } while (0);
10531 +
10532 + do { /* PaX: patched PLT emulation #3 */
10533 + unsigned int sethi, bajmpl, nop;
10534 +
10535 + err = get_user(sethi, (unsigned int *)regs->pc);
10536 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10537 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10538 +
10539 + if (err)
10540 + break;
10541 +
10542 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10543 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10544 + nop == 0x01000000U)
10545 + {
10546 + unsigned int addr;
10547 +
10548 + addr = (sethi & 0x003FFFFFU) << 10;
10549 + regs->u_regs[UREG_G1] = addr;
10550 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10551 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10552 + else
10553 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10554 + regs->pc = addr;
10555 + regs->npc = addr+4;
10556 + return 2;
10557 + }
10558 + } while (0);
10559 +
10560 + do { /* PaX: unpatched PLT emulation step 1 */
10561 + unsigned int sethi, ba, nop;
10562 +
10563 + err = get_user(sethi, (unsigned int *)regs->pc);
10564 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10565 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10566 +
10567 + if (err)
10568 + break;
10569 +
10570 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10571 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10572 + nop == 0x01000000U)
10573 + {
10574 + unsigned int addr, save, call;
10575 +
10576 + if ((ba & 0xFFC00000U) == 0x30800000U)
10577 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10578 + else
10579 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10580 +
10581 + err = get_user(save, (unsigned int *)addr);
10582 + err |= get_user(call, (unsigned int *)(addr+4));
10583 + err |= get_user(nop, (unsigned int *)(addr+8));
10584 + if (err)
10585 + break;
10586 +
10587 +#ifdef CONFIG_PAX_DLRESOLVE
10588 + if (save == 0x9DE3BFA8U &&
10589 + (call & 0xC0000000U) == 0x40000000U &&
10590 + nop == 0x01000000U)
10591 + {
10592 + struct vm_area_struct *vma;
10593 + unsigned long call_dl_resolve;
10594 +
10595 + down_read(&current->mm->mmap_sem);
10596 + call_dl_resolve = current->mm->call_dl_resolve;
10597 + up_read(&current->mm->mmap_sem);
10598 + if (likely(call_dl_resolve))
10599 + goto emulate;
10600 +
10601 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10602 +
10603 + down_write(&current->mm->mmap_sem);
10604 + if (current->mm->call_dl_resolve) {
10605 + call_dl_resolve = current->mm->call_dl_resolve;
10606 + up_write(&current->mm->mmap_sem);
10607 + if (vma)
10608 + kmem_cache_free(vm_area_cachep, vma);
10609 + goto emulate;
10610 + }
10611 +
10612 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10613 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10614 + up_write(&current->mm->mmap_sem);
10615 + if (vma)
10616 + kmem_cache_free(vm_area_cachep, vma);
10617 + return 1;
10618 + }
10619 +
10620 + if (pax_insert_vma(vma, call_dl_resolve)) {
10621 + up_write(&current->mm->mmap_sem);
10622 + kmem_cache_free(vm_area_cachep, vma);
10623 + return 1;
10624 + }
10625 +
10626 + current->mm->call_dl_resolve = call_dl_resolve;
10627 + up_write(&current->mm->mmap_sem);
10628 +
10629 +emulate:
10630 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10631 + regs->pc = call_dl_resolve;
10632 + regs->npc = addr+4;
10633 + return 3;
10634 + }
10635 +#endif
10636 +
10637 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10638 + if ((save & 0xFFC00000U) == 0x05000000U &&
10639 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10640 + nop == 0x01000000U)
10641 + {
10642 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10643 + regs->u_regs[UREG_G2] = addr + 4;
10644 + addr = (save & 0x003FFFFFU) << 10;
10645 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10646 + regs->pc = addr;
10647 + regs->npc = addr+4;
10648 + return 3;
10649 + }
10650 + }
10651 + } while (0);
10652 +
10653 + do { /* PaX: unpatched PLT emulation step 2 */
10654 + unsigned int save, call, nop;
10655 +
10656 + err = get_user(save, (unsigned int *)(regs->pc-4));
10657 + err |= get_user(call, (unsigned int *)regs->pc);
10658 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10659 + if (err)
10660 + break;
10661 +
10662 + if (save == 0x9DE3BFA8U &&
10663 + (call & 0xC0000000U) == 0x40000000U &&
10664 + nop == 0x01000000U)
10665 + {
10666 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10667 +
10668 + regs->u_regs[UREG_RETPC] = regs->pc;
10669 + regs->pc = dl_resolve;
10670 + regs->npc = dl_resolve+4;
10671 + return 3;
10672 + }
10673 + } while (0);
10674 +#endif
10675 +
10676 + return 1;
10677 +}
10678 +
10679 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10680 +{
10681 + unsigned long i;
10682 +
10683 + printk(KERN_ERR "PAX: bytes at PC: ");
10684 + for (i = 0; i < 8; i++) {
10685 + unsigned int c;
10686 + if (get_user(c, (unsigned int *)pc+i))
10687 + printk(KERN_CONT "???????? ");
10688 + else
10689 + printk(KERN_CONT "%08x ", c);
10690 + }
10691 + printk("\n");
10692 +}
10693 +#endif
10694 +
10695 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10696 int text_fault)
10697 {
10698 @@ -230,6 +504,24 @@ good_area:
10699 if (!(vma->vm_flags & VM_WRITE))
10700 goto bad_area;
10701 } else {
10702 +
10703 +#ifdef CONFIG_PAX_PAGEEXEC
10704 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10705 + up_read(&mm->mmap_sem);
10706 + switch (pax_handle_fetch_fault(regs)) {
10707 +
10708 +#ifdef CONFIG_PAX_EMUPLT
10709 + case 2:
10710 + case 3:
10711 + return;
10712 +#endif
10713 +
10714 + }
10715 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10716 + do_group_exit(SIGKILL);
10717 + }
10718 +#endif
10719 +
10720 /* Allow reads even for write-only mappings */
10721 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10722 goto bad_area;
10723 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10724 index 5062ff3..e0b75f3 100644
10725 --- a/arch/sparc/mm/fault_64.c
10726 +++ b/arch/sparc/mm/fault_64.c
10727 @@ -21,6 +21,9 @@
10728 #include <linux/kprobes.h>
10729 #include <linux/kdebug.h>
10730 #include <linux/percpu.h>
10731 +#include <linux/slab.h>
10732 +#include <linux/pagemap.h>
10733 +#include <linux/compiler.h>
10734
10735 #include <asm/page.h>
10736 #include <asm/pgtable.h>
10737 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10738 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10739 regs->tpc);
10740 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10741 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10742 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10743 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10744 dump_stack();
10745 unhandled_fault(regs->tpc, current, regs);
10746 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10747 show_regs(regs);
10748 }
10749
10750 +#ifdef CONFIG_PAX_PAGEEXEC
10751 +#ifdef CONFIG_PAX_DLRESOLVE
10752 +static void pax_emuplt_close(struct vm_area_struct *vma)
10753 +{
10754 + vma->vm_mm->call_dl_resolve = 0UL;
10755 +}
10756 +
10757 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10758 +{
10759 + unsigned int *kaddr;
10760 +
10761 + vmf->page = alloc_page(GFP_HIGHUSER);
10762 + if (!vmf->page)
10763 + return VM_FAULT_OOM;
10764 +
10765 + kaddr = kmap(vmf->page);
10766 + memset(kaddr, 0, PAGE_SIZE);
10767 + kaddr[0] = 0x9DE3BFA8U; /* save */
10768 + flush_dcache_page(vmf->page);
10769 + kunmap(vmf->page);
10770 + return VM_FAULT_MAJOR;
10771 +}
10772 +
10773 +static const struct vm_operations_struct pax_vm_ops = {
10774 + .close = pax_emuplt_close,
10775 + .fault = pax_emuplt_fault
10776 +};
10777 +
10778 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10779 +{
10780 + int ret;
10781 +
10782 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10783 + vma->vm_mm = current->mm;
10784 + vma->vm_start = addr;
10785 + vma->vm_end = addr + PAGE_SIZE;
10786 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10787 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10788 + vma->vm_ops = &pax_vm_ops;
10789 +
10790 + ret = insert_vm_struct(current->mm, vma);
10791 + if (ret)
10792 + return ret;
10793 +
10794 + ++current->mm->total_vm;
10795 + return 0;
10796 +}
10797 +#endif
10798 +
10799 +/*
10800 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10801 + *
10802 + * returns 1 when task should be killed
10803 + * 2 when patched PLT trampoline was detected
10804 + * 3 when unpatched PLT trampoline was detected
10805 + */
10806 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10807 +{
10808 +
10809 +#ifdef CONFIG_PAX_EMUPLT
10810 + int err;
10811 +
10812 + do { /* PaX: patched PLT emulation #1 */
10813 + unsigned int sethi1, sethi2, jmpl;
10814 +
10815 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10816 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10817 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10818 +
10819 + if (err)
10820 + break;
10821 +
10822 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10823 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10824 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10825 + {
10826 + unsigned long addr;
10827 +
10828 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10829 + addr = regs->u_regs[UREG_G1];
10830 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10831 +
10832 + if (test_thread_flag(TIF_32BIT))
10833 + addr &= 0xFFFFFFFFUL;
10834 +
10835 + regs->tpc = addr;
10836 + regs->tnpc = addr+4;
10837 + return 2;
10838 + }
10839 + } while (0);
10840 +
10841 + do { /* PaX: patched PLT emulation #2 */
10842 + unsigned int ba;
10843 +
10844 + err = get_user(ba, (unsigned int *)regs->tpc);
10845 +
10846 + if (err)
10847 + break;
10848 +
10849 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10850 + unsigned long addr;
10851 +
10852 + if ((ba & 0xFFC00000U) == 0x30800000U)
10853 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10854 + else
10855 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10856 +
10857 + if (test_thread_flag(TIF_32BIT))
10858 + addr &= 0xFFFFFFFFUL;
10859 +
10860 + regs->tpc = addr;
10861 + regs->tnpc = addr+4;
10862 + return 2;
10863 + }
10864 + } while (0);
10865 +
10866 + do { /* PaX: patched PLT emulation #3 */
10867 + unsigned int sethi, bajmpl, nop;
10868 +
10869 + err = get_user(sethi, (unsigned int *)regs->tpc);
10870 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10871 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10872 +
10873 + if (err)
10874 + break;
10875 +
10876 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10877 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10878 + nop == 0x01000000U)
10879 + {
10880 + unsigned long addr;
10881 +
10882 + addr = (sethi & 0x003FFFFFU) << 10;
10883 + regs->u_regs[UREG_G1] = addr;
10884 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10885 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10886 + else
10887 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10888 +
10889 + if (test_thread_flag(TIF_32BIT))
10890 + addr &= 0xFFFFFFFFUL;
10891 +
10892 + regs->tpc = addr;
10893 + regs->tnpc = addr+4;
10894 + return 2;
10895 + }
10896 + } while (0);
10897 +
10898 + do { /* PaX: patched PLT emulation #4 */
10899 + unsigned int sethi, mov1, call, mov2;
10900 +
10901 + err = get_user(sethi, (unsigned int *)regs->tpc);
10902 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10903 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10904 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10905 +
10906 + if (err)
10907 + break;
10908 +
10909 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10910 + mov1 == 0x8210000FU &&
10911 + (call & 0xC0000000U) == 0x40000000U &&
10912 + mov2 == 0x9E100001U)
10913 + {
10914 + unsigned long addr;
10915 +
10916 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10917 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10918 +
10919 + if (test_thread_flag(TIF_32BIT))
10920 + addr &= 0xFFFFFFFFUL;
10921 +
10922 + regs->tpc = addr;
10923 + regs->tnpc = addr+4;
10924 + return 2;
10925 + }
10926 + } while (0);
10927 +
10928 + do { /* PaX: patched PLT emulation #5 */
10929 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10930 +
10931 + err = get_user(sethi, (unsigned int *)regs->tpc);
10932 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10933 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10934 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10935 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10936 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10937 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10938 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10939 +
10940 + if (err)
10941 + break;
10942 +
10943 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10944 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10945 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10946 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10947 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10948 + sllx == 0x83287020U &&
10949 + jmpl == 0x81C04005U &&
10950 + nop == 0x01000000U)
10951 + {
10952 + unsigned long addr;
10953 +
10954 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10955 + regs->u_regs[UREG_G1] <<= 32;
10956 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10957 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10958 + regs->tpc = addr;
10959 + regs->tnpc = addr+4;
10960 + return 2;
10961 + }
10962 + } while (0);
10963 +
10964 + do { /* PaX: patched PLT emulation #6 */
10965 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10966 +
10967 + err = get_user(sethi, (unsigned int *)regs->tpc);
10968 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10969 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10970 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10971 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10972 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10973 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10974 +
10975 + if (err)
10976 + break;
10977 +
10978 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10979 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10980 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10981 + sllx == 0x83287020U &&
10982 + (or & 0xFFFFE000U) == 0x8A116000U &&
10983 + jmpl == 0x81C04005U &&
10984 + nop == 0x01000000U)
10985 + {
10986 + unsigned long addr;
10987 +
10988 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10989 + regs->u_regs[UREG_G1] <<= 32;
10990 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10991 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10992 + regs->tpc = addr;
10993 + regs->tnpc = addr+4;
10994 + return 2;
10995 + }
10996 + } while (0);
10997 +
10998 + do { /* PaX: unpatched PLT emulation step 1 */
10999 + unsigned int sethi, ba, nop;
11000 +
11001 + err = get_user(sethi, (unsigned int *)regs->tpc);
11002 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11003 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11004 +
11005 + if (err)
11006 + break;
11007 +
11008 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11009 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11010 + nop == 0x01000000U)
11011 + {
11012 + unsigned long addr;
11013 + unsigned int save, call;
11014 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11015 +
11016 + if ((ba & 0xFFC00000U) == 0x30800000U)
11017 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11018 + else
11019 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11020 +
11021 + if (test_thread_flag(TIF_32BIT))
11022 + addr &= 0xFFFFFFFFUL;
11023 +
11024 + err = get_user(save, (unsigned int *)addr);
11025 + err |= get_user(call, (unsigned int *)(addr+4));
11026 + err |= get_user(nop, (unsigned int *)(addr+8));
11027 + if (err)
11028 + break;
11029 +
11030 +#ifdef CONFIG_PAX_DLRESOLVE
11031 + if (save == 0x9DE3BFA8U &&
11032 + (call & 0xC0000000U) == 0x40000000U &&
11033 + nop == 0x01000000U)
11034 + {
11035 + struct vm_area_struct *vma;
11036 + unsigned long call_dl_resolve;
11037 +
11038 + down_read(&current->mm->mmap_sem);
11039 + call_dl_resolve = current->mm->call_dl_resolve;
11040 + up_read(&current->mm->mmap_sem);
11041 + if (likely(call_dl_resolve))
11042 + goto emulate;
11043 +
11044 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11045 +
11046 + down_write(&current->mm->mmap_sem);
11047 + if (current->mm->call_dl_resolve) {
11048 + call_dl_resolve = current->mm->call_dl_resolve;
11049 + up_write(&current->mm->mmap_sem);
11050 + if (vma)
11051 + kmem_cache_free(vm_area_cachep, vma);
11052 + goto emulate;
11053 + }
11054 +
11055 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11056 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11057 + up_write(&current->mm->mmap_sem);
11058 + if (vma)
11059 + kmem_cache_free(vm_area_cachep, vma);
11060 + return 1;
11061 + }
11062 +
11063 + if (pax_insert_vma(vma, call_dl_resolve)) {
11064 + up_write(&current->mm->mmap_sem);
11065 + kmem_cache_free(vm_area_cachep, vma);
11066 + return 1;
11067 + }
11068 +
11069 + current->mm->call_dl_resolve = call_dl_resolve;
11070 + up_write(&current->mm->mmap_sem);
11071 +
11072 +emulate:
11073 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11074 + regs->tpc = call_dl_resolve;
11075 + regs->tnpc = addr+4;
11076 + return 3;
11077 + }
11078 +#endif
11079 +
11080 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11081 + if ((save & 0xFFC00000U) == 0x05000000U &&
11082 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11083 + nop == 0x01000000U)
11084 + {
11085 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11086 + regs->u_regs[UREG_G2] = addr + 4;
11087 + addr = (save & 0x003FFFFFU) << 10;
11088 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11089 +
11090 + if (test_thread_flag(TIF_32BIT))
11091 + addr &= 0xFFFFFFFFUL;
11092 +
11093 + regs->tpc = addr;
11094 + regs->tnpc = addr+4;
11095 + return 3;
11096 + }
11097 +
11098 + /* PaX: 64-bit PLT stub */
11099 + err = get_user(sethi1, (unsigned int *)addr);
11100 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11101 + err |= get_user(or1, (unsigned int *)(addr+8));
11102 + err |= get_user(or2, (unsigned int *)(addr+12));
11103 + err |= get_user(sllx, (unsigned int *)(addr+16));
11104 + err |= get_user(add, (unsigned int *)(addr+20));
11105 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11106 + err |= get_user(nop, (unsigned int *)(addr+28));
11107 + if (err)
11108 + break;
11109 +
11110 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11111 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11112 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11113 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11114 + sllx == 0x89293020U &&
11115 + add == 0x8A010005U &&
11116 + jmpl == 0x89C14000U &&
11117 + nop == 0x01000000U)
11118 + {
11119 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11120 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11121 + regs->u_regs[UREG_G4] <<= 32;
11122 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11123 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11124 + regs->u_regs[UREG_G4] = addr + 24;
11125 + addr = regs->u_regs[UREG_G5];
11126 + regs->tpc = addr;
11127 + regs->tnpc = addr+4;
11128 + return 3;
11129 + }
11130 + }
11131 + } while (0);
11132 +
11133 +#ifdef CONFIG_PAX_DLRESOLVE
11134 + do { /* PaX: unpatched PLT emulation step 2 */
11135 + unsigned int save, call, nop;
11136 +
11137 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11138 + err |= get_user(call, (unsigned int *)regs->tpc);
11139 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11140 + if (err)
11141 + break;
11142 +
11143 + if (save == 0x9DE3BFA8U &&
11144 + (call & 0xC0000000U) == 0x40000000U &&
11145 + nop == 0x01000000U)
11146 + {
11147 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11148 +
11149 + if (test_thread_flag(TIF_32BIT))
11150 + dl_resolve &= 0xFFFFFFFFUL;
11151 +
11152 + regs->u_regs[UREG_RETPC] = regs->tpc;
11153 + regs->tpc = dl_resolve;
11154 + regs->tnpc = dl_resolve+4;
11155 + return 3;
11156 + }
11157 + } while (0);
11158 +#endif
11159 +
11160 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11161 + unsigned int sethi, ba, nop;
11162 +
11163 + err = get_user(sethi, (unsigned int *)regs->tpc);
11164 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11165 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11166 +
11167 + if (err)
11168 + break;
11169 +
11170 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11171 + (ba & 0xFFF00000U) == 0x30600000U &&
11172 + nop == 0x01000000U)
11173 + {
11174 + unsigned long addr;
11175 +
11176 + addr = (sethi & 0x003FFFFFU) << 10;
11177 + regs->u_regs[UREG_G1] = addr;
11178 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11179 +
11180 + if (test_thread_flag(TIF_32BIT))
11181 + addr &= 0xFFFFFFFFUL;
11182 +
11183 + regs->tpc = addr;
11184 + regs->tnpc = addr+4;
11185 + return 2;
11186 + }
11187 + } while (0);
11188 +
11189 +#endif
11190 +
11191 + return 1;
11192 +}
11193 +
11194 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11195 +{
11196 + unsigned long i;
11197 +
11198 + printk(KERN_ERR "PAX: bytes at PC: ");
11199 + for (i = 0; i < 8; i++) {
11200 + unsigned int c;
11201 + if (get_user(c, (unsigned int *)pc+i))
11202 + printk(KERN_CONT "???????? ");
11203 + else
11204 + printk(KERN_CONT "%08x ", c);
11205 + }
11206 + printk("\n");
11207 +}
11208 +#endif
11209 +
11210 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11211 {
11212 struct mm_struct *mm = current->mm;
11213 @@ -341,6 +804,29 @@ retry:
11214 if (!vma)
11215 goto bad_area;
11216
11217 +#ifdef CONFIG_PAX_PAGEEXEC
11218 + /* PaX: detect ITLB misses on non-exec pages */
11219 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11220 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11221 + {
11222 + if (address != regs->tpc)
11223 + goto good_area;
11224 +
11225 + up_read(&mm->mmap_sem);
11226 + switch (pax_handle_fetch_fault(regs)) {
11227 +
11228 +#ifdef CONFIG_PAX_EMUPLT
11229 + case 2:
11230 + case 3:
11231 + return;
11232 +#endif
11233 +
11234 + }
11235 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11236 + do_group_exit(SIGKILL);
11237 + }
11238 +#endif
11239 +
11240 /* Pure DTLB misses do not tell us whether the fault causing
11241 * load/store/atomic was a write or not, it only says that there
11242 * was no match. So in such a case we (carefully) read the
11243 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11244 index d2b5944..d878f3c 100644
11245 --- a/arch/sparc/mm/hugetlbpage.c
11246 +++ b/arch/sparc/mm/hugetlbpage.c
11247 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11248 unsigned long addr,
11249 unsigned long len,
11250 unsigned long pgoff,
11251 - unsigned long flags)
11252 + unsigned long flags,
11253 + unsigned long offset)
11254 {
11255 unsigned long task_size = TASK_SIZE;
11256 struct vm_unmapped_area_info info;
11257 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11258
11259 info.flags = 0;
11260 info.length = len;
11261 - info.low_limit = TASK_UNMAPPED_BASE;
11262 + info.low_limit = mm->mmap_base;
11263 info.high_limit = min(task_size, VA_EXCLUDE_START);
11264 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11265 info.align_offset = 0;
11266 + info.threadstack_offset = offset;
11267 addr = vm_unmapped_area(&info);
11268
11269 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11270 VM_BUG_ON(addr != -ENOMEM);
11271 info.low_limit = VA_EXCLUDE_END;
11272 +
11273 +#ifdef CONFIG_PAX_RANDMMAP
11274 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11275 + info.low_limit += mm->delta_mmap;
11276 +#endif
11277 +
11278 info.high_limit = task_size;
11279 addr = vm_unmapped_area(&info);
11280 }
11281 @@ -58,7 +66,8 @@ static unsigned long
11282 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11283 const unsigned long len,
11284 const unsigned long pgoff,
11285 - const unsigned long flags)
11286 + const unsigned long flags,
11287 + const unsigned long offset)
11288 {
11289 struct mm_struct *mm = current->mm;
11290 unsigned long addr = addr0;
11291 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11292 info.high_limit = mm->mmap_base;
11293 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11294 info.align_offset = 0;
11295 + info.threadstack_offset = offset;
11296 addr = vm_unmapped_area(&info);
11297
11298 /*
11299 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11300 VM_BUG_ON(addr != -ENOMEM);
11301 info.flags = 0;
11302 info.low_limit = TASK_UNMAPPED_BASE;
11303 +
11304 +#ifdef CONFIG_PAX_RANDMMAP
11305 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11306 + info.low_limit += mm->delta_mmap;
11307 +#endif
11308 +
11309 info.high_limit = STACK_TOP32;
11310 addr = vm_unmapped_area(&info);
11311 }
11312 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11313 struct mm_struct *mm = current->mm;
11314 struct vm_area_struct *vma;
11315 unsigned long task_size = TASK_SIZE;
11316 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11317
11318 if (test_thread_flag(TIF_32BIT))
11319 task_size = STACK_TOP32;
11320 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11321 return addr;
11322 }
11323
11324 +#ifdef CONFIG_PAX_RANDMMAP
11325 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11326 +#endif
11327 +
11328 if (addr) {
11329 addr = ALIGN(addr, HPAGE_SIZE);
11330 vma = find_vma(mm, addr);
11331 - if (task_size - len >= addr &&
11332 - (!vma || addr + len <= vma->vm_start))
11333 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11334 return addr;
11335 }
11336 if (mm->get_unmapped_area == arch_get_unmapped_area)
11337 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11338 - pgoff, flags);
11339 + pgoff, flags, offset);
11340 else
11341 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11342 - pgoff, flags);
11343 + pgoff, flags, offset);
11344 }
11345
11346 pte_t *huge_pte_alloc(struct mm_struct *mm,
11347 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11348 index ed82eda..0d80e77 100644
11349 --- a/arch/sparc/mm/init_64.c
11350 +++ b/arch/sparc/mm/init_64.c
11351 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11352 int num_kernel_image_mappings;
11353
11354 #ifdef CONFIG_DEBUG_DCFLUSH
11355 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11356 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11357 #ifdef CONFIG_SMP
11358 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11359 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11360 #endif
11361 #endif
11362
11363 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11364 {
11365 BUG_ON(tlb_type == hypervisor);
11366 #ifdef CONFIG_DEBUG_DCFLUSH
11367 - atomic_inc(&dcpage_flushes);
11368 + atomic_inc_unchecked(&dcpage_flushes);
11369 #endif
11370
11371 #ifdef DCACHE_ALIASING_POSSIBLE
11372 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11373
11374 #ifdef CONFIG_DEBUG_DCFLUSH
11375 seq_printf(m, "DCPageFlushes\t: %d\n",
11376 - atomic_read(&dcpage_flushes));
11377 + atomic_read_unchecked(&dcpage_flushes));
11378 #ifdef CONFIG_SMP
11379 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11380 - atomic_read(&dcpage_flushes_xcall));
11381 + atomic_read_unchecked(&dcpage_flushes_xcall));
11382 #endif /* CONFIG_SMP */
11383 #endif /* CONFIG_DEBUG_DCFLUSH */
11384 }
11385 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11386 index f4500c6..889656c 100644
11387 --- a/arch/tile/include/asm/atomic_64.h
11388 +++ b/arch/tile/include/asm/atomic_64.h
11389 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11390
11391 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11392
11393 +#define atomic64_read_unchecked(v) atomic64_read(v)
11394 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11395 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11396 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11397 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11398 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11399 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11400 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11401 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11402 +
11403 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11404 #define smp_mb__before_atomic_dec() smp_mb()
11405 #define smp_mb__after_atomic_dec() smp_mb()
11406 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11407 index a9a5299..0fce79e 100644
11408 --- a/arch/tile/include/asm/cache.h
11409 +++ b/arch/tile/include/asm/cache.h
11410 @@ -15,11 +15,12 @@
11411 #ifndef _ASM_TILE_CACHE_H
11412 #define _ASM_TILE_CACHE_H
11413
11414 +#include <linux/const.h>
11415 #include <arch/chip.h>
11416
11417 /* bytes per L1 data cache line */
11418 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11419 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11420 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11421
11422 /* bytes per L2 cache line */
11423 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11424 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11425 index e4d44bd..99927a3 100644
11426 --- a/arch/tile/include/asm/uaccess.h
11427 +++ b/arch/tile/include/asm/uaccess.h
11428 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11429 const void __user *from,
11430 unsigned long n)
11431 {
11432 - int sz = __compiletime_object_size(to);
11433 + size_t sz = __compiletime_object_size(to);
11434
11435 - if (likely(sz == -1 || sz >= n))
11436 + if (likely(sz == (size_t)-1 || sz >= n))
11437 n = _copy_from_user(to, from, n);
11438 else
11439 copy_from_user_overflow();
11440 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11441 index 650ccff..45fe2d6 100644
11442 --- a/arch/tile/mm/hugetlbpage.c
11443 +++ b/arch/tile/mm/hugetlbpage.c
11444 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11445 info.high_limit = TASK_SIZE;
11446 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11447 info.align_offset = 0;
11448 + info.threadstack_offset = 0;
11449 return vm_unmapped_area(&info);
11450 }
11451
11452 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11453 info.high_limit = current->mm->mmap_base;
11454 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11455 info.align_offset = 0;
11456 + info.threadstack_offset = 0;
11457 addr = vm_unmapped_area(&info);
11458
11459 /*
11460 diff --git a/arch/um/Makefile b/arch/um/Makefile
11461 index 133f7de..1d6f2f1 100644
11462 --- a/arch/um/Makefile
11463 +++ b/arch/um/Makefile
11464 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11465 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11466 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11467
11468 +ifdef CONSTIFY_PLUGIN
11469 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11470 +endif
11471 +
11472 #This will adjust *FLAGS accordingly to the platform.
11473 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11474
11475 diff --git a/arch/um/defconfig b/arch/um/defconfig
11476 index 08107a7..ab22afe 100644
11477 --- a/arch/um/defconfig
11478 +++ b/arch/um/defconfig
11479 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11480 CONFIG_X86_L1_CACHE_SHIFT=5
11481 CONFIG_X86_XADD=y
11482 CONFIG_X86_PPRO_FENCE=y
11483 -CONFIG_X86_WP_WORKS_OK=y
11484 CONFIG_X86_INVLPG=y
11485 CONFIG_X86_BSWAP=y
11486 CONFIG_X86_POPAD_OK=y
11487 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11488 index 19e1bdd..3665b77 100644
11489 --- a/arch/um/include/asm/cache.h
11490 +++ b/arch/um/include/asm/cache.h
11491 @@ -1,6 +1,7 @@
11492 #ifndef __UM_CACHE_H
11493 #define __UM_CACHE_H
11494
11495 +#include <linux/const.h>
11496
11497 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11498 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11499 @@ -12,6 +13,6 @@
11500 # define L1_CACHE_SHIFT 5
11501 #endif
11502
11503 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11504 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11505
11506 #endif
11507 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11508 index 2e0a6b1..a64d0f5 100644
11509 --- a/arch/um/include/asm/kmap_types.h
11510 +++ b/arch/um/include/asm/kmap_types.h
11511 @@ -8,6 +8,6 @@
11512
11513 /* No more #include "asm/arch/kmap_types.h" ! */
11514
11515 -#define KM_TYPE_NR 14
11516 +#define KM_TYPE_NR 15
11517
11518 #endif
11519 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11520 index 5ff53d9..5850cdf 100644
11521 --- a/arch/um/include/asm/page.h
11522 +++ b/arch/um/include/asm/page.h
11523 @@ -14,6 +14,9 @@
11524 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11525 #define PAGE_MASK (~(PAGE_SIZE-1))
11526
11527 +#define ktla_ktva(addr) (addr)
11528 +#define ktva_ktla(addr) (addr)
11529 +
11530 #ifndef __ASSEMBLY__
11531
11532 struct page;
11533 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11534 index 0032f92..cd151e0 100644
11535 --- a/arch/um/include/asm/pgtable-3level.h
11536 +++ b/arch/um/include/asm/pgtable-3level.h
11537 @@ -58,6 +58,7 @@
11538 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11539 #define pud_populate(mm, pud, pmd) \
11540 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11541 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11542
11543 #ifdef CONFIG_64BIT
11544 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11545 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11546 index bbcef52..6a2a483 100644
11547 --- a/arch/um/kernel/process.c
11548 +++ b/arch/um/kernel/process.c
11549 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11550 return 2;
11551 }
11552
11553 -/*
11554 - * Only x86 and x86_64 have an arch_align_stack().
11555 - * All other arches have "#define arch_align_stack(x) (x)"
11556 - * in their asm/system.h
11557 - * As this is included in UML from asm-um/system-generic.h,
11558 - * we can use it to behave as the subarch does.
11559 - */
11560 -#ifndef arch_align_stack
11561 -unsigned long arch_align_stack(unsigned long sp)
11562 -{
11563 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11564 - sp -= get_random_int() % 8192;
11565 - return sp & ~0xf;
11566 -}
11567 -#endif
11568 -
11569 unsigned long get_wchan(struct task_struct *p)
11570 {
11571 unsigned long stack_page, sp, ip;
11572 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11573 index ad8f795..2c7eec6 100644
11574 --- a/arch/unicore32/include/asm/cache.h
11575 +++ b/arch/unicore32/include/asm/cache.h
11576 @@ -12,8 +12,10 @@
11577 #ifndef __UNICORE_CACHE_H__
11578 #define __UNICORE_CACHE_H__
11579
11580 -#define L1_CACHE_SHIFT (5)
11581 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11582 +#include <linux/const.h>
11583 +
11584 +#define L1_CACHE_SHIFT 5
11585 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11586
11587 /*
11588 * Memory returned by kmalloc() may be used for DMA, so we must make
11589 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11590 index b32ebf9..5704f98 100644
11591 --- a/arch/x86/Kconfig
11592 +++ b/arch/x86/Kconfig
11593 @@ -248,7 +248,7 @@ config X86_HT
11594
11595 config X86_32_LAZY_GS
11596 def_bool y
11597 - depends on X86_32 && !CC_STACKPROTECTOR
11598 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11599
11600 config ARCH_HWEIGHT_CFLAGS
11601 string
11602 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11603
11604 config X86_MSR
11605 tristate "/dev/cpu/*/msr - Model-specific register support"
11606 + depends on !GRKERNSEC_KMEM
11607 ---help---
11608 This device gives privileged processes access to the x86
11609 Model-Specific Registers (MSRs). It is a character device with
11610 @@ -1111,7 +1112,7 @@ choice
11611
11612 config NOHIGHMEM
11613 bool "off"
11614 - depends on !X86_NUMAQ
11615 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11616 ---help---
11617 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11618 However, the address space of 32-bit x86 processors is only 4
11619 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11620
11621 config HIGHMEM4G
11622 bool "4GB"
11623 - depends on !X86_NUMAQ
11624 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11625 ---help---
11626 Select this if you have a 32-bit processor and between 1 and 4
11627 gigabytes of physical RAM.
11628 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11629 hex
11630 default 0xB0000000 if VMSPLIT_3G_OPT
11631 default 0x80000000 if VMSPLIT_2G
11632 - default 0x78000000 if VMSPLIT_2G_OPT
11633 + default 0x70000000 if VMSPLIT_2G_OPT
11634 default 0x40000000 if VMSPLIT_1G
11635 default 0xC0000000
11636 depends on X86_32
11637 @@ -1599,6 +1600,7 @@ config SECCOMP
11638
11639 config CC_STACKPROTECTOR
11640 bool "Enable -fstack-protector buffer overflow detection"
11641 + depends on X86_64 || !PAX_MEMORY_UDEREF
11642 ---help---
11643 This option turns on the -fstack-protector GCC feature. This
11644 feature puts, at the beginning of functions, a canary value on
11645 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11646 config PHYSICAL_ALIGN
11647 hex "Alignment value to which kernel should be aligned" if X86_32
11648 default "0x1000000"
11649 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11650 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11651 range 0x2000 0x1000000
11652 ---help---
11653 This value puts the alignment restrictions on physical address
11654 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11655 If unsure, say N.
11656
11657 config COMPAT_VDSO
11658 - def_bool y
11659 + def_bool n
11660 prompt "Compat VDSO support"
11661 depends on X86_32 || IA32_EMULATION
11662 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11663 ---help---
11664 Map the 32-bit VDSO to the predictable old-style address too.
11665
11666 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11667 index c026cca..14657ae 100644
11668 --- a/arch/x86/Kconfig.cpu
11669 +++ b/arch/x86/Kconfig.cpu
11670 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11671
11672 config X86_F00F_BUG
11673 def_bool y
11674 - depends on M586MMX || M586TSC || M586 || M486
11675 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11676
11677 config X86_INVD_BUG
11678 def_bool y
11679 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11680
11681 config X86_ALIGNMENT_16
11682 def_bool y
11683 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11684 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11685
11686 config X86_INTEL_USERCOPY
11687 def_bool y
11688 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11689 # generates cmov.
11690 config X86_CMOV
11691 def_bool y
11692 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11693 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11694
11695 config X86_MINIMUM_CPU_FAMILY
11696 int
11697 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11698 index 78d91af..8ceb94b 100644
11699 --- a/arch/x86/Kconfig.debug
11700 +++ b/arch/x86/Kconfig.debug
11701 @@ -74,7 +74,7 @@ config X86_PTDUMP
11702 config DEBUG_RODATA
11703 bool "Write protect kernel read-only data structures"
11704 default y
11705 - depends on DEBUG_KERNEL
11706 + depends on DEBUG_KERNEL && BROKEN
11707 ---help---
11708 Mark the kernel read-only data as write-protected in the pagetables,
11709 in order to catch accidental (and incorrect) writes to such const
11710 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11711
11712 config DEBUG_SET_MODULE_RONX
11713 bool "Set loadable kernel module data as NX and text as RO"
11714 - depends on MODULES
11715 + depends on MODULES && BROKEN
11716 ---help---
11717 This option helps catch unintended modifications to loadable
11718 kernel module's text and read-only data. It also prevents execution
11719 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11720 index 07639c6..6f2c901 100644
11721 --- a/arch/x86/Makefile
11722 +++ b/arch/x86/Makefile
11723 @@ -54,6 +54,7 @@ else
11724 UTS_MACHINE := x86_64
11725 CHECKFLAGS += -D__x86_64__ -m64
11726
11727 + biarch := $(call cc-option,-m64)
11728 KBUILD_AFLAGS += -m64
11729 KBUILD_CFLAGS += -m64
11730
11731 @@ -241,3 +242,12 @@ define archhelp
11732 echo ' FDINITRD=file initrd for the booted kernel'
11733 echo ' kvmconfig - Enable additional options for guest kernel support'
11734 endef
11735 +
11736 +define OLD_LD
11737 +
11738 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11739 +*** Please upgrade your binutils to 2.18 or newer
11740 +endef
11741 +
11742 +archprepare:
11743 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11744 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11745 index 379814b..add62ce 100644
11746 --- a/arch/x86/boot/Makefile
11747 +++ b/arch/x86/boot/Makefile
11748 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11749 $(call cc-option, -fno-stack-protector) \
11750 $(call cc-option, -mpreferred-stack-boundary=2)
11751 KBUILD_CFLAGS += $(call cc-option, -m32)
11752 +ifdef CONSTIFY_PLUGIN
11753 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11754 +endif
11755 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11756 GCOV_PROFILE := n
11757
11758 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11759 index 878e4b9..20537ab 100644
11760 --- a/arch/x86/boot/bitops.h
11761 +++ b/arch/x86/boot/bitops.h
11762 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11763 u8 v;
11764 const u32 *p = (const u32 *)addr;
11765
11766 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11767 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11768 return v;
11769 }
11770
11771 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11772
11773 static inline void set_bit(int nr, void *addr)
11774 {
11775 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11776 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11777 }
11778
11779 #endif /* BOOT_BITOPS_H */
11780 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11781 index 5b75319..331a4ca 100644
11782 --- a/arch/x86/boot/boot.h
11783 +++ b/arch/x86/boot/boot.h
11784 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11785 static inline u16 ds(void)
11786 {
11787 u16 seg;
11788 - asm("movw %%ds,%0" : "=rm" (seg));
11789 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11790 return seg;
11791 }
11792
11793 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11794 static inline int memcmp(const void *s1, const void *s2, size_t len)
11795 {
11796 u8 diff;
11797 - asm("repe; cmpsb; setnz %0"
11798 + asm volatile("repe; cmpsb; setnz %0"
11799 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11800 return diff;
11801 }
11802 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11803 index dcd90df..c830d7d 100644
11804 --- a/arch/x86/boot/compressed/Makefile
11805 +++ b/arch/x86/boot/compressed/Makefile
11806 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11807 KBUILD_CFLAGS += $(cflags-y)
11808 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11809 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11810 +ifdef CONSTIFY_PLUGIN
11811 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11812 +endif
11813
11814 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11815 GCOV_PROFILE := n
11816 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11817 index b7388a4..03844ec 100644
11818 --- a/arch/x86/boot/compressed/eboot.c
11819 +++ b/arch/x86/boot/compressed/eboot.c
11820 @@ -150,7 +150,6 @@ again:
11821 *addr = max_addr;
11822 }
11823
11824 -free_pool:
11825 efi_call_phys1(sys_table->boottime->free_pool, map);
11826
11827 fail:
11828 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11829 if (i == map_size / desc_size)
11830 status = EFI_NOT_FOUND;
11831
11832 -free_pool:
11833 efi_call_phys1(sys_table->boottime->free_pool, map);
11834 fail:
11835 return status;
11836 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11837 index a53440e..c3dbf1e 100644
11838 --- a/arch/x86/boot/compressed/efi_stub_32.S
11839 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11840 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11841 * parameter 2, ..., param n. To make things easy, we save the return
11842 * address of efi_call_phys in a global variable.
11843 */
11844 - popl %ecx
11845 - movl %ecx, saved_return_addr(%edx)
11846 - /* get the function pointer into ECX*/
11847 - popl %ecx
11848 - movl %ecx, efi_rt_function_ptr(%edx)
11849 + popl saved_return_addr(%edx)
11850 + popl efi_rt_function_ptr(%edx)
11851
11852 /*
11853 * 3. Call the physical function.
11854 */
11855 - call *%ecx
11856 + call *efi_rt_function_ptr(%edx)
11857
11858 /*
11859 * 4. Balance the stack. And because EAX contain the return value,
11860 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11861 1: popl %edx
11862 subl $1b, %edx
11863
11864 - movl efi_rt_function_ptr(%edx), %ecx
11865 - pushl %ecx
11866 + pushl efi_rt_function_ptr(%edx)
11867
11868 /*
11869 * 10. Push the saved return address onto the stack and return.
11870 */
11871 - movl saved_return_addr(%edx), %ecx
11872 - pushl %ecx
11873 - ret
11874 + jmpl *saved_return_addr(%edx)
11875 ENDPROC(efi_call_phys)
11876 .previous
11877
11878 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11879 index 1e3184f..0d11e2e 100644
11880 --- a/arch/x86/boot/compressed/head_32.S
11881 +++ b/arch/x86/boot/compressed/head_32.S
11882 @@ -118,7 +118,7 @@ preferred_addr:
11883 notl %eax
11884 andl %eax, %ebx
11885 #else
11886 - movl $LOAD_PHYSICAL_ADDR, %ebx
11887 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11888 #endif
11889
11890 /* Target address to relocate to for decompression */
11891 @@ -204,7 +204,7 @@ relocated:
11892 * and where it was actually loaded.
11893 */
11894 movl %ebp, %ebx
11895 - subl $LOAD_PHYSICAL_ADDR, %ebx
11896 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11897 jz 2f /* Nothing to be done if loaded at compiled addr. */
11898 /*
11899 * Process relocations.
11900 @@ -212,8 +212,7 @@ relocated:
11901
11902 1: subl $4, %edi
11903 movl (%edi), %ecx
11904 - testl %ecx, %ecx
11905 - jz 2f
11906 + jecxz 2f
11907 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11908 jmp 1b
11909 2:
11910 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11911 index 06e71c2..88a98264 100644
11912 --- a/arch/x86/boot/compressed/head_64.S
11913 +++ b/arch/x86/boot/compressed/head_64.S
11914 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11915 notl %eax
11916 andl %eax, %ebx
11917 #else
11918 - movl $LOAD_PHYSICAL_ADDR, %ebx
11919 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11920 #endif
11921
11922 /* Target address to relocate to for decompression */
11923 @@ -270,7 +270,7 @@ preferred_addr:
11924 notq %rax
11925 andq %rax, %rbp
11926 #else
11927 - movq $LOAD_PHYSICAL_ADDR, %rbp
11928 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11929 #endif
11930
11931 /* Target address to relocate to for decompression */
11932 @@ -361,8 +361,8 @@ gdt:
11933 .long gdt
11934 .word 0
11935 .quad 0x0000000000000000 /* NULL descriptor */
11936 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11937 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11938 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11939 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11940 .quad 0x0080890000000000 /* TS descriptor */
11941 .quad 0x0000000000000000 /* TS continued */
11942 gdt_end:
11943 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11944 index 0319c88..7c1931f 100644
11945 --- a/arch/x86/boot/compressed/misc.c
11946 +++ b/arch/x86/boot/compressed/misc.c
11947 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11948 case PT_LOAD:
11949 #ifdef CONFIG_RELOCATABLE
11950 dest = output;
11951 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11952 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11953 #else
11954 dest = (void *)(phdr->p_paddr);
11955 #endif
11956 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11957 error("Destination address too large");
11958 #endif
11959 #ifndef CONFIG_RELOCATABLE
11960 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11961 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11962 error("Wrong destination address");
11963 #endif
11964
11965 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11966 index 4d3ff03..e4972ff 100644
11967 --- a/arch/x86/boot/cpucheck.c
11968 +++ b/arch/x86/boot/cpucheck.c
11969 @@ -74,7 +74,7 @@ static int has_fpu(void)
11970 u16 fcw = -1, fsw = -1;
11971 u32 cr0;
11972
11973 - asm("movl %%cr0,%0" : "=r" (cr0));
11974 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11975 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11976 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11977 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11978 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11979 {
11980 u32 f0, f1;
11981
11982 - asm("pushfl ; "
11983 + asm volatile("pushfl ; "
11984 "pushfl ; "
11985 "popl %0 ; "
11986 "movl %0,%1 ; "
11987 @@ -115,7 +115,7 @@ static void get_flags(void)
11988 set_bit(X86_FEATURE_FPU, cpu.flags);
11989
11990 if (has_eflag(X86_EFLAGS_ID)) {
11991 - asm("cpuid"
11992 + asm volatile("cpuid"
11993 : "=a" (max_intel_level),
11994 "=b" (cpu_vendor[0]),
11995 "=d" (cpu_vendor[1]),
11996 @@ -124,7 +124,7 @@ static void get_flags(void)
11997
11998 if (max_intel_level >= 0x00000001 &&
11999 max_intel_level <= 0x0000ffff) {
12000 - asm("cpuid"
12001 + asm volatile("cpuid"
12002 : "=a" (tfms),
12003 "=c" (cpu.flags[4]),
12004 "=d" (cpu.flags[0])
12005 @@ -136,7 +136,7 @@ static void get_flags(void)
12006 cpu.model += ((tfms >> 16) & 0xf) << 4;
12007 }
12008
12009 - asm("cpuid"
12010 + asm volatile("cpuid"
12011 : "=a" (max_amd_level)
12012 : "a" (0x80000000)
12013 : "ebx", "ecx", "edx");
12014 @@ -144,7 +144,7 @@ static void get_flags(void)
12015 if (max_amd_level >= 0x80000001 &&
12016 max_amd_level <= 0x8000ffff) {
12017 u32 eax = 0x80000001;
12018 - asm("cpuid"
12019 + asm volatile("cpuid"
12020 : "+a" (eax),
12021 "=c" (cpu.flags[6]),
12022 "=d" (cpu.flags[1])
12023 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12024 u32 ecx = MSR_K7_HWCR;
12025 u32 eax, edx;
12026
12027 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12028 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12029 eax &= ~(1 << 15);
12030 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12031 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12032
12033 get_flags(); /* Make sure it really did something */
12034 err = check_flags();
12035 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12036 u32 ecx = MSR_VIA_FCR;
12037 u32 eax, edx;
12038
12039 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12040 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12041 eax |= (1<<1)|(1<<7);
12042 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12043 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12044
12045 set_bit(X86_FEATURE_CX8, cpu.flags);
12046 err = check_flags();
12047 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12048 u32 eax, edx;
12049 u32 level = 1;
12050
12051 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12052 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12053 - asm("cpuid"
12054 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12055 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12056 + asm volatile("cpuid"
12057 : "+a" (level), "=d" (cpu.flags[0])
12058 : : "ecx", "ebx");
12059 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12060 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12061
12062 err = check_flags();
12063 }
12064 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12065 index 9ec06a1..2c25e79 100644
12066 --- a/arch/x86/boot/header.S
12067 +++ b/arch/x86/boot/header.S
12068 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12069 # single linked list of
12070 # struct setup_data
12071
12072 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12073 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12074
12075 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12076 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12077 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12078 +#else
12079 #define VO_INIT_SIZE (VO__end - VO__text)
12080 +#endif
12081 #if ZO_INIT_SIZE > VO_INIT_SIZE
12082 #define INIT_SIZE ZO_INIT_SIZE
12083 #else
12084 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12085 index db75d07..8e6d0af 100644
12086 --- a/arch/x86/boot/memory.c
12087 +++ b/arch/x86/boot/memory.c
12088 @@ -19,7 +19,7 @@
12089
12090 static int detect_memory_e820(void)
12091 {
12092 - int count = 0;
12093 + unsigned int count = 0;
12094 struct biosregs ireg, oreg;
12095 struct e820entry *desc = boot_params.e820_map;
12096 static struct e820entry buf; /* static so it is zeroed */
12097 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12098 index 11e8c6e..fdbb1ed 100644
12099 --- a/arch/x86/boot/video-vesa.c
12100 +++ b/arch/x86/boot/video-vesa.c
12101 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12102
12103 boot_params.screen_info.vesapm_seg = oreg.es;
12104 boot_params.screen_info.vesapm_off = oreg.di;
12105 + boot_params.screen_info.vesapm_size = oreg.cx;
12106 }
12107
12108 /*
12109 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12110 index 43eda28..5ab5fdb 100644
12111 --- a/arch/x86/boot/video.c
12112 +++ b/arch/x86/boot/video.c
12113 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12114 static unsigned int get_entry(void)
12115 {
12116 char entry_buf[4];
12117 - int i, len = 0;
12118 + unsigned int i, len = 0;
12119 int key;
12120 unsigned int v;
12121
12122 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12123 index 9105655..5e37f27 100644
12124 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12125 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12126 @@ -8,6 +8,8 @@
12127 * including this sentence is retained in full.
12128 */
12129
12130 +#include <asm/alternative-asm.h>
12131 +
12132 .extern crypto_ft_tab
12133 .extern crypto_it_tab
12134 .extern crypto_fl_tab
12135 @@ -70,6 +72,8 @@
12136 je B192; \
12137 leaq 32(r9),r9;
12138
12139 +#define ret pax_force_retaddr 0, 1; ret
12140 +
12141 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12142 movq r1,r2; \
12143 movq r3,r4; \
12144 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12145 index 477e9d7..3ab339f 100644
12146 --- a/arch/x86/crypto/aesni-intel_asm.S
12147 +++ b/arch/x86/crypto/aesni-intel_asm.S
12148 @@ -31,6 +31,7 @@
12149
12150 #include <linux/linkage.h>
12151 #include <asm/inst.h>
12152 +#include <asm/alternative-asm.h>
12153
12154 #ifdef __x86_64__
12155 .data
12156 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12157 pop %r14
12158 pop %r13
12159 pop %r12
12160 + pax_force_retaddr 0, 1
12161 ret
12162 ENDPROC(aesni_gcm_dec)
12163
12164 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12165 pop %r14
12166 pop %r13
12167 pop %r12
12168 + pax_force_retaddr 0, 1
12169 ret
12170 ENDPROC(aesni_gcm_enc)
12171
12172 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12173 pxor %xmm1, %xmm0
12174 movaps %xmm0, (TKEYP)
12175 add $0x10, TKEYP
12176 + pax_force_retaddr_bts
12177 ret
12178 ENDPROC(_key_expansion_128)
12179 ENDPROC(_key_expansion_256a)
12180 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12181 shufps $0b01001110, %xmm2, %xmm1
12182 movaps %xmm1, 0x10(TKEYP)
12183 add $0x20, TKEYP
12184 + pax_force_retaddr_bts
12185 ret
12186 ENDPROC(_key_expansion_192a)
12187
12188 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12189
12190 movaps %xmm0, (TKEYP)
12191 add $0x10, TKEYP
12192 + pax_force_retaddr_bts
12193 ret
12194 ENDPROC(_key_expansion_192b)
12195
12196 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12197 pxor %xmm1, %xmm2
12198 movaps %xmm2, (TKEYP)
12199 add $0x10, TKEYP
12200 + pax_force_retaddr_bts
12201 ret
12202 ENDPROC(_key_expansion_256b)
12203
12204 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12205 #ifndef __x86_64__
12206 popl KEYP
12207 #endif
12208 + pax_force_retaddr 0, 1
12209 ret
12210 ENDPROC(aesni_set_key)
12211
12212 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12213 popl KLEN
12214 popl KEYP
12215 #endif
12216 + pax_force_retaddr 0, 1
12217 ret
12218 ENDPROC(aesni_enc)
12219
12220 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12221 AESENC KEY STATE
12222 movaps 0x70(TKEYP), KEY
12223 AESENCLAST KEY STATE
12224 + pax_force_retaddr_bts
12225 ret
12226 ENDPROC(_aesni_enc1)
12227
12228 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12229 AESENCLAST KEY STATE2
12230 AESENCLAST KEY STATE3
12231 AESENCLAST KEY STATE4
12232 + pax_force_retaddr_bts
12233 ret
12234 ENDPROC(_aesni_enc4)
12235
12236 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12237 popl KLEN
12238 popl KEYP
12239 #endif
12240 + pax_force_retaddr 0, 1
12241 ret
12242 ENDPROC(aesni_dec)
12243
12244 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12245 AESDEC KEY STATE
12246 movaps 0x70(TKEYP), KEY
12247 AESDECLAST KEY STATE
12248 + pax_force_retaddr_bts
12249 ret
12250 ENDPROC(_aesni_dec1)
12251
12252 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12253 AESDECLAST KEY STATE2
12254 AESDECLAST KEY STATE3
12255 AESDECLAST KEY STATE4
12256 + pax_force_retaddr_bts
12257 ret
12258 ENDPROC(_aesni_dec4)
12259
12260 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12261 popl KEYP
12262 popl LEN
12263 #endif
12264 + pax_force_retaddr 0, 1
12265 ret
12266 ENDPROC(aesni_ecb_enc)
12267
12268 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12269 popl KEYP
12270 popl LEN
12271 #endif
12272 + pax_force_retaddr 0, 1
12273 ret
12274 ENDPROC(aesni_ecb_dec)
12275
12276 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12277 popl LEN
12278 popl IVP
12279 #endif
12280 + pax_force_retaddr 0, 1
12281 ret
12282 ENDPROC(aesni_cbc_enc)
12283
12284 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12285 popl LEN
12286 popl IVP
12287 #endif
12288 + pax_force_retaddr 0, 1
12289 ret
12290 ENDPROC(aesni_cbc_dec)
12291
12292 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12293 mov $1, TCTR_LOW
12294 MOVQ_R64_XMM TCTR_LOW INC
12295 MOVQ_R64_XMM CTR TCTR_LOW
12296 + pax_force_retaddr_bts
12297 ret
12298 ENDPROC(_aesni_inc_init)
12299
12300 @@ -2579,6 +2598,7 @@ _aesni_inc:
12301 .Linc_low:
12302 movaps CTR, IV
12303 PSHUFB_XMM BSWAP_MASK IV
12304 + pax_force_retaddr_bts
12305 ret
12306 ENDPROC(_aesni_inc)
12307
12308 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12309 .Lctr_enc_ret:
12310 movups IV, (IVP)
12311 .Lctr_enc_just_ret:
12312 + pax_force_retaddr 0, 1
12313 ret
12314 ENDPROC(aesni_ctr_enc)
12315
12316 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12317 pxor INC, STATE4
12318 movdqu STATE4, 0x70(OUTP)
12319
12320 + pax_force_retaddr 0, 1
12321 ret
12322 ENDPROC(aesni_xts_crypt8)
12323
12324 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12325 index 246c670..4d1ed00 100644
12326 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12327 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12328 @@ -21,6 +21,7 @@
12329 */
12330
12331 #include <linux/linkage.h>
12332 +#include <asm/alternative-asm.h>
12333
12334 .file "blowfish-x86_64-asm.S"
12335 .text
12336 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12337 jnz .L__enc_xor;
12338
12339 write_block();
12340 + pax_force_retaddr 0, 1
12341 ret;
12342 .L__enc_xor:
12343 xor_block();
12344 + pax_force_retaddr 0, 1
12345 ret;
12346 ENDPROC(__blowfish_enc_blk)
12347
12348 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12349
12350 movq %r11, %rbp;
12351
12352 + pax_force_retaddr 0, 1
12353 ret;
12354 ENDPROC(blowfish_dec_blk)
12355
12356 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12357
12358 popq %rbx;
12359 popq %rbp;
12360 + pax_force_retaddr 0, 1
12361 ret;
12362
12363 .L__enc_xor4:
12364 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12365
12366 popq %rbx;
12367 popq %rbp;
12368 + pax_force_retaddr 0, 1
12369 ret;
12370 ENDPROC(__blowfish_enc_blk_4way)
12371
12372 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12373 popq %rbx;
12374 popq %rbp;
12375
12376 + pax_force_retaddr 0, 1
12377 ret;
12378 ENDPROC(blowfish_dec_blk_4way)
12379 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12380 index ce71f92..2dd5b1e 100644
12381 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12382 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12383 @@ -16,6 +16,7 @@
12384 */
12385
12386 #include <linux/linkage.h>
12387 +#include <asm/alternative-asm.h>
12388
12389 #define CAMELLIA_TABLE_BYTE_LEN 272
12390
12391 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12392 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12393 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12394 %rcx, (%r9));
12395 + pax_force_retaddr_bts
12396 ret;
12397 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12398
12399 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12400 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12401 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12402 %rax, (%r9));
12403 + pax_force_retaddr_bts
12404 ret;
12405 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12406
12407 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12408 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12409 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12410
12411 + pax_force_retaddr_bts
12412 ret;
12413
12414 .align 8
12415 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12416 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12417 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12418
12419 + pax_force_retaddr_bts
12420 ret;
12421
12422 .align 8
12423 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12424 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12425 %xmm8, %rsi);
12426
12427 + pax_force_retaddr 0, 1
12428 ret;
12429 ENDPROC(camellia_ecb_enc_16way)
12430
12431 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12432 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12433 %xmm8, %rsi);
12434
12435 + pax_force_retaddr 0, 1
12436 ret;
12437 ENDPROC(camellia_ecb_dec_16way)
12438
12439 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12440 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12441 %xmm8, %rsi);
12442
12443 + pax_force_retaddr 0, 1
12444 ret;
12445 ENDPROC(camellia_cbc_dec_16way)
12446
12447 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12448 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12449 %xmm8, %rsi);
12450
12451 + pax_force_retaddr 0, 1
12452 ret;
12453 ENDPROC(camellia_ctr_16way)
12454
12455 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12456 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12457 %xmm8, %rsi);
12458
12459 + pax_force_retaddr 0, 1
12460 ret;
12461 ENDPROC(camellia_xts_crypt_16way)
12462
12463 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12464 index 0e0b886..8fc756a 100644
12465 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12466 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12467 @@ -11,6 +11,7 @@
12468 */
12469
12470 #include <linux/linkage.h>
12471 +#include <asm/alternative-asm.h>
12472
12473 #define CAMELLIA_TABLE_BYTE_LEN 272
12474
12475 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12476 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12477 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12478 %rcx, (%r9));
12479 + pax_force_retaddr_bts
12480 ret;
12481 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12482
12483 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12484 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12485 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12486 %rax, (%r9));
12487 + pax_force_retaddr_bts
12488 ret;
12489 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12490
12491 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12492 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12493 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12494
12495 + pax_force_retaddr_bts
12496 ret;
12497
12498 .align 8
12499 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12500 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12501 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12502
12503 + pax_force_retaddr_bts
12504 ret;
12505
12506 .align 8
12507 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12508
12509 vzeroupper;
12510
12511 + pax_force_retaddr 0, 1
12512 ret;
12513 ENDPROC(camellia_ecb_enc_32way)
12514
12515 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12516
12517 vzeroupper;
12518
12519 + pax_force_retaddr 0, 1
12520 ret;
12521 ENDPROC(camellia_ecb_dec_32way)
12522
12523 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12524
12525 vzeroupper;
12526
12527 + pax_force_retaddr 0, 1
12528 ret;
12529 ENDPROC(camellia_cbc_dec_32way)
12530
12531 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12532
12533 vzeroupper;
12534
12535 + pax_force_retaddr 0, 1
12536 ret;
12537 ENDPROC(camellia_ctr_32way)
12538
12539 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12540
12541 vzeroupper;
12542
12543 + pax_force_retaddr 0, 1
12544 ret;
12545 ENDPROC(camellia_xts_crypt_32way)
12546
12547 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12548 index 310319c..ce174a4 100644
12549 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12550 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12551 @@ -21,6 +21,7 @@
12552 */
12553
12554 #include <linux/linkage.h>
12555 +#include <asm/alternative-asm.h>
12556
12557 .file "camellia-x86_64-asm_64.S"
12558 .text
12559 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12560 enc_outunpack(mov, RT1);
12561
12562 movq RRBP, %rbp;
12563 + pax_force_retaddr 0, 1
12564 ret;
12565
12566 .L__enc_xor:
12567 enc_outunpack(xor, RT1);
12568
12569 movq RRBP, %rbp;
12570 + pax_force_retaddr 0, 1
12571 ret;
12572 ENDPROC(__camellia_enc_blk)
12573
12574 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12575 dec_outunpack();
12576
12577 movq RRBP, %rbp;
12578 + pax_force_retaddr 0, 1
12579 ret;
12580 ENDPROC(camellia_dec_blk)
12581
12582 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12583
12584 movq RRBP, %rbp;
12585 popq %rbx;
12586 + pax_force_retaddr 0, 1
12587 ret;
12588
12589 .L__enc2_xor:
12590 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12591
12592 movq RRBP, %rbp;
12593 popq %rbx;
12594 + pax_force_retaddr 0, 1
12595 ret;
12596 ENDPROC(__camellia_enc_blk_2way)
12597
12598 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12599
12600 movq RRBP, %rbp;
12601 movq RXOR, %rbx;
12602 + pax_force_retaddr 0, 1
12603 ret;
12604 ENDPROC(camellia_dec_blk_2way)
12605 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12606 index c35fd5d..c1ee236 100644
12607 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12608 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12609 @@ -24,6 +24,7 @@
12610 */
12611
12612 #include <linux/linkage.h>
12613 +#include <asm/alternative-asm.h>
12614
12615 .file "cast5-avx-x86_64-asm_64.S"
12616
12617 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12618 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12619 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12620
12621 + pax_force_retaddr 0, 1
12622 ret;
12623 ENDPROC(__cast5_enc_blk16)
12624
12625 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12626 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12627 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12628
12629 + pax_force_retaddr 0, 1
12630 ret;
12631
12632 .L__skip_dec:
12633 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12634 vmovdqu RR4, (6*4*4)(%r11);
12635 vmovdqu RL4, (7*4*4)(%r11);
12636
12637 + pax_force_retaddr
12638 ret;
12639 ENDPROC(cast5_ecb_enc_16way)
12640
12641 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12642 vmovdqu RR4, (6*4*4)(%r11);
12643 vmovdqu RL4, (7*4*4)(%r11);
12644
12645 + pax_force_retaddr
12646 ret;
12647 ENDPROC(cast5_ecb_dec_16way)
12648
12649 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12650
12651 popq %r12;
12652
12653 + pax_force_retaddr
12654 ret;
12655 ENDPROC(cast5_cbc_dec_16way)
12656
12657 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12658
12659 popq %r12;
12660
12661 + pax_force_retaddr
12662 ret;
12663 ENDPROC(cast5_ctr_16way)
12664 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12665 index e3531f8..18ded3a 100644
12666 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12667 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12668 @@ -24,6 +24,7 @@
12669 */
12670
12671 #include <linux/linkage.h>
12672 +#include <asm/alternative-asm.h>
12673 #include "glue_helper-asm-avx.S"
12674
12675 .file "cast6-avx-x86_64-asm_64.S"
12676 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12677 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12678 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12679
12680 + pax_force_retaddr 0, 1
12681 ret;
12682 ENDPROC(__cast6_enc_blk8)
12683
12684 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12685 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12686 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12687
12688 + pax_force_retaddr 0, 1
12689 ret;
12690 ENDPROC(__cast6_dec_blk8)
12691
12692 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12693
12694 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12695
12696 + pax_force_retaddr
12697 ret;
12698 ENDPROC(cast6_ecb_enc_8way)
12699
12700 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12701
12702 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12703
12704 + pax_force_retaddr
12705 ret;
12706 ENDPROC(cast6_ecb_dec_8way)
12707
12708 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12709
12710 popq %r12;
12711
12712 + pax_force_retaddr
12713 ret;
12714 ENDPROC(cast6_cbc_dec_8way)
12715
12716 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12717
12718 popq %r12;
12719
12720 + pax_force_retaddr
12721 ret;
12722 ENDPROC(cast6_ctr_8way)
12723
12724 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12725 /* dst <= regs xor IVs(in dst) */
12726 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12727
12728 + pax_force_retaddr
12729 ret;
12730 ENDPROC(cast6_xts_enc_8way)
12731
12732 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12733 /* dst <= regs xor IVs(in dst) */
12734 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12735
12736 + pax_force_retaddr
12737 ret;
12738 ENDPROC(cast6_xts_dec_8way)
12739 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12740 index dbc4339..3d868c5 100644
12741 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12742 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12743 @@ -45,6 +45,7 @@
12744
12745 #include <asm/inst.h>
12746 #include <linux/linkage.h>
12747 +#include <asm/alternative-asm.h>
12748
12749 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12750
12751 @@ -312,6 +313,7 @@ do_return:
12752 popq %rsi
12753 popq %rdi
12754 popq %rbx
12755 + pax_force_retaddr 0, 1
12756 ret
12757
12758 ################################################################
12759 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12760 index 586f41a..d02851e 100644
12761 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12762 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12763 @@ -18,6 +18,7 @@
12764
12765 #include <linux/linkage.h>
12766 #include <asm/inst.h>
12767 +#include <asm/alternative-asm.h>
12768
12769 .data
12770
12771 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12772 psrlq $1, T2
12773 pxor T2, T1
12774 pxor T1, DATA
12775 + pax_force_retaddr
12776 ret
12777 ENDPROC(__clmul_gf128mul_ble)
12778
12779 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12780 call __clmul_gf128mul_ble
12781 PSHUFB_XMM BSWAP DATA
12782 movups DATA, (%rdi)
12783 + pax_force_retaddr
12784 ret
12785 ENDPROC(clmul_ghash_mul)
12786
12787 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12788 PSHUFB_XMM BSWAP DATA
12789 movups DATA, (%rdi)
12790 .Lupdate_just_ret:
12791 + pax_force_retaddr
12792 ret
12793 ENDPROC(clmul_ghash_update)
12794
12795 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12796 pand .Lpoly, %xmm1
12797 pxor %xmm1, %xmm0
12798 movups %xmm0, (%rdi)
12799 + pax_force_retaddr
12800 ret
12801 ENDPROC(clmul_ghash_setkey)
12802 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12803 index 9279e0b..9270820 100644
12804 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12805 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12806 @@ -1,4 +1,5 @@
12807 #include <linux/linkage.h>
12808 +#include <asm/alternative-asm.h>
12809
12810 # enter salsa20_encrypt_bytes
12811 ENTRY(salsa20_encrypt_bytes)
12812 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12813 add %r11,%rsp
12814 mov %rdi,%rax
12815 mov %rsi,%rdx
12816 + pax_force_retaddr 0, 1
12817 ret
12818 # bytesatleast65:
12819 ._bytesatleast65:
12820 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12821 add %r11,%rsp
12822 mov %rdi,%rax
12823 mov %rsi,%rdx
12824 + pax_force_retaddr
12825 ret
12826 ENDPROC(salsa20_keysetup)
12827
12828 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12829 add %r11,%rsp
12830 mov %rdi,%rax
12831 mov %rsi,%rdx
12832 + pax_force_retaddr
12833 ret
12834 ENDPROC(salsa20_ivsetup)
12835 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12836 index 2f202f4..d9164d6 100644
12837 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12838 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12839 @@ -24,6 +24,7 @@
12840 */
12841
12842 #include <linux/linkage.h>
12843 +#include <asm/alternative-asm.h>
12844 #include "glue_helper-asm-avx.S"
12845
12846 .file "serpent-avx-x86_64-asm_64.S"
12847 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12848 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12849 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12850
12851 + pax_force_retaddr
12852 ret;
12853 ENDPROC(__serpent_enc_blk8_avx)
12854
12855 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12856 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12857 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12858
12859 + pax_force_retaddr
12860 ret;
12861 ENDPROC(__serpent_dec_blk8_avx)
12862
12863 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12864
12865 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12866
12867 + pax_force_retaddr
12868 ret;
12869 ENDPROC(serpent_ecb_enc_8way_avx)
12870
12871 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12872
12873 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12874
12875 + pax_force_retaddr
12876 ret;
12877 ENDPROC(serpent_ecb_dec_8way_avx)
12878
12879 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12880
12881 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12882
12883 + pax_force_retaddr
12884 ret;
12885 ENDPROC(serpent_cbc_dec_8way_avx)
12886
12887 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12888
12889 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12890
12891 + pax_force_retaddr
12892 ret;
12893 ENDPROC(serpent_ctr_8way_avx)
12894
12895 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12896 /* dst <= regs xor IVs(in dst) */
12897 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12898
12899 + pax_force_retaddr
12900 ret;
12901 ENDPROC(serpent_xts_enc_8way_avx)
12902
12903 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12904 /* dst <= regs xor IVs(in dst) */
12905 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12906
12907 + pax_force_retaddr
12908 ret;
12909 ENDPROC(serpent_xts_dec_8way_avx)
12910 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12911 index b222085..abd483c 100644
12912 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12913 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12914 @@ -15,6 +15,7 @@
12915 */
12916
12917 #include <linux/linkage.h>
12918 +#include <asm/alternative-asm.h>
12919 #include "glue_helper-asm-avx2.S"
12920
12921 .file "serpent-avx2-asm_64.S"
12922 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12923 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12924 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12925
12926 + pax_force_retaddr
12927 ret;
12928 ENDPROC(__serpent_enc_blk16)
12929
12930 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12931 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12932 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12933
12934 + pax_force_retaddr
12935 ret;
12936 ENDPROC(__serpent_dec_blk16)
12937
12938 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12939
12940 vzeroupper;
12941
12942 + pax_force_retaddr
12943 ret;
12944 ENDPROC(serpent_ecb_enc_16way)
12945
12946 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12947
12948 vzeroupper;
12949
12950 + pax_force_retaddr
12951 ret;
12952 ENDPROC(serpent_ecb_dec_16way)
12953
12954 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12955
12956 vzeroupper;
12957
12958 + pax_force_retaddr
12959 ret;
12960 ENDPROC(serpent_cbc_dec_16way)
12961
12962 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12963
12964 vzeroupper;
12965
12966 + pax_force_retaddr
12967 ret;
12968 ENDPROC(serpent_ctr_16way)
12969
12970 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12971
12972 vzeroupper;
12973
12974 + pax_force_retaddr
12975 ret;
12976 ENDPROC(serpent_xts_enc_16way)
12977
12978 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12979
12980 vzeroupper;
12981
12982 + pax_force_retaddr
12983 ret;
12984 ENDPROC(serpent_xts_dec_16way)
12985 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12986 index acc066c..1559cc4 100644
12987 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12988 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12989 @@ -25,6 +25,7 @@
12990 */
12991
12992 #include <linux/linkage.h>
12993 +#include <asm/alternative-asm.h>
12994
12995 .file "serpent-sse2-x86_64-asm_64.S"
12996 .text
12997 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12998 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12999 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13000
13001 + pax_force_retaddr
13002 ret;
13003
13004 .L__enc_xor8:
13005 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13006 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13007
13008 + pax_force_retaddr
13009 ret;
13010 ENDPROC(__serpent_enc_blk_8way)
13011
13012 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
13013 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13014 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13015
13016 + pax_force_retaddr
13017 ret;
13018 ENDPROC(serpent_dec_blk_8way)
13019 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
13020 index a410950..3356d42 100644
13021 --- a/arch/x86/crypto/sha1_ssse3_asm.S
13022 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
13023 @@ -29,6 +29,7 @@
13024 */
13025
13026 #include <linux/linkage.h>
13027 +#include <asm/alternative-asm.h>
13028
13029 #define CTX %rdi // arg1
13030 #define BUF %rsi // arg2
13031 @@ -104,6 +105,7 @@
13032 pop %r12
13033 pop %rbp
13034 pop %rbx
13035 + pax_force_retaddr 0, 1
13036 ret
13037
13038 ENDPROC(\name)
13039 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13040 index 642f156..4ab07b9 100644
13041 --- a/arch/x86/crypto/sha256-avx-asm.S
13042 +++ b/arch/x86/crypto/sha256-avx-asm.S
13043 @@ -49,6 +49,7 @@
13044
13045 #ifdef CONFIG_AS_AVX
13046 #include <linux/linkage.h>
13047 +#include <asm/alternative-asm.h>
13048
13049 ## assume buffers not aligned
13050 #define VMOVDQ vmovdqu
13051 @@ -460,6 +461,7 @@ done_hash:
13052 popq %r13
13053 popq %rbp
13054 popq %rbx
13055 + pax_force_retaddr 0, 1
13056 ret
13057 ENDPROC(sha256_transform_avx)
13058
13059 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13060 index 9e86944..2e7f95a 100644
13061 --- a/arch/x86/crypto/sha256-avx2-asm.S
13062 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13063 @@ -50,6 +50,7 @@
13064
13065 #ifdef CONFIG_AS_AVX2
13066 #include <linux/linkage.h>
13067 +#include <asm/alternative-asm.h>
13068
13069 ## assume buffers not aligned
13070 #define VMOVDQ vmovdqu
13071 @@ -720,6 +721,7 @@ done_hash:
13072 popq %r12
13073 popq %rbp
13074 popq %rbx
13075 + pax_force_retaddr 0, 1
13076 ret
13077 ENDPROC(sha256_transform_rorx)
13078
13079 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13080 index f833b74..c36ed14 100644
13081 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13082 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13083 @@ -47,6 +47,7 @@
13084 ########################################################################
13085
13086 #include <linux/linkage.h>
13087 +#include <asm/alternative-asm.h>
13088
13089 ## assume buffers not aligned
13090 #define MOVDQ movdqu
13091 @@ -471,6 +472,7 @@ done_hash:
13092 popq %rbp
13093 popq %rbx
13094
13095 + pax_force_retaddr 0, 1
13096 ret
13097 ENDPROC(sha256_transform_ssse3)
13098
13099 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13100 index 974dde9..4533d34 100644
13101 --- a/arch/x86/crypto/sha512-avx-asm.S
13102 +++ b/arch/x86/crypto/sha512-avx-asm.S
13103 @@ -49,6 +49,7 @@
13104
13105 #ifdef CONFIG_AS_AVX
13106 #include <linux/linkage.h>
13107 +#include <asm/alternative-asm.h>
13108
13109 .text
13110
13111 @@ -364,6 +365,7 @@ updateblock:
13112 mov frame_RSPSAVE(%rsp), %rsp
13113
13114 nowork:
13115 + pax_force_retaddr 0, 1
13116 ret
13117 ENDPROC(sha512_transform_avx)
13118
13119 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13120 index 568b961..061ef1d 100644
13121 --- a/arch/x86/crypto/sha512-avx2-asm.S
13122 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13123 @@ -51,6 +51,7 @@
13124
13125 #ifdef CONFIG_AS_AVX2
13126 #include <linux/linkage.h>
13127 +#include <asm/alternative-asm.h>
13128
13129 .text
13130
13131 @@ -678,6 +679,7 @@ done_hash:
13132
13133 # Restore Stack Pointer
13134 mov frame_RSPSAVE(%rsp), %rsp
13135 + pax_force_retaddr 0, 1
13136 ret
13137 ENDPROC(sha512_transform_rorx)
13138
13139 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13140 index fb56855..e23914f 100644
13141 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13142 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13143 @@ -48,6 +48,7 @@
13144 ########################################################################
13145
13146 #include <linux/linkage.h>
13147 +#include <asm/alternative-asm.h>
13148
13149 .text
13150
13151 @@ -363,6 +364,7 @@ updateblock:
13152 mov frame_RSPSAVE(%rsp), %rsp
13153
13154 nowork:
13155 + pax_force_retaddr 0, 1
13156 ret
13157 ENDPROC(sha512_transform_ssse3)
13158
13159 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13160 index 0505813..63b1d00 100644
13161 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13162 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13163 @@ -24,6 +24,7 @@
13164 */
13165
13166 #include <linux/linkage.h>
13167 +#include <asm/alternative-asm.h>
13168 #include "glue_helper-asm-avx.S"
13169
13170 .file "twofish-avx-x86_64-asm_64.S"
13171 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13172 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13173 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13174
13175 + pax_force_retaddr 0, 1
13176 ret;
13177 ENDPROC(__twofish_enc_blk8)
13178
13179 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13180 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13181 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13182
13183 + pax_force_retaddr 0, 1
13184 ret;
13185 ENDPROC(__twofish_dec_blk8)
13186
13187 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13188
13189 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13190
13191 + pax_force_retaddr 0, 1
13192 ret;
13193 ENDPROC(twofish_ecb_enc_8way)
13194
13195 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13196
13197 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13198
13199 + pax_force_retaddr 0, 1
13200 ret;
13201 ENDPROC(twofish_ecb_dec_8way)
13202
13203 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13204
13205 popq %r12;
13206
13207 + pax_force_retaddr 0, 1
13208 ret;
13209 ENDPROC(twofish_cbc_dec_8way)
13210
13211 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13212
13213 popq %r12;
13214
13215 + pax_force_retaddr 0, 1
13216 ret;
13217 ENDPROC(twofish_ctr_8way)
13218
13219 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13220 /* dst <= regs xor IVs(in dst) */
13221 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13222
13223 + pax_force_retaddr 0, 1
13224 ret;
13225 ENDPROC(twofish_xts_enc_8way)
13226
13227 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13228 /* dst <= regs xor IVs(in dst) */
13229 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13230
13231 + pax_force_retaddr 0, 1
13232 ret;
13233 ENDPROC(twofish_xts_dec_8way)
13234 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13235 index 1c3b7ce..b365c5e 100644
13236 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13237 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13238 @@ -21,6 +21,7 @@
13239 */
13240
13241 #include <linux/linkage.h>
13242 +#include <asm/alternative-asm.h>
13243
13244 .file "twofish-x86_64-asm-3way.S"
13245 .text
13246 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13247 popq %r13;
13248 popq %r14;
13249 popq %r15;
13250 + pax_force_retaddr 0, 1
13251 ret;
13252
13253 .L__enc_xor3:
13254 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13255 popq %r13;
13256 popq %r14;
13257 popq %r15;
13258 + pax_force_retaddr 0, 1
13259 ret;
13260 ENDPROC(__twofish_enc_blk_3way)
13261
13262 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13263 popq %r13;
13264 popq %r14;
13265 popq %r15;
13266 + pax_force_retaddr 0, 1
13267 ret;
13268 ENDPROC(twofish_dec_blk_3way)
13269 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13270 index a039d21..29e7615 100644
13271 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13272 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13273 @@ -22,6 +22,7 @@
13274
13275 #include <linux/linkage.h>
13276 #include <asm/asm-offsets.h>
13277 +#include <asm/alternative-asm.h>
13278
13279 #define a_offset 0
13280 #define b_offset 4
13281 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13282
13283 popq R1
13284 movq $1,%rax
13285 + pax_force_retaddr 0, 1
13286 ret
13287 ENDPROC(twofish_enc_blk)
13288
13289 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13290
13291 popq R1
13292 movq $1,%rax
13293 + pax_force_retaddr 0, 1
13294 ret
13295 ENDPROC(twofish_dec_blk)
13296 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13297 index bae3aba..c1788c1 100644
13298 --- a/arch/x86/ia32/ia32_aout.c
13299 +++ b/arch/x86/ia32/ia32_aout.c
13300 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13301 unsigned long dump_start, dump_size;
13302 struct user32 dump;
13303
13304 + memset(&dump, 0, sizeof(dump));
13305 +
13306 fs = get_fs();
13307 set_fs(KERNEL_DS);
13308 has_dumped = 1;
13309 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13310 index 665a730..8e7a67a 100644
13311 --- a/arch/x86/ia32/ia32_signal.c
13312 +++ b/arch/x86/ia32/ia32_signal.c
13313 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13314 sp -= frame_size;
13315 /* Align the stack pointer according to the i386 ABI,
13316 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13317 - sp = ((sp + 4) & -16ul) - 4;
13318 + sp = ((sp - 12) & -16ul) - 4;
13319 return (void __user *) sp;
13320 }
13321
13322 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13323 * These are actually not used anymore, but left because some
13324 * gdb versions depend on them as a marker.
13325 */
13326 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13327 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13328 } put_user_catch(err);
13329
13330 if (err)
13331 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13332 0xb8,
13333 __NR_ia32_rt_sigreturn,
13334 0x80cd,
13335 - 0,
13336 + 0
13337 };
13338
13339 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13340 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13341
13342 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13343 restorer = ksig->ka.sa.sa_restorer;
13344 + else if (current->mm->context.vdso)
13345 + /* Return stub is in 32bit vsyscall page */
13346 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13347 else
13348 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13349 - rt_sigreturn);
13350 + restorer = &frame->retcode;
13351 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13352
13353 /*
13354 * Not actually used anymore, but left because some gdb
13355 * versions need it.
13356 */
13357 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13358 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13359 } put_user_catch(err);
13360
13361 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13362 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13363 index 474dc1b..9297c58 100644
13364 --- a/arch/x86/ia32/ia32entry.S
13365 +++ b/arch/x86/ia32/ia32entry.S
13366 @@ -15,8 +15,10 @@
13367 #include <asm/irqflags.h>
13368 #include <asm/asm.h>
13369 #include <asm/smap.h>
13370 +#include <asm/pgtable.h>
13371 #include <linux/linkage.h>
13372 #include <linux/err.h>
13373 +#include <asm/alternative-asm.h>
13374
13375 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13376 #include <linux/elf-em.h>
13377 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13378 ENDPROC(native_irq_enable_sysexit)
13379 #endif
13380
13381 + .macro pax_enter_kernel_user
13382 + pax_set_fptr_mask
13383 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13384 + call pax_enter_kernel_user
13385 +#endif
13386 + .endm
13387 +
13388 + .macro pax_exit_kernel_user
13389 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13390 + call pax_exit_kernel_user
13391 +#endif
13392 +#ifdef CONFIG_PAX_RANDKSTACK
13393 + pushq %rax
13394 + pushq %r11
13395 + call pax_randomize_kstack
13396 + popq %r11
13397 + popq %rax
13398 +#endif
13399 + .endm
13400 +
13401 + .macro pax_erase_kstack
13402 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13403 + call pax_erase_kstack
13404 +#endif
13405 + .endm
13406 +
13407 /*
13408 * 32bit SYSENTER instruction entry.
13409 *
13410 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13411 CFI_REGISTER rsp,rbp
13412 SWAPGS_UNSAFE_STACK
13413 movq PER_CPU_VAR(kernel_stack), %rsp
13414 - addq $(KERNEL_STACK_OFFSET),%rsp
13415 - /*
13416 - * No need to follow this irqs on/off section: the syscall
13417 - * disabled irqs, here we enable it straight after entry:
13418 - */
13419 - ENABLE_INTERRUPTS(CLBR_NONE)
13420 movl %ebp,%ebp /* zero extension */
13421 pushq_cfi $__USER32_DS
13422 /*CFI_REL_OFFSET ss,0*/
13423 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13424 CFI_REL_OFFSET rsp,0
13425 pushfq_cfi
13426 /*CFI_REL_OFFSET rflags,0*/
13427 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13428 - CFI_REGISTER rip,r10
13429 + orl $X86_EFLAGS_IF,(%rsp)
13430 + GET_THREAD_INFO(%r11)
13431 + movl TI_sysenter_return(%r11), %r11d
13432 + CFI_REGISTER rip,r11
13433 pushq_cfi $__USER32_CS
13434 /*CFI_REL_OFFSET cs,0*/
13435 movl %eax, %eax
13436 - pushq_cfi %r10
13437 + pushq_cfi %r11
13438 CFI_REL_OFFSET rip,0
13439 pushq_cfi %rax
13440 cld
13441 SAVE_ARGS 0,1,0
13442 + pax_enter_kernel_user
13443 +
13444 +#ifdef CONFIG_PAX_RANDKSTACK
13445 + pax_erase_kstack
13446 +#endif
13447 +
13448 + /*
13449 + * No need to follow this irqs on/off section: the syscall
13450 + * disabled irqs, here we enable it straight after entry:
13451 + */
13452 + ENABLE_INTERRUPTS(CLBR_NONE)
13453 /* no need to do an access_ok check here because rbp has been
13454 32bit zero extended */
13455 +
13456 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13457 + addq pax_user_shadow_base,%rbp
13458 + ASM_PAX_OPEN_USERLAND
13459 +#endif
13460 +
13461 ASM_STAC
13462 1: movl (%rbp),%ebp
13463 _ASM_EXTABLE(1b,ia32_badarg)
13464 ASM_CLAC
13465 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13466 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13467 +
13468 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13469 + ASM_PAX_CLOSE_USERLAND
13470 +#endif
13471 +
13472 + GET_THREAD_INFO(%r11)
13473 + orl $TS_COMPAT,TI_status(%r11)
13474 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13475 CFI_REMEMBER_STATE
13476 jnz sysenter_tracesys
13477 cmpq $(IA32_NR_syscalls-1),%rax
13478 @@ -162,12 +209,15 @@ sysenter_do_call:
13479 sysenter_dispatch:
13480 call *ia32_sys_call_table(,%rax,8)
13481 movq %rax,RAX-ARGOFFSET(%rsp)
13482 + GET_THREAD_INFO(%r11)
13483 DISABLE_INTERRUPTS(CLBR_NONE)
13484 TRACE_IRQS_OFF
13485 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13486 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13487 jnz sysexit_audit
13488 sysexit_from_sys_call:
13489 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13490 + pax_exit_kernel_user
13491 + pax_erase_kstack
13492 + andl $~TS_COMPAT,TI_status(%r11)
13493 /* clear IF, that popfq doesn't enable interrupts early */
13494 andl $~0x200,EFLAGS-R11(%rsp)
13495 movl RIP-R11(%rsp),%edx /* User %eip */
13496 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13497 movl %eax,%esi /* 2nd arg: syscall number */
13498 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13499 call __audit_syscall_entry
13500 +
13501 + pax_erase_kstack
13502 +
13503 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13504 cmpq $(IA32_NR_syscalls-1),%rax
13505 ja ia32_badsys
13506 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13507 .endm
13508
13509 .macro auditsys_exit exit
13510 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13511 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13512 jnz ia32_ret_from_sys_call
13513 TRACE_IRQS_ON
13514 ENABLE_INTERRUPTS(CLBR_NONE)
13515 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13516 1: setbe %al /* 1 if error, 0 if not */
13517 movzbl %al,%edi /* zero-extend that into %edi */
13518 call __audit_syscall_exit
13519 + GET_THREAD_INFO(%r11)
13520 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13521 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13522 DISABLE_INTERRUPTS(CLBR_NONE)
13523 TRACE_IRQS_OFF
13524 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13525 + testl %edi,TI_flags(%r11)
13526 jz \exit
13527 CLEAR_RREGS -ARGOFFSET
13528 jmp int_with_check
13529 @@ -237,7 +291,7 @@ sysexit_audit:
13530
13531 sysenter_tracesys:
13532 #ifdef CONFIG_AUDITSYSCALL
13533 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13534 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13535 jz sysenter_auditsys
13536 #endif
13537 SAVE_REST
13538 @@ -249,6 +303,9 @@ sysenter_tracesys:
13539 RESTORE_REST
13540 cmpq $(IA32_NR_syscalls-1),%rax
13541 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13542 +
13543 + pax_erase_kstack
13544 +
13545 jmp sysenter_do_call
13546 CFI_ENDPROC
13547 ENDPROC(ia32_sysenter_target)
13548 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13549 ENTRY(ia32_cstar_target)
13550 CFI_STARTPROC32 simple
13551 CFI_SIGNAL_FRAME
13552 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13553 + CFI_DEF_CFA rsp,0
13554 CFI_REGISTER rip,rcx
13555 /*CFI_REGISTER rflags,r11*/
13556 SWAPGS_UNSAFE_STACK
13557 movl %esp,%r8d
13558 CFI_REGISTER rsp,r8
13559 movq PER_CPU_VAR(kernel_stack),%rsp
13560 + SAVE_ARGS 8*6,0,0
13561 + pax_enter_kernel_user
13562 +
13563 +#ifdef CONFIG_PAX_RANDKSTACK
13564 + pax_erase_kstack
13565 +#endif
13566 +
13567 /*
13568 * No need to follow this irqs on/off section: the syscall
13569 * disabled irqs and here we enable it straight after entry:
13570 */
13571 ENABLE_INTERRUPTS(CLBR_NONE)
13572 - SAVE_ARGS 8,0,0
13573 movl %eax,%eax /* zero extension */
13574 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13575 movq %rcx,RIP-ARGOFFSET(%rsp)
13576 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13577 /* no need to do an access_ok check here because r8 has been
13578 32bit zero extended */
13579 /* hardware stack frame is complete now */
13580 +
13581 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13582 + ASM_PAX_OPEN_USERLAND
13583 + movq pax_user_shadow_base,%r8
13584 + addq RSP-ARGOFFSET(%rsp),%r8
13585 +#endif
13586 +
13587 ASM_STAC
13588 1: movl (%r8),%r9d
13589 _ASM_EXTABLE(1b,ia32_badarg)
13590 ASM_CLAC
13591 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13592 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13593 +
13594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13595 + ASM_PAX_CLOSE_USERLAND
13596 +#endif
13597 +
13598 + GET_THREAD_INFO(%r11)
13599 + orl $TS_COMPAT,TI_status(%r11)
13600 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13601 CFI_REMEMBER_STATE
13602 jnz cstar_tracesys
13603 cmpq $IA32_NR_syscalls-1,%rax
13604 @@ -319,12 +395,15 @@ cstar_do_call:
13605 cstar_dispatch:
13606 call *ia32_sys_call_table(,%rax,8)
13607 movq %rax,RAX-ARGOFFSET(%rsp)
13608 + GET_THREAD_INFO(%r11)
13609 DISABLE_INTERRUPTS(CLBR_NONE)
13610 TRACE_IRQS_OFF
13611 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13612 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13613 jnz sysretl_audit
13614 sysretl_from_sys_call:
13615 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13616 + pax_exit_kernel_user
13617 + pax_erase_kstack
13618 + andl $~TS_COMPAT,TI_status(%r11)
13619 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13620 movl RIP-ARGOFFSET(%rsp),%ecx
13621 CFI_REGISTER rip,rcx
13622 @@ -352,7 +431,7 @@ sysretl_audit:
13623
13624 cstar_tracesys:
13625 #ifdef CONFIG_AUDITSYSCALL
13626 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13627 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13628 jz cstar_auditsys
13629 #endif
13630 xchgl %r9d,%ebp
13631 @@ -366,11 +445,19 @@ cstar_tracesys:
13632 xchgl %ebp,%r9d
13633 cmpq $(IA32_NR_syscalls-1),%rax
13634 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13635 +
13636 + pax_erase_kstack
13637 +
13638 jmp cstar_do_call
13639 END(ia32_cstar_target)
13640
13641 ia32_badarg:
13642 ASM_CLAC
13643 +
13644 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13645 + ASM_PAX_CLOSE_USERLAND
13646 +#endif
13647 +
13648 movq $-EFAULT,%rax
13649 jmp ia32_sysret
13650 CFI_ENDPROC
13651 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13652 CFI_REL_OFFSET rip,RIP-RIP
13653 PARAVIRT_ADJUST_EXCEPTION_FRAME
13654 SWAPGS
13655 - /*
13656 - * No need to follow this irqs on/off section: the syscall
13657 - * disabled irqs and here we enable it straight after entry:
13658 - */
13659 - ENABLE_INTERRUPTS(CLBR_NONE)
13660 movl %eax,%eax
13661 pushq_cfi %rax
13662 cld
13663 /* note the registers are not zero extended to the sf.
13664 this could be a problem. */
13665 SAVE_ARGS 0,1,0
13666 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13667 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13668 + pax_enter_kernel_user
13669 +
13670 +#ifdef CONFIG_PAX_RANDKSTACK
13671 + pax_erase_kstack
13672 +#endif
13673 +
13674 + /*
13675 + * No need to follow this irqs on/off section: the syscall
13676 + * disabled irqs and here we enable it straight after entry:
13677 + */
13678 + ENABLE_INTERRUPTS(CLBR_NONE)
13679 + GET_THREAD_INFO(%r11)
13680 + orl $TS_COMPAT,TI_status(%r11)
13681 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13682 jnz ia32_tracesys
13683 cmpq $(IA32_NR_syscalls-1),%rax
13684 ja ia32_badsys
13685 @@ -442,6 +536,9 @@ ia32_tracesys:
13686 RESTORE_REST
13687 cmpq $(IA32_NR_syscalls-1),%rax
13688 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13689 +
13690 + pax_erase_kstack
13691 +
13692 jmp ia32_do_call
13693 END(ia32_syscall)
13694
13695 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13696 index 8e0ceec..af13504 100644
13697 --- a/arch/x86/ia32/sys_ia32.c
13698 +++ b/arch/x86/ia32/sys_ia32.c
13699 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13700 */
13701 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13702 {
13703 - typeof(ubuf->st_uid) uid = 0;
13704 - typeof(ubuf->st_gid) gid = 0;
13705 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13706 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13707 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13708 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13709 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13710 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13711 index 372231c..a5aa1a1 100644
13712 --- a/arch/x86/include/asm/alternative-asm.h
13713 +++ b/arch/x86/include/asm/alternative-asm.h
13714 @@ -18,6 +18,45 @@
13715 .endm
13716 #endif
13717
13718 +#ifdef KERNEXEC_PLUGIN
13719 + .macro pax_force_retaddr_bts rip=0
13720 + btsq $63,\rip(%rsp)
13721 + .endm
13722 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13723 + .macro pax_force_retaddr rip=0, reload=0
13724 + btsq $63,\rip(%rsp)
13725 + .endm
13726 + .macro pax_force_fptr ptr
13727 + btsq $63,\ptr
13728 + .endm
13729 + .macro pax_set_fptr_mask
13730 + .endm
13731 +#endif
13732 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13733 + .macro pax_force_retaddr rip=0, reload=0
13734 + .if \reload
13735 + pax_set_fptr_mask
13736 + .endif
13737 + orq %r10,\rip(%rsp)
13738 + .endm
13739 + .macro pax_force_fptr ptr
13740 + orq %r10,\ptr
13741 + .endm
13742 + .macro pax_set_fptr_mask
13743 + movabs $0x8000000000000000,%r10
13744 + .endm
13745 +#endif
13746 +#else
13747 + .macro pax_force_retaddr rip=0, reload=0
13748 + .endm
13749 + .macro pax_force_fptr ptr
13750 + .endm
13751 + .macro pax_force_retaddr_bts rip=0
13752 + .endm
13753 + .macro pax_set_fptr_mask
13754 + .endm
13755 +#endif
13756 +
13757 .macro altinstruction_entry orig alt feature orig_len alt_len
13758 .long \orig - .
13759 .long \alt - .
13760 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13761 index 58ed6d9..f1cbe58 100644
13762 --- a/arch/x86/include/asm/alternative.h
13763 +++ b/arch/x86/include/asm/alternative.h
13764 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13765 ".pushsection .discard,\"aw\",@progbits\n" \
13766 DISCARD_ENTRY(1) \
13767 ".popsection\n" \
13768 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13769 + ".pushsection .altinstr_replacement, \"a\"\n" \
13770 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13771 ".popsection"
13772
13773 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13774 DISCARD_ENTRY(1) \
13775 DISCARD_ENTRY(2) \
13776 ".popsection\n" \
13777 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13778 + ".pushsection .altinstr_replacement, \"a\"\n" \
13779 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13780 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13781 ".popsection"
13782 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13783 index f8119b5..7209d5b 100644
13784 --- a/arch/x86/include/asm/apic.h
13785 +++ b/arch/x86/include/asm/apic.h
13786 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13787
13788 #ifdef CONFIG_X86_LOCAL_APIC
13789
13790 -extern unsigned int apic_verbosity;
13791 +extern int apic_verbosity;
13792 extern int local_apic_timer_c2_ok;
13793
13794 extern int disable_apic;
13795 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13796 index 20370c6..a2eb9b0 100644
13797 --- a/arch/x86/include/asm/apm.h
13798 +++ b/arch/x86/include/asm/apm.h
13799 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13800 __asm__ __volatile__(APM_DO_ZERO_SEGS
13801 "pushl %%edi\n\t"
13802 "pushl %%ebp\n\t"
13803 - "lcall *%%cs:apm_bios_entry\n\t"
13804 + "lcall *%%ss:apm_bios_entry\n\t"
13805 "setc %%al\n\t"
13806 "popl %%ebp\n\t"
13807 "popl %%edi\n\t"
13808 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13809 __asm__ __volatile__(APM_DO_ZERO_SEGS
13810 "pushl %%edi\n\t"
13811 "pushl %%ebp\n\t"
13812 - "lcall *%%cs:apm_bios_entry\n\t"
13813 + "lcall *%%ss:apm_bios_entry\n\t"
13814 "setc %%bl\n\t"
13815 "popl %%ebp\n\t"
13816 "popl %%edi\n\t"
13817 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13818 index 722aa3b..3a0bb27 100644
13819 --- a/arch/x86/include/asm/atomic.h
13820 +++ b/arch/x86/include/asm/atomic.h
13821 @@ -22,7 +22,18 @@
13822 */
13823 static inline int atomic_read(const atomic_t *v)
13824 {
13825 - return (*(volatile int *)&(v)->counter);
13826 + return (*(volatile const int *)&(v)->counter);
13827 +}
13828 +
13829 +/**
13830 + * atomic_read_unchecked - read atomic variable
13831 + * @v: pointer of type atomic_unchecked_t
13832 + *
13833 + * Atomically reads the value of @v.
13834 + */
13835 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13836 +{
13837 + return (*(volatile const int *)&(v)->counter);
13838 }
13839
13840 /**
13841 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13842 }
13843
13844 /**
13845 + * atomic_set_unchecked - set atomic variable
13846 + * @v: pointer of type atomic_unchecked_t
13847 + * @i: required value
13848 + *
13849 + * Atomically sets the value of @v to @i.
13850 + */
13851 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13852 +{
13853 + v->counter = i;
13854 +}
13855 +
13856 +/**
13857 * atomic_add - add integer to atomic variable
13858 * @i: integer value to add
13859 * @v: pointer of type atomic_t
13860 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13861 */
13862 static inline void atomic_add(int i, atomic_t *v)
13863 {
13864 - asm volatile(LOCK_PREFIX "addl %1,%0"
13865 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13866 +
13867 +#ifdef CONFIG_PAX_REFCOUNT
13868 + "jno 0f\n"
13869 + LOCK_PREFIX "subl %1,%0\n"
13870 + "int $4\n0:\n"
13871 + _ASM_EXTABLE(0b, 0b)
13872 +#endif
13873 +
13874 + : "+m" (v->counter)
13875 + : "ir" (i));
13876 +}
13877 +
13878 +/**
13879 + * atomic_add_unchecked - add integer to atomic variable
13880 + * @i: integer value to add
13881 + * @v: pointer of type atomic_unchecked_t
13882 + *
13883 + * Atomically adds @i to @v.
13884 + */
13885 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13886 +{
13887 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13888 : "+m" (v->counter)
13889 : "ir" (i));
13890 }
13891 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13892 */
13893 static inline void atomic_sub(int i, atomic_t *v)
13894 {
13895 - asm volatile(LOCK_PREFIX "subl %1,%0"
13896 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13897 +
13898 +#ifdef CONFIG_PAX_REFCOUNT
13899 + "jno 0f\n"
13900 + LOCK_PREFIX "addl %1,%0\n"
13901 + "int $4\n0:\n"
13902 + _ASM_EXTABLE(0b, 0b)
13903 +#endif
13904 +
13905 + : "+m" (v->counter)
13906 + : "ir" (i));
13907 +}
13908 +
13909 +/**
13910 + * atomic_sub_unchecked - subtract integer from atomic variable
13911 + * @i: integer value to subtract
13912 + * @v: pointer of type atomic_unchecked_t
13913 + *
13914 + * Atomically subtracts @i from @v.
13915 + */
13916 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13917 +{
13918 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13919 : "+m" (v->counter)
13920 : "ir" (i));
13921 }
13922 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13923 {
13924 unsigned char c;
13925
13926 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13927 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13928 +
13929 +#ifdef CONFIG_PAX_REFCOUNT
13930 + "jno 0f\n"
13931 + LOCK_PREFIX "addl %2,%0\n"
13932 + "int $4\n0:\n"
13933 + _ASM_EXTABLE(0b, 0b)
13934 +#endif
13935 +
13936 + "sete %1\n"
13937 : "+m" (v->counter), "=qm" (c)
13938 : "ir" (i) : "memory");
13939 return c;
13940 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13941 */
13942 static inline void atomic_inc(atomic_t *v)
13943 {
13944 - asm volatile(LOCK_PREFIX "incl %0"
13945 + asm volatile(LOCK_PREFIX "incl %0\n"
13946 +
13947 +#ifdef CONFIG_PAX_REFCOUNT
13948 + "jno 0f\n"
13949 + LOCK_PREFIX "decl %0\n"
13950 + "int $4\n0:\n"
13951 + _ASM_EXTABLE(0b, 0b)
13952 +#endif
13953 +
13954 + : "+m" (v->counter));
13955 +}
13956 +
13957 +/**
13958 + * atomic_inc_unchecked - increment atomic variable
13959 + * @v: pointer of type atomic_unchecked_t
13960 + *
13961 + * Atomically increments @v by 1.
13962 + */
13963 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13964 +{
13965 + asm volatile(LOCK_PREFIX "incl %0\n"
13966 : "+m" (v->counter));
13967 }
13968
13969 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13970 */
13971 static inline void atomic_dec(atomic_t *v)
13972 {
13973 - asm volatile(LOCK_PREFIX "decl %0"
13974 + asm volatile(LOCK_PREFIX "decl %0\n"
13975 +
13976 +#ifdef CONFIG_PAX_REFCOUNT
13977 + "jno 0f\n"
13978 + LOCK_PREFIX "incl %0\n"
13979 + "int $4\n0:\n"
13980 + _ASM_EXTABLE(0b, 0b)
13981 +#endif
13982 +
13983 + : "+m" (v->counter));
13984 +}
13985 +
13986 +/**
13987 + * atomic_dec_unchecked - decrement atomic variable
13988 + * @v: pointer of type atomic_unchecked_t
13989 + *
13990 + * Atomically decrements @v by 1.
13991 + */
13992 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13993 +{
13994 + asm volatile(LOCK_PREFIX "decl %0\n"
13995 : "+m" (v->counter));
13996 }
13997
13998 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13999 {
14000 unsigned char c;
14001
14002 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
14003 + asm volatile(LOCK_PREFIX "decl %0\n"
14004 +
14005 +#ifdef CONFIG_PAX_REFCOUNT
14006 + "jno 0f\n"
14007 + LOCK_PREFIX "incl %0\n"
14008 + "int $4\n0:\n"
14009 + _ASM_EXTABLE(0b, 0b)
14010 +#endif
14011 +
14012 + "sete %1\n"
14013 : "+m" (v->counter), "=qm" (c)
14014 : : "memory");
14015 return c != 0;
14016 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
14017 {
14018 unsigned char c;
14019
14020 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
14021 + asm volatile(LOCK_PREFIX "incl %0\n"
14022 +
14023 +#ifdef CONFIG_PAX_REFCOUNT
14024 + "jno 0f\n"
14025 + LOCK_PREFIX "decl %0\n"
14026 + "int $4\n0:\n"
14027 + _ASM_EXTABLE(0b, 0b)
14028 +#endif
14029 +
14030 + "sete %1\n"
14031 + : "+m" (v->counter), "=qm" (c)
14032 + : : "memory");
14033 + return c != 0;
14034 +}
14035 +
14036 +/**
14037 + * atomic_inc_and_test_unchecked - increment and test
14038 + * @v: pointer of type atomic_unchecked_t
14039 + *
14040 + * Atomically increments @v by 1
14041 + * and returns true if the result is zero, or false for all
14042 + * other cases.
14043 + */
14044 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14045 +{
14046 + unsigned char c;
14047 +
14048 + asm volatile(LOCK_PREFIX "incl %0\n"
14049 + "sete %1\n"
14050 : "+m" (v->counter), "=qm" (c)
14051 : : "memory");
14052 return c != 0;
14053 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14054 {
14055 unsigned char c;
14056
14057 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14058 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14059 +
14060 +#ifdef CONFIG_PAX_REFCOUNT
14061 + "jno 0f\n"
14062 + LOCK_PREFIX "subl %2,%0\n"
14063 + "int $4\n0:\n"
14064 + _ASM_EXTABLE(0b, 0b)
14065 +#endif
14066 +
14067 + "sets %1\n"
14068 : "+m" (v->counter), "=qm" (c)
14069 : "ir" (i) : "memory");
14070 return c;
14071 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14072 */
14073 static inline int atomic_add_return(int i, atomic_t *v)
14074 {
14075 + return i + xadd_check_overflow(&v->counter, i);
14076 +}
14077 +
14078 +/**
14079 + * atomic_add_return_unchecked - add integer and return
14080 + * @i: integer value to add
14081 + * @v: pointer of type atomic_unchecked_t
14082 + *
14083 + * Atomically adds @i to @v and returns @i + @v
14084 + */
14085 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14086 +{
14087 return i + xadd(&v->counter, i);
14088 }
14089
14090 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14091 }
14092
14093 #define atomic_inc_return(v) (atomic_add_return(1, v))
14094 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14095 +{
14096 + return atomic_add_return_unchecked(1, v);
14097 +}
14098 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14099
14100 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14101 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14102 return cmpxchg(&v->counter, old, new);
14103 }
14104
14105 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14106 +{
14107 + return cmpxchg(&v->counter, old, new);
14108 +}
14109 +
14110 static inline int atomic_xchg(atomic_t *v, int new)
14111 {
14112 return xchg(&v->counter, new);
14113 }
14114
14115 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14116 +{
14117 + return xchg(&v->counter, new);
14118 +}
14119 +
14120 /**
14121 * __atomic_add_unless - add unless the number is already a given value
14122 * @v: pointer of type atomic_t
14123 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14124 */
14125 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14126 {
14127 - int c, old;
14128 + int c, old, new;
14129 c = atomic_read(v);
14130 for (;;) {
14131 - if (unlikely(c == (u)))
14132 + if (unlikely(c == u))
14133 break;
14134 - old = atomic_cmpxchg((v), c, c + (a));
14135 +
14136 + asm volatile("addl %2,%0\n"
14137 +
14138 +#ifdef CONFIG_PAX_REFCOUNT
14139 + "jno 0f\n"
14140 + "subl %2,%0\n"
14141 + "int $4\n0:\n"
14142 + _ASM_EXTABLE(0b, 0b)
14143 +#endif
14144 +
14145 + : "=r" (new)
14146 + : "0" (c), "ir" (a));
14147 +
14148 + old = atomic_cmpxchg(v, c, new);
14149 if (likely(old == c))
14150 break;
14151 c = old;
14152 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14153 }
14154
14155 /**
14156 + * atomic_inc_not_zero_hint - increment if not null
14157 + * @v: pointer of type atomic_t
14158 + * @hint: probable value of the atomic before the increment
14159 + *
14160 + * This version of atomic_inc_not_zero() gives a hint of probable
14161 + * value of the atomic. This helps processor to not read the memory
14162 + * before doing the atomic read/modify/write cycle, lowering
14163 + * number of bus transactions on some arches.
14164 + *
14165 + * Returns: 0 if increment was not done, 1 otherwise.
14166 + */
14167 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14168 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14169 +{
14170 + int val, c = hint, new;
14171 +
14172 + /* sanity test, should be removed by compiler if hint is a constant */
14173 + if (!hint)
14174 + return __atomic_add_unless(v, 1, 0);
14175 +
14176 + do {
14177 + asm volatile("incl %0\n"
14178 +
14179 +#ifdef CONFIG_PAX_REFCOUNT
14180 + "jno 0f\n"
14181 + "decl %0\n"
14182 + "int $4\n0:\n"
14183 + _ASM_EXTABLE(0b, 0b)
14184 +#endif
14185 +
14186 + : "=r" (new)
14187 + : "0" (c));
14188 +
14189 + val = atomic_cmpxchg(v, c, new);
14190 + if (val == c)
14191 + return 1;
14192 + c = val;
14193 + } while (c);
14194 +
14195 + return 0;
14196 +}
14197 +
14198 +/**
14199 * atomic_inc_short - increment of a short integer
14200 * @v: pointer to type int
14201 *
14202 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14203 #endif
14204
14205 /* These are x86-specific, used by some header files */
14206 -#define atomic_clear_mask(mask, addr) \
14207 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14208 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14209 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14210 +{
14211 + asm volatile(LOCK_PREFIX "andl %1,%0"
14212 + : "+m" (v->counter)
14213 + : "r" (~(mask))
14214 + : "memory");
14215 +}
14216
14217 -#define atomic_set_mask(mask, addr) \
14218 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14219 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14220 - : "memory")
14221 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14222 +{
14223 + asm volatile(LOCK_PREFIX "andl %1,%0"
14224 + : "+m" (v->counter)
14225 + : "r" (~(mask))
14226 + : "memory");
14227 +}
14228 +
14229 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14230 +{
14231 + asm volatile(LOCK_PREFIX "orl %1,%0"
14232 + : "+m" (v->counter)
14233 + : "r" (mask)
14234 + : "memory");
14235 +}
14236 +
14237 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14238 +{
14239 + asm volatile(LOCK_PREFIX "orl %1,%0"
14240 + : "+m" (v->counter)
14241 + : "r" (mask)
14242 + : "memory");
14243 +}
14244
14245 /* Atomic operations are already serializing on x86 */
14246 #define smp_mb__before_atomic_dec() barrier()
14247 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14248 index b154de7..aadebd8 100644
14249 --- a/arch/x86/include/asm/atomic64_32.h
14250 +++ b/arch/x86/include/asm/atomic64_32.h
14251 @@ -12,6 +12,14 @@ typedef struct {
14252 u64 __aligned(8) counter;
14253 } atomic64_t;
14254
14255 +#ifdef CONFIG_PAX_REFCOUNT
14256 +typedef struct {
14257 + u64 __aligned(8) counter;
14258 +} atomic64_unchecked_t;
14259 +#else
14260 +typedef atomic64_t atomic64_unchecked_t;
14261 +#endif
14262 +
14263 #define ATOMIC64_INIT(val) { (val) }
14264
14265 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14266 @@ -37,21 +45,31 @@ typedef struct {
14267 ATOMIC64_DECL_ONE(sym##_386)
14268
14269 ATOMIC64_DECL_ONE(add_386);
14270 +ATOMIC64_DECL_ONE(add_unchecked_386);
14271 ATOMIC64_DECL_ONE(sub_386);
14272 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14273 ATOMIC64_DECL_ONE(inc_386);
14274 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14275 ATOMIC64_DECL_ONE(dec_386);
14276 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14277 #endif
14278
14279 #define alternative_atomic64(f, out, in...) \
14280 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14281
14282 ATOMIC64_DECL(read);
14283 +ATOMIC64_DECL(read_unchecked);
14284 ATOMIC64_DECL(set);
14285 +ATOMIC64_DECL(set_unchecked);
14286 ATOMIC64_DECL(xchg);
14287 ATOMIC64_DECL(add_return);
14288 +ATOMIC64_DECL(add_return_unchecked);
14289 ATOMIC64_DECL(sub_return);
14290 +ATOMIC64_DECL(sub_return_unchecked);
14291 ATOMIC64_DECL(inc_return);
14292 +ATOMIC64_DECL(inc_return_unchecked);
14293 ATOMIC64_DECL(dec_return);
14294 +ATOMIC64_DECL(dec_return_unchecked);
14295 ATOMIC64_DECL(dec_if_positive);
14296 ATOMIC64_DECL(inc_not_zero);
14297 ATOMIC64_DECL(add_unless);
14298 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14299 }
14300
14301 /**
14302 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14303 + * @p: pointer to type atomic64_unchecked_t
14304 + * @o: expected value
14305 + * @n: new value
14306 + *
14307 + * Atomically sets @v to @n if it was equal to @o and returns
14308 + * the old value.
14309 + */
14310 +
14311 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14312 +{
14313 + return cmpxchg64(&v->counter, o, n);
14314 +}
14315 +
14316 +/**
14317 * atomic64_xchg - xchg atomic64 variable
14318 * @v: pointer to type atomic64_t
14319 * @n: value to assign
14320 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14321 }
14322
14323 /**
14324 + * atomic64_set_unchecked - set atomic64 variable
14325 + * @v: pointer to type atomic64_unchecked_t
14326 + * @n: value to assign
14327 + *
14328 + * Atomically sets the value of @v to @n.
14329 + */
14330 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14331 +{
14332 + unsigned high = (unsigned)(i >> 32);
14333 + unsigned low = (unsigned)i;
14334 + alternative_atomic64(set, /* no output */,
14335 + "S" (v), "b" (low), "c" (high)
14336 + : "eax", "edx", "memory");
14337 +}
14338 +
14339 +/**
14340 * atomic64_read - read atomic64 variable
14341 * @v: pointer to type atomic64_t
14342 *
14343 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14344 }
14345
14346 /**
14347 + * atomic64_read_unchecked - read atomic64 variable
14348 + * @v: pointer to type atomic64_unchecked_t
14349 + *
14350 + * Atomically reads the value of @v and returns it.
14351 + */
14352 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14353 +{
14354 + long long r;
14355 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14356 + return r;
14357 + }
14358 +
14359 +/**
14360 * atomic64_add_return - add and return
14361 * @i: integer value to add
14362 * @v: pointer to type atomic64_t
14363 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14364 return i;
14365 }
14366
14367 +/**
14368 + * atomic64_add_return_unchecked - add and return
14369 + * @i: integer value to add
14370 + * @v: pointer to type atomic64_unchecked_t
14371 + *
14372 + * Atomically adds @i to @v and returns @i + *@v
14373 + */
14374 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14375 +{
14376 + alternative_atomic64(add_return_unchecked,
14377 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14378 + ASM_NO_INPUT_CLOBBER("memory"));
14379 + return i;
14380 +}
14381 +
14382 /*
14383 * Other variants with different arithmetic operators:
14384 */
14385 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14386 return a;
14387 }
14388
14389 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14390 +{
14391 + long long a;
14392 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14393 + "S" (v) : "memory", "ecx");
14394 + return a;
14395 +}
14396 +
14397 static inline long long atomic64_dec_return(atomic64_t *v)
14398 {
14399 long long a;
14400 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14401 }
14402
14403 /**
14404 + * atomic64_add_unchecked - add integer to atomic64 variable
14405 + * @i: integer value to add
14406 + * @v: pointer to type atomic64_unchecked_t
14407 + *
14408 + * Atomically adds @i to @v.
14409 + */
14410 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14411 +{
14412 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14413 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14414 + ASM_NO_INPUT_CLOBBER("memory"));
14415 + return i;
14416 +}
14417 +
14418 +/**
14419 * atomic64_sub - subtract the atomic64 variable
14420 * @i: integer value to subtract
14421 * @v: pointer to type atomic64_t
14422 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14423 index 0e1cbfc..5623683 100644
14424 --- a/arch/x86/include/asm/atomic64_64.h
14425 +++ b/arch/x86/include/asm/atomic64_64.h
14426 @@ -18,7 +18,19 @@
14427 */
14428 static inline long atomic64_read(const atomic64_t *v)
14429 {
14430 - return (*(volatile long *)&(v)->counter);
14431 + return (*(volatile const long *)&(v)->counter);
14432 +}
14433 +
14434 +/**
14435 + * atomic64_read_unchecked - read atomic64 variable
14436 + * @v: pointer of type atomic64_unchecked_t
14437 + *
14438 + * Atomically reads the value of @v.
14439 + * Doesn't imply a read memory barrier.
14440 + */
14441 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14442 +{
14443 + return (*(volatile const long *)&(v)->counter);
14444 }
14445
14446 /**
14447 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14448 }
14449
14450 /**
14451 + * atomic64_set_unchecked - set atomic64 variable
14452 + * @v: pointer to type atomic64_unchecked_t
14453 + * @i: required value
14454 + *
14455 + * Atomically sets the value of @v to @i.
14456 + */
14457 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14458 +{
14459 + v->counter = i;
14460 +}
14461 +
14462 +/**
14463 * atomic64_add - add integer to atomic64 variable
14464 * @i: integer value to add
14465 * @v: pointer to type atomic64_t
14466 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14467 */
14468 static inline void atomic64_add(long i, atomic64_t *v)
14469 {
14470 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14471 +
14472 +#ifdef CONFIG_PAX_REFCOUNT
14473 + "jno 0f\n"
14474 + LOCK_PREFIX "subq %1,%0\n"
14475 + "int $4\n0:\n"
14476 + _ASM_EXTABLE(0b, 0b)
14477 +#endif
14478 +
14479 + : "=m" (v->counter)
14480 + : "er" (i), "m" (v->counter));
14481 +}
14482 +
14483 +/**
14484 + * atomic64_add_unchecked - add integer to atomic64 variable
14485 + * @i: integer value to add
14486 + * @v: pointer to type atomic64_unchecked_t
14487 + *
14488 + * Atomically adds @i to @v.
14489 + */
14490 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14491 +{
14492 asm volatile(LOCK_PREFIX "addq %1,%0"
14493 : "=m" (v->counter)
14494 : "er" (i), "m" (v->counter));
14495 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14496 */
14497 static inline void atomic64_sub(long i, atomic64_t *v)
14498 {
14499 - asm volatile(LOCK_PREFIX "subq %1,%0"
14500 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14501 +
14502 +#ifdef CONFIG_PAX_REFCOUNT
14503 + "jno 0f\n"
14504 + LOCK_PREFIX "addq %1,%0\n"
14505 + "int $4\n0:\n"
14506 + _ASM_EXTABLE(0b, 0b)
14507 +#endif
14508 +
14509 + : "=m" (v->counter)
14510 + : "er" (i), "m" (v->counter));
14511 +}
14512 +
14513 +/**
14514 + * atomic64_sub_unchecked - subtract the atomic64 variable
14515 + * @i: integer value to subtract
14516 + * @v: pointer to type atomic64_unchecked_t
14517 + *
14518 + * Atomically subtracts @i from @v.
14519 + */
14520 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14521 +{
14522 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14523 : "=m" (v->counter)
14524 : "er" (i), "m" (v->counter));
14525 }
14526 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14527 {
14528 unsigned char c;
14529
14530 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14531 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14532 +
14533 +#ifdef CONFIG_PAX_REFCOUNT
14534 + "jno 0f\n"
14535 + LOCK_PREFIX "addq %2,%0\n"
14536 + "int $4\n0:\n"
14537 + _ASM_EXTABLE(0b, 0b)
14538 +#endif
14539 +
14540 + "sete %1\n"
14541 : "=m" (v->counter), "=qm" (c)
14542 : "er" (i), "m" (v->counter) : "memory");
14543 return c;
14544 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14545 */
14546 static inline void atomic64_inc(atomic64_t *v)
14547 {
14548 + asm volatile(LOCK_PREFIX "incq %0\n"
14549 +
14550 +#ifdef CONFIG_PAX_REFCOUNT
14551 + "jno 0f\n"
14552 + LOCK_PREFIX "decq %0\n"
14553 + "int $4\n0:\n"
14554 + _ASM_EXTABLE(0b, 0b)
14555 +#endif
14556 +
14557 + : "=m" (v->counter)
14558 + : "m" (v->counter));
14559 +}
14560 +
14561 +/**
14562 + * atomic64_inc_unchecked - increment atomic64 variable
14563 + * @v: pointer to type atomic64_unchecked_t
14564 + *
14565 + * Atomically increments @v by 1.
14566 + */
14567 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14568 +{
14569 asm volatile(LOCK_PREFIX "incq %0"
14570 : "=m" (v->counter)
14571 : "m" (v->counter));
14572 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14573 */
14574 static inline void atomic64_dec(atomic64_t *v)
14575 {
14576 - asm volatile(LOCK_PREFIX "decq %0"
14577 + asm volatile(LOCK_PREFIX "decq %0\n"
14578 +
14579 +#ifdef CONFIG_PAX_REFCOUNT
14580 + "jno 0f\n"
14581 + LOCK_PREFIX "incq %0\n"
14582 + "int $4\n0:\n"
14583 + _ASM_EXTABLE(0b, 0b)
14584 +#endif
14585 +
14586 + : "=m" (v->counter)
14587 + : "m" (v->counter));
14588 +}
14589 +
14590 +/**
14591 + * atomic64_dec_unchecked - decrement atomic64 variable
14592 + * @v: pointer to type atomic64_t
14593 + *
14594 + * Atomically decrements @v by 1.
14595 + */
14596 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14597 +{
14598 + asm volatile(LOCK_PREFIX "decq %0\n"
14599 : "=m" (v->counter)
14600 : "m" (v->counter));
14601 }
14602 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14603 {
14604 unsigned char c;
14605
14606 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14607 + asm volatile(LOCK_PREFIX "decq %0\n"
14608 +
14609 +#ifdef CONFIG_PAX_REFCOUNT
14610 + "jno 0f\n"
14611 + LOCK_PREFIX "incq %0\n"
14612 + "int $4\n0:\n"
14613 + _ASM_EXTABLE(0b, 0b)
14614 +#endif
14615 +
14616 + "sete %1\n"
14617 : "=m" (v->counter), "=qm" (c)
14618 : "m" (v->counter) : "memory");
14619 return c != 0;
14620 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14621 {
14622 unsigned char c;
14623
14624 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14625 + asm volatile(LOCK_PREFIX "incq %0\n"
14626 +
14627 +#ifdef CONFIG_PAX_REFCOUNT
14628 + "jno 0f\n"
14629 + LOCK_PREFIX "decq %0\n"
14630 + "int $4\n0:\n"
14631 + _ASM_EXTABLE(0b, 0b)
14632 +#endif
14633 +
14634 + "sete %1\n"
14635 : "=m" (v->counter), "=qm" (c)
14636 : "m" (v->counter) : "memory");
14637 return c != 0;
14638 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14639 {
14640 unsigned char c;
14641
14642 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14643 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14644 +
14645 +#ifdef CONFIG_PAX_REFCOUNT
14646 + "jno 0f\n"
14647 + LOCK_PREFIX "subq %2,%0\n"
14648 + "int $4\n0:\n"
14649 + _ASM_EXTABLE(0b, 0b)
14650 +#endif
14651 +
14652 + "sets %1\n"
14653 : "=m" (v->counter), "=qm" (c)
14654 : "er" (i), "m" (v->counter) : "memory");
14655 return c;
14656 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14657 */
14658 static inline long atomic64_add_return(long i, atomic64_t *v)
14659 {
14660 + return i + xadd_check_overflow(&v->counter, i);
14661 +}
14662 +
14663 +/**
14664 + * atomic64_add_return_unchecked - add and return
14665 + * @i: integer value to add
14666 + * @v: pointer to type atomic64_unchecked_t
14667 + *
14668 + * Atomically adds @i to @v and returns @i + @v
14669 + */
14670 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14671 +{
14672 return i + xadd(&v->counter, i);
14673 }
14674
14675 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14676 }
14677
14678 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14679 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14680 +{
14681 + return atomic64_add_return_unchecked(1, v);
14682 +}
14683 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14684
14685 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14686 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14687 return cmpxchg(&v->counter, old, new);
14688 }
14689
14690 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14691 +{
14692 + return cmpxchg(&v->counter, old, new);
14693 +}
14694 +
14695 static inline long atomic64_xchg(atomic64_t *v, long new)
14696 {
14697 return xchg(&v->counter, new);
14698 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14699 */
14700 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14701 {
14702 - long c, old;
14703 + long c, old, new;
14704 c = atomic64_read(v);
14705 for (;;) {
14706 - if (unlikely(c == (u)))
14707 + if (unlikely(c == u))
14708 break;
14709 - old = atomic64_cmpxchg((v), c, c + (a));
14710 +
14711 + asm volatile("add %2,%0\n"
14712 +
14713 +#ifdef CONFIG_PAX_REFCOUNT
14714 + "jno 0f\n"
14715 + "sub %2,%0\n"
14716 + "int $4\n0:\n"
14717 + _ASM_EXTABLE(0b, 0b)
14718 +#endif
14719 +
14720 + : "=r" (new)
14721 + : "0" (c), "ir" (a));
14722 +
14723 + old = atomic64_cmpxchg(v, c, new);
14724 if (likely(old == c))
14725 break;
14726 c = old;
14727 }
14728 - return c != (u);
14729 + return c != u;
14730 }
14731
14732 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14733 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14734 index 6dfd019..28e188d 100644
14735 --- a/arch/x86/include/asm/bitops.h
14736 +++ b/arch/x86/include/asm/bitops.h
14737 @@ -40,7 +40,7 @@
14738 * a mask operation on a byte.
14739 */
14740 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14741 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14742 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14743 #define CONST_MASK(nr) (1 << ((nr) & 7))
14744
14745 /**
14746 @@ -486,7 +486,7 @@ static inline int fls(int x)
14747 * at position 64.
14748 */
14749 #ifdef CONFIG_X86_64
14750 -static __always_inline int fls64(__u64 x)
14751 +static __always_inline long fls64(__u64 x)
14752 {
14753 int bitpos = -1;
14754 /*
14755 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14756 index 4fa687a..60f2d39 100644
14757 --- a/arch/x86/include/asm/boot.h
14758 +++ b/arch/x86/include/asm/boot.h
14759 @@ -6,10 +6,15 @@
14760 #include <uapi/asm/boot.h>
14761
14762 /* Physical address where kernel should be loaded. */
14763 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14764 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14765 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14766 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14767
14768 +#ifndef __ASSEMBLY__
14769 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14770 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14771 +#endif
14772 +
14773 /* Minimum kernel alignment, as a power of two */
14774 #ifdef CONFIG_X86_64
14775 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14776 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14777 index 48f99f1..d78ebf9 100644
14778 --- a/arch/x86/include/asm/cache.h
14779 +++ b/arch/x86/include/asm/cache.h
14780 @@ -5,12 +5,13 @@
14781
14782 /* L1 cache line size */
14783 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14784 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14785 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14786
14787 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14788 +#define __read_only __attribute__((__section__(".data..read_only")))
14789
14790 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14791 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14792 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14793
14794 #ifdef CONFIG_X86_VSMP
14795 #ifdef CONFIG_SMP
14796 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14797 index 9863ee3..4a1f8e1 100644
14798 --- a/arch/x86/include/asm/cacheflush.h
14799 +++ b/arch/x86/include/asm/cacheflush.h
14800 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14801 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14802
14803 if (pg_flags == _PGMT_DEFAULT)
14804 - return -1;
14805 + return ~0UL;
14806 else if (pg_flags == _PGMT_WC)
14807 return _PAGE_CACHE_WC;
14808 else if (pg_flags == _PGMT_UC_MINUS)
14809 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14810 index f50de69..2b0a458 100644
14811 --- a/arch/x86/include/asm/checksum_32.h
14812 +++ b/arch/x86/include/asm/checksum_32.h
14813 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14814 int len, __wsum sum,
14815 int *src_err_ptr, int *dst_err_ptr);
14816
14817 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14818 + int len, __wsum sum,
14819 + int *src_err_ptr, int *dst_err_ptr);
14820 +
14821 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14822 + int len, __wsum sum,
14823 + int *src_err_ptr, int *dst_err_ptr);
14824 +
14825 /*
14826 * Note: when you get a NULL pointer exception here this means someone
14827 * passed in an incorrect kernel address to one of these functions.
14828 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14829
14830 might_sleep();
14831 stac();
14832 - ret = csum_partial_copy_generic((__force void *)src, dst,
14833 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14834 len, sum, err_ptr, NULL);
14835 clac();
14836
14837 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14838 might_sleep();
14839 if (access_ok(VERIFY_WRITE, dst, len)) {
14840 stac();
14841 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14842 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14843 len, sum, NULL, err_ptr);
14844 clac();
14845 return ret;
14846 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14847 index d47786a..ce1b05d 100644
14848 --- a/arch/x86/include/asm/cmpxchg.h
14849 +++ b/arch/x86/include/asm/cmpxchg.h
14850 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14851 __compiletime_error("Bad argument size for cmpxchg");
14852 extern void __xadd_wrong_size(void)
14853 __compiletime_error("Bad argument size for xadd");
14854 +extern void __xadd_check_overflow_wrong_size(void)
14855 + __compiletime_error("Bad argument size for xadd_check_overflow");
14856 extern void __add_wrong_size(void)
14857 __compiletime_error("Bad argument size for add");
14858 +extern void __add_check_overflow_wrong_size(void)
14859 + __compiletime_error("Bad argument size for add_check_overflow");
14860
14861 /*
14862 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14863 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14864 __ret; \
14865 })
14866
14867 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14868 + ({ \
14869 + __typeof__ (*(ptr)) __ret = (arg); \
14870 + switch (sizeof(*(ptr))) { \
14871 + case __X86_CASE_L: \
14872 + asm volatile (lock #op "l %0, %1\n" \
14873 + "jno 0f\n" \
14874 + "mov %0,%1\n" \
14875 + "int $4\n0:\n" \
14876 + _ASM_EXTABLE(0b, 0b) \
14877 + : "+r" (__ret), "+m" (*(ptr)) \
14878 + : : "memory", "cc"); \
14879 + break; \
14880 + case __X86_CASE_Q: \
14881 + asm volatile (lock #op "q %q0, %1\n" \
14882 + "jno 0f\n" \
14883 + "mov %0,%1\n" \
14884 + "int $4\n0:\n" \
14885 + _ASM_EXTABLE(0b, 0b) \
14886 + : "+r" (__ret), "+m" (*(ptr)) \
14887 + : : "memory", "cc"); \
14888 + break; \
14889 + default: \
14890 + __ ## op ## _check_overflow_wrong_size(); \
14891 + } \
14892 + __ret; \
14893 + })
14894 +
14895 /*
14896 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14897 * Since this is generally used to protect other memory information, we
14898 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14899 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14900 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14901
14902 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14903 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14904 +
14905 #define __add(ptr, inc, lock) \
14906 ({ \
14907 __typeof__ (*(ptr)) __ret = (inc); \
14908 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14909 index 59c6c40..5e0b22c 100644
14910 --- a/arch/x86/include/asm/compat.h
14911 +++ b/arch/x86/include/asm/compat.h
14912 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14913 typedef u32 compat_uint_t;
14914 typedef u32 compat_ulong_t;
14915 typedef u64 __attribute__((aligned(4))) compat_u64;
14916 -typedef u32 compat_uptr_t;
14917 +typedef u32 __user compat_uptr_t;
14918
14919 struct compat_timespec {
14920 compat_time_t tv_sec;
14921 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14922 index 47538a6..44902d1 100644
14923 --- a/arch/x86/include/asm/cpufeature.h
14924 +++ b/arch/x86/include/asm/cpufeature.h
14925 @@ -203,7 +203,7 @@
14926 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14927 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14928 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14929 -
14930 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14931
14932 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14933 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14934 @@ -211,7 +211,7 @@
14935 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14936 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14937 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14938 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14939 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14940 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14941 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14942 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14943 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14944 #undef cpu_has_centaur_mcr
14945 #define cpu_has_centaur_mcr 0
14946
14947 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14948 #endif /* CONFIG_X86_64 */
14949
14950 #if __GNUC__ >= 4
14951 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14952
14953 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14954 t_warn:
14955 - warn_pre_alternatives();
14956 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14957 + warn_pre_alternatives();
14958 return false;
14959 #endif
14960 #else /* GCC_VERSION >= 40500 */
14961 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14962 ".section .discard,\"aw\",@progbits\n"
14963 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14964 ".previous\n"
14965 - ".section .altinstr_replacement,\"ax\"\n"
14966 + ".section .altinstr_replacement,\"a\"\n"
14967 "3: movb $1,%0\n"
14968 "4:\n"
14969 ".previous\n"
14970 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14971 " .byte 2b - 1b\n" /* src len */
14972 " .byte 4f - 3f\n" /* repl len */
14973 ".previous\n"
14974 - ".section .altinstr_replacement,\"ax\"\n"
14975 + ".section .altinstr_replacement,\"a\"\n"
14976 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14977 "4:\n"
14978 ".previous\n"
14979 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14980 ".section .discard,\"aw\",@progbits\n"
14981 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14982 ".previous\n"
14983 - ".section .altinstr_replacement,\"ax\"\n"
14984 + ".section .altinstr_replacement,\"a\"\n"
14985 "3: movb $0,%0\n"
14986 "4:\n"
14987 ".previous\n"
14988 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14989 ".section .discard,\"aw\",@progbits\n"
14990 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14991 ".previous\n"
14992 - ".section .altinstr_replacement,\"ax\"\n"
14993 + ".section .altinstr_replacement,\"a\"\n"
14994 "5: movb $1,%0\n"
14995 "6:\n"
14996 ".previous\n"
14997 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14998 index b90e5df..b462c91 100644
14999 --- a/arch/x86/include/asm/desc.h
15000 +++ b/arch/x86/include/asm/desc.h
15001 @@ -4,6 +4,7 @@
15002 #include <asm/desc_defs.h>
15003 #include <asm/ldt.h>
15004 #include <asm/mmu.h>
15005 +#include <asm/pgtable.h>
15006
15007 #include <linux/smp.h>
15008 #include <linux/percpu.h>
15009 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15010
15011 desc->type = (info->read_exec_only ^ 1) << 1;
15012 desc->type |= info->contents << 2;
15013 + desc->type |= info->seg_not_present ^ 1;
15014
15015 desc->s = 1;
15016 desc->dpl = 0x3;
15017 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15018 }
15019
15020 extern struct desc_ptr idt_descr;
15021 -extern gate_desc idt_table[];
15022 -extern struct desc_ptr debug_idt_descr;
15023 -extern gate_desc debug_idt_table[];
15024 -
15025 -struct gdt_page {
15026 - struct desc_struct gdt[GDT_ENTRIES];
15027 -} __attribute__((aligned(PAGE_SIZE)));
15028 -
15029 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15030 +extern gate_desc idt_table[IDT_ENTRIES];
15031 +extern const struct desc_ptr debug_idt_descr;
15032 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15033
15034 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15035 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15036 {
15037 - return per_cpu(gdt_page, cpu).gdt;
15038 + return cpu_gdt_table[cpu];
15039 }
15040
15041 #ifdef CONFIG_X86_64
15042 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15043 unsigned long base, unsigned dpl, unsigned flags,
15044 unsigned short seg)
15045 {
15046 - gate->a = (seg << 16) | (base & 0xffff);
15047 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15048 + gate->gate.offset_low = base;
15049 + gate->gate.seg = seg;
15050 + gate->gate.reserved = 0;
15051 + gate->gate.type = type;
15052 + gate->gate.s = 0;
15053 + gate->gate.dpl = dpl;
15054 + gate->gate.p = 1;
15055 + gate->gate.offset_high = base >> 16;
15056 }
15057
15058 #endif
15059 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15060
15061 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15062 {
15063 + pax_open_kernel();
15064 memcpy(&idt[entry], gate, sizeof(*gate));
15065 + pax_close_kernel();
15066 }
15067
15068 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15069 {
15070 + pax_open_kernel();
15071 memcpy(&ldt[entry], desc, 8);
15072 + pax_close_kernel();
15073 }
15074
15075 static inline void
15076 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15077 default: size = sizeof(*gdt); break;
15078 }
15079
15080 + pax_open_kernel();
15081 memcpy(&gdt[entry], desc, size);
15082 + pax_close_kernel();
15083 }
15084
15085 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15086 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15087
15088 static inline void native_load_tr_desc(void)
15089 {
15090 + pax_open_kernel();
15091 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15092 + pax_close_kernel();
15093 }
15094
15095 static inline void native_load_gdt(const struct desc_ptr *dtr)
15096 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15097 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15098 unsigned int i;
15099
15100 + pax_open_kernel();
15101 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15102 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15103 + pax_close_kernel();
15104 }
15105
15106 #define _LDT_empty(info) \
15107 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15108 preempt_enable();
15109 }
15110
15111 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15112 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15113 {
15114 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15115 }
15116 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15117 }
15118
15119 #ifdef CONFIG_X86_64
15120 -static inline void set_nmi_gate(int gate, void *addr)
15121 +static inline void set_nmi_gate(int gate, const void *addr)
15122 {
15123 gate_desc s;
15124
15125 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15126 #endif
15127
15128 #ifdef CONFIG_TRACING
15129 -extern struct desc_ptr trace_idt_descr;
15130 -extern gate_desc trace_idt_table[];
15131 +extern const struct desc_ptr trace_idt_descr;
15132 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15133 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15134 {
15135 write_idt_entry(trace_idt_table, entry, gate);
15136 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15137 }
15138 #endif
15139
15140 -static inline void _set_gate(int gate, unsigned type, void *addr,
15141 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15142 unsigned dpl, unsigned ist, unsigned seg)
15143 {
15144 gate_desc s;
15145 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15146 * Pentium F0 0F bugfix can have resulted in the mapped
15147 * IDT being write-protected.
15148 */
15149 -static inline void set_intr_gate(unsigned int n, void *addr)
15150 +static inline void set_intr_gate(unsigned int n, const void *addr)
15151 {
15152 BUG_ON((unsigned)n > 0xFF);
15153 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15154 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15155 /*
15156 * This routine sets up an interrupt gate at directory privilege level 3.
15157 */
15158 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15159 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15160 {
15161 BUG_ON((unsigned)n > 0xFF);
15162 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15163 }
15164
15165 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15166 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15167 {
15168 BUG_ON((unsigned)n > 0xFF);
15169 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15170 }
15171
15172 -static inline void set_trap_gate(unsigned int n, void *addr)
15173 +static inline void set_trap_gate(unsigned int n, const void *addr)
15174 {
15175 BUG_ON((unsigned)n > 0xFF);
15176 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15177 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15178 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15179 {
15180 BUG_ON((unsigned)n > 0xFF);
15181 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15182 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15183 }
15184
15185 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15186 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15187 {
15188 BUG_ON((unsigned)n > 0xFF);
15189 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15190 }
15191
15192 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15193 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15194 {
15195 BUG_ON((unsigned)n > 0xFF);
15196 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15197 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15198 else
15199 load_idt((const struct desc_ptr *)&idt_descr);
15200 }
15201 +
15202 +#ifdef CONFIG_X86_32
15203 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15204 +{
15205 + struct desc_struct d;
15206 +
15207 + if (likely(limit))
15208 + limit = (limit - 1UL) >> PAGE_SHIFT;
15209 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15210 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15211 +}
15212 +#endif
15213 +
15214 #endif /* _ASM_X86_DESC_H */
15215 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15216 index 278441f..b95a174 100644
15217 --- a/arch/x86/include/asm/desc_defs.h
15218 +++ b/arch/x86/include/asm/desc_defs.h
15219 @@ -31,6 +31,12 @@ struct desc_struct {
15220 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15221 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15222 };
15223 + struct {
15224 + u16 offset_low;
15225 + u16 seg;
15226 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15227 + unsigned offset_high: 16;
15228 + } gate;
15229 };
15230 } __attribute__((packed));
15231
15232 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15233 index ced283a..ffe04cc 100644
15234 --- a/arch/x86/include/asm/div64.h
15235 +++ b/arch/x86/include/asm/div64.h
15236 @@ -39,7 +39,7 @@
15237 __mod; \
15238 })
15239
15240 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15241 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15242 {
15243 union {
15244 u64 v64;
15245 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15246 index 9c999c1..3860cb8 100644
15247 --- a/arch/x86/include/asm/elf.h
15248 +++ b/arch/x86/include/asm/elf.h
15249 @@ -243,7 +243,25 @@ extern int force_personality32;
15250 the loader. We need to make sure that it is out of the way of the program
15251 that it will "exec", and that there is sufficient room for the brk. */
15252
15253 +#ifdef CONFIG_PAX_SEGMEXEC
15254 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15255 +#else
15256 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15257 +#endif
15258 +
15259 +#ifdef CONFIG_PAX_ASLR
15260 +#ifdef CONFIG_X86_32
15261 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15262 +
15263 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15264 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15265 +#else
15266 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15267 +
15268 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15269 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15270 +#endif
15271 +#endif
15272
15273 /* This yields a mask that user programs can use to figure out what
15274 instruction set this CPU supports. This could be done in user space,
15275 @@ -296,16 +314,12 @@ do { \
15276
15277 #define ARCH_DLINFO \
15278 do { \
15279 - if (vdso_enabled) \
15280 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15281 - (unsigned long)current->mm->context.vdso); \
15282 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15283 } while (0)
15284
15285 #define ARCH_DLINFO_X32 \
15286 do { \
15287 - if (vdso_enabled) \
15288 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15289 - (unsigned long)current->mm->context.vdso); \
15290 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15291 } while (0)
15292
15293 #define AT_SYSINFO 32
15294 @@ -320,7 +334,7 @@ else \
15295
15296 #endif /* !CONFIG_X86_32 */
15297
15298 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15299 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15300
15301 #define VDSO_ENTRY \
15302 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15303 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15304 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15305 #define compat_arch_setup_additional_pages syscall32_setup_pages
15306
15307 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15308 -#define arch_randomize_brk arch_randomize_brk
15309 -
15310 /*
15311 * True on X86_32 or when emulating IA32 on X86_64
15312 */
15313 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15314 index 77a99ac..39ff7f5 100644
15315 --- a/arch/x86/include/asm/emergency-restart.h
15316 +++ b/arch/x86/include/asm/emergency-restart.h
15317 @@ -1,6 +1,6 @@
15318 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15319 #define _ASM_X86_EMERGENCY_RESTART_H
15320
15321 -extern void machine_emergency_restart(void);
15322 +extern void machine_emergency_restart(void) __noreturn;
15323
15324 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15325 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15326 index 4d0bda7..221da4d 100644
15327 --- a/arch/x86/include/asm/fpu-internal.h
15328 +++ b/arch/x86/include/asm/fpu-internal.h
15329 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15330 #define user_insn(insn, output, input...) \
15331 ({ \
15332 int err; \
15333 + pax_open_userland(); \
15334 asm volatile(ASM_STAC "\n" \
15335 - "1:" #insn "\n\t" \
15336 + "1:" \
15337 + __copyuser_seg \
15338 + #insn "\n\t" \
15339 "2: " ASM_CLAC "\n" \
15340 ".section .fixup,\"ax\"\n" \
15341 "3: movl $-1,%[err]\n" \
15342 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15343 _ASM_EXTABLE(1b, 3b) \
15344 : [err] "=r" (err), output \
15345 : "0"(0), input); \
15346 + pax_close_userland(); \
15347 err; \
15348 })
15349
15350 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15351 "emms\n\t" /* clear stack tags */
15352 "fildl %P[addr]", /* set F?P to defined value */
15353 X86_FEATURE_FXSAVE_LEAK,
15354 - [addr] "m" (tsk->thread.fpu.has_fpu));
15355 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15356
15357 return fpu_restore_checking(&tsk->thread.fpu);
15358 }
15359 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15360 index be27ba1..04a8801 100644
15361 --- a/arch/x86/include/asm/futex.h
15362 +++ b/arch/x86/include/asm/futex.h
15363 @@ -12,6 +12,7 @@
15364 #include <asm/smap.h>
15365
15366 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15367 + typecheck(u32 __user *, uaddr); \
15368 asm volatile("\t" ASM_STAC "\n" \
15369 "1:\t" insn "\n" \
15370 "2:\t" ASM_CLAC "\n" \
15371 @@ -20,15 +21,16 @@
15372 "\tjmp\t2b\n" \
15373 "\t.previous\n" \
15374 _ASM_EXTABLE(1b, 3b) \
15375 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15376 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15377 : "i" (-EFAULT), "0" (oparg), "1" (0))
15378
15379 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15380 + typecheck(u32 __user *, uaddr); \
15381 asm volatile("\t" ASM_STAC "\n" \
15382 "1:\tmovl %2, %0\n" \
15383 "\tmovl\t%0, %3\n" \
15384 "\t" insn "\n" \
15385 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15386 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15387 "\tjnz\t1b\n" \
15388 "3:\t" ASM_CLAC "\n" \
15389 "\t.section .fixup,\"ax\"\n" \
15390 @@ -38,7 +40,7 @@
15391 _ASM_EXTABLE(1b, 4b) \
15392 _ASM_EXTABLE(2b, 4b) \
15393 : "=&a" (oldval), "=&r" (ret), \
15394 - "+m" (*uaddr), "=&r" (tem) \
15395 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15396 : "r" (oparg), "i" (-EFAULT), "1" (0))
15397
15398 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15399 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15400
15401 pagefault_disable();
15402
15403 + pax_open_userland();
15404 switch (op) {
15405 case FUTEX_OP_SET:
15406 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15407 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15408 break;
15409 case FUTEX_OP_ADD:
15410 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15411 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15412 uaddr, oparg);
15413 break;
15414 case FUTEX_OP_OR:
15415 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15416 default:
15417 ret = -ENOSYS;
15418 }
15419 + pax_close_userland();
15420
15421 pagefault_enable();
15422
15423 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15424 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15425 return -EFAULT;
15426
15427 + pax_open_userland();
15428 asm volatile("\t" ASM_STAC "\n"
15429 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15430 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15431 "2:\t" ASM_CLAC "\n"
15432 "\t.section .fixup, \"ax\"\n"
15433 "3:\tmov %3, %0\n"
15434 "\tjmp 2b\n"
15435 "\t.previous\n"
15436 _ASM_EXTABLE(1b, 3b)
15437 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15438 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15439 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15440 : "memory"
15441 );
15442 + pax_close_userland();
15443
15444 *uval = oldval;
15445 return ret;
15446 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15447 index e4ac559..c1c0c87 100644
15448 --- a/arch/x86/include/asm/hw_irq.h
15449 +++ b/arch/x86/include/asm/hw_irq.h
15450 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15451 extern void enable_IO_APIC(void);
15452
15453 /* Statistics */
15454 -extern atomic_t irq_err_count;
15455 -extern atomic_t irq_mis_count;
15456 +extern atomic_unchecked_t irq_err_count;
15457 +extern atomic_unchecked_t irq_mis_count;
15458
15459 /* EISA */
15460 extern void eisa_set_level_irq(unsigned int irq);
15461 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15462 index a203659..9889f1c 100644
15463 --- a/arch/x86/include/asm/i8259.h
15464 +++ b/arch/x86/include/asm/i8259.h
15465 @@ -62,7 +62,7 @@ struct legacy_pic {
15466 void (*init)(int auto_eoi);
15467 int (*irq_pending)(unsigned int irq);
15468 void (*make_irq)(unsigned int irq);
15469 -};
15470 +} __do_const;
15471
15472 extern struct legacy_pic *legacy_pic;
15473 extern struct legacy_pic null_legacy_pic;
15474 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15475 index 34f69cb..6d95446 100644
15476 --- a/arch/x86/include/asm/io.h
15477 +++ b/arch/x86/include/asm/io.h
15478 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15479 "m" (*(volatile type __force *)addr) barrier); }
15480
15481 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15482 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15483 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15484 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15485 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15486
15487 build_mmio_read(__readb, "b", unsigned char, "=q", )
15488 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15489 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15490 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15491 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15492
15493 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15494 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15495 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15496 return ioremap_nocache(offset, size);
15497 }
15498
15499 -extern void iounmap(volatile void __iomem *addr);
15500 +extern void iounmap(const volatile void __iomem *addr);
15501
15502 extern void set_iounmap_nonlazy(void);
15503
15504 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15505
15506 #include <linux/vmalloc.h>
15507
15508 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15509 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15510 +{
15511 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15512 +}
15513 +
15514 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15515 +{
15516 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15517 +}
15518 +
15519 /*
15520 * Convert a virtual cached pointer to an uncached pointer
15521 */
15522 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15523 index bba3cf8..06bc8da 100644
15524 --- a/arch/x86/include/asm/irqflags.h
15525 +++ b/arch/x86/include/asm/irqflags.h
15526 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15527 sti; \
15528 sysexit
15529
15530 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15531 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15532 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15533 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15534 +
15535 #else
15536 #define INTERRUPT_RETURN iret
15537 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15538 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15539 index 5a6d287..f815789 100644
15540 --- a/arch/x86/include/asm/kprobes.h
15541 +++ b/arch/x86/include/asm/kprobes.h
15542 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15543 #define RELATIVEJUMP_SIZE 5
15544 #define RELATIVECALL_OPCODE 0xe8
15545 #define RELATIVE_ADDR_SIZE 4
15546 -#define MAX_STACK_SIZE 64
15547 -#define MIN_STACK_SIZE(ADDR) \
15548 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15549 - THREAD_SIZE - (unsigned long)(ADDR))) \
15550 - ? (MAX_STACK_SIZE) \
15551 - : (((unsigned long)current_thread_info()) + \
15552 - THREAD_SIZE - (unsigned long)(ADDR)))
15553 +#define MAX_STACK_SIZE 64UL
15554 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15555
15556 #define flush_insn_slot(p) do { } while (0)
15557
15558 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15559 index 2d89e39..baee879 100644
15560 --- a/arch/x86/include/asm/local.h
15561 +++ b/arch/x86/include/asm/local.h
15562 @@ -10,33 +10,97 @@ typedef struct {
15563 atomic_long_t a;
15564 } local_t;
15565
15566 +typedef struct {
15567 + atomic_long_unchecked_t a;
15568 +} local_unchecked_t;
15569 +
15570 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15571
15572 #define local_read(l) atomic_long_read(&(l)->a)
15573 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15574 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15575 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15576
15577 static inline void local_inc(local_t *l)
15578 {
15579 - asm volatile(_ASM_INC "%0"
15580 + asm volatile(_ASM_INC "%0\n"
15581 +
15582 +#ifdef CONFIG_PAX_REFCOUNT
15583 + "jno 0f\n"
15584 + _ASM_DEC "%0\n"
15585 + "int $4\n0:\n"
15586 + _ASM_EXTABLE(0b, 0b)
15587 +#endif
15588 +
15589 + : "+m" (l->a.counter));
15590 +}
15591 +
15592 +static inline void local_inc_unchecked(local_unchecked_t *l)
15593 +{
15594 + asm volatile(_ASM_INC "%0\n"
15595 : "+m" (l->a.counter));
15596 }
15597
15598 static inline void local_dec(local_t *l)
15599 {
15600 - asm volatile(_ASM_DEC "%0"
15601 + asm volatile(_ASM_DEC "%0\n"
15602 +
15603 +#ifdef CONFIG_PAX_REFCOUNT
15604 + "jno 0f\n"
15605 + _ASM_INC "%0\n"
15606 + "int $4\n0:\n"
15607 + _ASM_EXTABLE(0b, 0b)
15608 +#endif
15609 +
15610 + : "+m" (l->a.counter));
15611 +}
15612 +
15613 +static inline void local_dec_unchecked(local_unchecked_t *l)
15614 +{
15615 + asm volatile(_ASM_DEC "%0\n"
15616 : "+m" (l->a.counter));
15617 }
15618
15619 static inline void local_add(long i, local_t *l)
15620 {
15621 - asm volatile(_ASM_ADD "%1,%0"
15622 + asm volatile(_ASM_ADD "%1,%0\n"
15623 +
15624 +#ifdef CONFIG_PAX_REFCOUNT
15625 + "jno 0f\n"
15626 + _ASM_SUB "%1,%0\n"
15627 + "int $4\n0:\n"
15628 + _ASM_EXTABLE(0b, 0b)
15629 +#endif
15630 +
15631 + : "+m" (l->a.counter)
15632 + : "ir" (i));
15633 +}
15634 +
15635 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15636 +{
15637 + asm volatile(_ASM_ADD "%1,%0\n"
15638 : "+m" (l->a.counter)
15639 : "ir" (i));
15640 }
15641
15642 static inline void local_sub(long i, local_t *l)
15643 {
15644 - asm volatile(_ASM_SUB "%1,%0"
15645 + asm volatile(_ASM_SUB "%1,%0\n"
15646 +
15647 +#ifdef CONFIG_PAX_REFCOUNT
15648 + "jno 0f\n"
15649 + _ASM_ADD "%1,%0\n"
15650 + "int $4\n0:\n"
15651 + _ASM_EXTABLE(0b, 0b)
15652 +#endif
15653 +
15654 + : "+m" (l->a.counter)
15655 + : "ir" (i));
15656 +}
15657 +
15658 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15659 +{
15660 + asm volatile(_ASM_SUB "%1,%0\n"
15661 : "+m" (l->a.counter)
15662 : "ir" (i));
15663 }
15664 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15665 {
15666 unsigned char c;
15667
15668 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15669 + asm volatile(_ASM_SUB "%2,%0\n"
15670 +
15671 +#ifdef CONFIG_PAX_REFCOUNT
15672 + "jno 0f\n"
15673 + _ASM_ADD "%2,%0\n"
15674 + "int $4\n0:\n"
15675 + _ASM_EXTABLE(0b, 0b)
15676 +#endif
15677 +
15678 + "sete %1\n"
15679 : "+m" (l->a.counter), "=qm" (c)
15680 : "ir" (i) : "memory");
15681 return c;
15682 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15683 {
15684 unsigned char c;
15685
15686 - asm volatile(_ASM_DEC "%0; sete %1"
15687 + asm volatile(_ASM_DEC "%0\n"
15688 +
15689 +#ifdef CONFIG_PAX_REFCOUNT
15690 + "jno 0f\n"
15691 + _ASM_INC "%0\n"
15692 + "int $4\n0:\n"
15693 + _ASM_EXTABLE(0b, 0b)
15694 +#endif
15695 +
15696 + "sete %1\n"
15697 : "+m" (l->a.counter), "=qm" (c)
15698 : : "memory");
15699 return c != 0;
15700 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15701 {
15702 unsigned char c;
15703
15704 - asm volatile(_ASM_INC "%0; sete %1"
15705 + asm volatile(_ASM_INC "%0\n"
15706 +
15707 +#ifdef CONFIG_PAX_REFCOUNT
15708 + "jno 0f\n"
15709 + _ASM_DEC "%0\n"
15710 + "int $4\n0:\n"
15711 + _ASM_EXTABLE(0b, 0b)
15712 +#endif
15713 +
15714 + "sete %1\n"
15715 : "+m" (l->a.counter), "=qm" (c)
15716 : : "memory");
15717 return c != 0;
15718 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15719 {
15720 unsigned char c;
15721
15722 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15723 + asm volatile(_ASM_ADD "%2,%0\n"
15724 +
15725 +#ifdef CONFIG_PAX_REFCOUNT
15726 + "jno 0f\n"
15727 + _ASM_SUB "%2,%0\n"
15728 + "int $4\n0:\n"
15729 + _ASM_EXTABLE(0b, 0b)
15730 +#endif
15731 +
15732 + "sets %1\n"
15733 : "+m" (l->a.counter), "=qm" (c)
15734 : "ir" (i) : "memory");
15735 return c;
15736 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15737 static inline long local_add_return(long i, local_t *l)
15738 {
15739 long __i = i;
15740 + asm volatile(_ASM_XADD "%0, %1\n"
15741 +
15742 +#ifdef CONFIG_PAX_REFCOUNT
15743 + "jno 0f\n"
15744 + _ASM_MOV "%0,%1\n"
15745 + "int $4\n0:\n"
15746 + _ASM_EXTABLE(0b, 0b)
15747 +#endif
15748 +
15749 + : "+r" (i), "+m" (l->a.counter)
15750 + : : "memory");
15751 + return i + __i;
15752 +}
15753 +
15754 +/**
15755 + * local_add_return_unchecked - add and return
15756 + * @i: integer value to add
15757 + * @l: pointer to type local_unchecked_t
15758 + *
15759 + * Atomically adds @i to @l and returns @i + @l
15760 + */
15761 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15762 +{
15763 + long __i = i;
15764 asm volatile(_ASM_XADD "%0, %1;"
15765 : "+r" (i), "+m" (l->a.counter)
15766 : : "memory");
15767 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15768
15769 #define local_cmpxchg(l, o, n) \
15770 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15771 +#define local_cmpxchg_unchecked(l, o, n) \
15772 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15773 /* Always has a lock prefix */
15774 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15775
15776 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15777 new file mode 100644
15778 index 0000000..2bfd3ba
15779 --- /dev/null
15780 +++ b/arch/x86/include/asm/mman.h
15781 @@ -0,0 +1,15 @@
15782 +#ifndef _X86_MMAN_H
15783 +#define _X86_MMAN_H
15784 +
15785 +#include <uapi/asm/mman.h>
15786 +
15787 +#ifdef __KERNEL__
15788 +#ifndef __ASSEMBLY__
15789 +#ifdef CONFIG_X86_32
15790 +#define arch_mmap_check i386_mmap_check
15791 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15792 +#endif
15793 +#endif
15794 +#endif
15795 +
15796 +#endif /* X86_MMAN_H */
15797 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15798 index 5f55e69..e20bfb1 100644
15799 --- a/arch/x86/include/asm/mmu.h
15800 +++ b/arch/x86/include/asm/mmu.h
15801 @@ -9,7 +9,7 @@
15802 * we put the segment information here.
15803 */
15804 typedef struct {
15805 - void *ldt;
15806 + struct desc_struct *ldt;
15807 int size;
15808
15809 #ifdef CONFIG_X86_64
15810 @@ -18,7 +18,19 @@ typedef struct {
15811 #endif
15812
15813 struct mutex lock;
15814 - void *vdso;
15815 + unsigned long vdso;
15816 +
15817 +#ifdef CONFIG_X86_32
15818 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15819 + unsigned long user_cs_base;
15820 + unsigned long user_cs_limit;
15821 +
15822 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15823 + cpumask_t cpu_user_cs_mask;
15824 +#endif
15825 +
15826 +#endif
15827 +#endif
15828 } mm_context_t;
15829
15830 #ifdef CONFIG_SMP
15831 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15832 index be12c53..2124e35 100644
15833 --- a/arch/x86/include/asm/mmu_context.h
15834 +++ b/arch/x86/include/asm/mmu_context.h
15835 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15836
15837 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15838 {
15839 +
15840 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15841 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15842 + unsigned int i;
15843 + pgd_t *pgd;
15844 +
15845 + pax_open_kernel();
15846 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15847 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15848 + set_pgd_batched(pgd+i, native_make_pgd(0));
15849 + pax_close_kernel();
15850 + }
15851 +#endif
15852 +
15853 #ifdef CONFIG_SMP
15854 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15855 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15856 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15857 struct task_struct *tsk)
15858 {
15859 unsigned cpu = smp_processor_id();
15860 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15861 + int tlbstate = TLBSTATE_OK;
15862 +#endif
15863
15864 if (likely(prev != next)) {
15865 #ifdef CONFIG_SMP
15866 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15867 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15868 +#endif
15869 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15870 this_cpu_write(cpu_tlbstate.active_mm, next);
15871 #endif
15872 cpumask_set_cpu(cpu, mm_cpumask(next));
15873
15874 /* Re-load page tables */
15875 +#ifdef CONFIG_PAX_PER_CPU_PGD
15876 + pax_open_kernel();
15877 +
15878 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15879 + if (static_cpu_has(X86_FEATURE_PCID))
15880 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15881 + else
15882 +#endif
15883 +
15884 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15885 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15886 + pax_close_kernel();
15887 + 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));
15888 +
15889 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15890 + if (static_cpu_has(X86_FEATURE_PCID)) {
15891 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15892 + u64 descriptor[2];
15893 + descriptor[0] = PCID_USER;
15894 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15895 + } else {
15896 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15897 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15898 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15899 + else
15900 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15901 + }
15902 + } else
15903 +#endif
15904 +
15905 + load_cr3(get_cpu_pgd(cpu, kernel));
15906 +#else
15907 load_cr3(next->pgd);
15908 +#endif
15909
15910 /* Stop flush ipis for the previous mm */
15911 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15912 @@ -51,9 +104,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15913 /* Load the LDT, if the LDT is different: */
15914 if (unlikely(prev->context.ldt != next->context.ldt))
15915 load_LDT_nolock(&next->context);
15916 +
15917 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15918 + if (!(__supported_pte_mask & _PAGE_NX)) {
15919 + smp_mb__before_clear_bit();
15920 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15921 + smp_mb__after_clear_bit();
15922 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15923 + }
15924 +#endif
15925 +
15926 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15927 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15928 + prev->context.user_cs_limit != next->context.user_cs_limit))
15929 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15930 +#ifdef CONFIG_SMP
15931 + else if (unlikely(tlbstate != TLBSTATE_OK))
15932 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15933 +#endif
15934 +#endif
15935 +
15936 }
15937 + else {
15938 +
15939 +#ifdef CONFIG_PAX_PER_CPU_PGD
15940 + pax_open_kernel();
15941 +
15942 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15943 + if (static_cpu_has(X86_FEATURE_PCID))
15944 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15945 + else
15946 +#endif
15947 +
15948 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15949 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15950 + pax_close_kernel();
15951 + 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));
15952 +
15953 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15954 + if (static_cpu_has(X86_FEATURE_PCID)) {
15955 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15956 + u64 descriptor[2];
15957 + descriptor[0] = PCID_USER;
15958 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15959 + } else {
15960 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15961 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15962 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15963 + else
15964 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15965 + }
15966 + } else
15967 +#endif
15968 +
15969 + load_cr3(get_cpu_pgd(cpu, kernel));
15970 +#endif
15971 +
15972 #ifdef CONFIG_SMP
15973 - else {
15974 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15975 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15976
15977 @@ -70,11 +177,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15978 * tlb flush IPI delivery. We must reload CR3
15979 * to make sure to use no freed page tables.
15980 */
15981 +
15982 +#ifndef CONFIG_PAX_PER_CPU_PGD
15983 load_cr3(next->pgd);
15984 +#endif
15985 +
15986 load_LDT_nolock(&next->context);
15987 +
15988 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15989 + if (!(__supported_pte_mask & _PAGE_NX))
15990 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15991 +#endif
15992 +
15993 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15994 +#ifdef CONFIG_PAX_PAGEEXEC
15995 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15996 +#endif
15997 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15998 +#endif
15999 +
16000 }
16001 +#endif
16002 }
16003 -#endif
16004 }
16005
16006 #define activate_mm(prev, next) \
16007 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
16008 index e3b7819..b257c64 100644
16009 --- a/arch/x86/include/asm/module.h
16010 +++ b/arch/x86/include/asm/module.h
16011 @@ -5,6 +5,7 @@
16012
16013 #ifdef CONFIG_X86_64
16014 /* X86_64 does not define MODULE_PROC_FAMILY */
16015 +#define MODULE_PROC_FAMILY ""
16016 #elif defined CONFIG_M486
16017 #define MODULE_PROC_FAMILY "486 "
16018 #elif defined CONFIG_M586
16019 @@ -57,8 +58,20 @@
16020 #error unknown processor family
16021 #endif
16022
16023 -#ifdef CONFIG_X86_32
16024 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16025 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16026 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16027 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16028 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16029 +#else
16030 +#define MODULE_PAX_KERNEXEC ""
16031 #endif
16032
16033 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16034 +#define MODULE_PAX_UDEREF "UDEREF "
16035 +#else
16036 +#define MODULE_PAX_UDEREF ""
16037 +#endif
16038 +
16039 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16040 +
16041 #endif /* _ASM_X86_MODULE_H */
16042 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16043 index 86f9301..b365cda 100644
16044 --- a/arch/x86/include/asm/nmi.h
16045 +++ b/arch/x86/include/asm/nmi.h
16046 @@ -40,11 +40,11 @@ struct nmiaction {
16047 nmi_handler_t handler;
16048 unsigned long flags;
16049 const char *name;
16050 -};
16051 +} __do_const;
16052
16053 #define register_nmi_handler(t, fn, fg, n, init...) \
16054 ({ \
16055 - static struct nmiaction init fn##_na = { \
16056 + static const struct nmiaction init fn##_na = { \
16057 .handler = (fn), \
16058 .name = (n), \
16059 .flags = (fg), \
16060 @@ -52,7 +52,7 @@ struct nmiaction {
16061 __register_nmi_handler((t), &fn##_na); \
16062 })
16063
16064 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16065 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16066
16067 void unregister_nmi_handler(unsigned int, const char *);
16068
16069 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16070 index c878924..21f4889 100644
16071 --- a/arch/x86/include/asm/page.h
16072 +++ b/arch/x86/include/asm/page.h
16073 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16074 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16075
16076 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16077 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16078
16079 #define __boot_va(x) __va(x)
16080 #define __boot_pa(x) __pa(x)
16081 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16082 index 0f1ddee..e2fc3d1 100644
16083 --- a/arch/x86/include/asm/page_64.h
16084 +++ b/arch/x86/include/asm/page_64.h
16085 @@ -7,9 +7,9 @@
16086
16087 /* duplicated to the one in bootmem.h */
16088 extern unsigned long max_pfn;
16089 -extern unsigned long phys_base;
16090 +extern const unsigned long phys_base;
16091
16092 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16093 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16094 {
16095 unsigned long y = x - __START_KERNEL_map;
16096
16097 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16098 index cfdc9ee..3f7b5d6 100644
16099 --- a/arch/x86/include/asm/paravirt.h
16100 +++ b/arch/x86/include/asm/paravirt.h
16101 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16102 return (pmd_t) { ret };
16103 }
16104
16105 -static inline pmdval_t pmd_val(pmd_t pmd)
16106 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16107 {
16108 pmdval_t ret;
16109
16110 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16111 val);
16112 }
16113
16114 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16115 +{
16116 + pgdval_t val = native_pgd_val(pgd);
16117 +
16118 + if (sizeof(pgdval_t) > sizeof(long))
16119 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16120 + val, (u64)val >> 32);
16121 + else
16122 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16123 + val);
16124 +}
16125 +
16126 static inline void pgd_clear(pgd_t *pgdp)
16127 {
16128 set_pgd(pgdp, __pgd(0));
16129 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16130 pv_mmu_ops.set_fixmap(idx, phys, flags);
16131 }
16132
16133 +#ifdef CONFIG_PAX_KERNEXEC
16134 +static inline unsigned long pax_open_kernel(void)
16135 +{
16136 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16137 +}
16138 +
16139 +static inline unsigned long pax_close_kernel(void)
16140 +{
16141 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16142 +}
16143 +#else
16144 +static inline unsigned long pax_open_kernel(void) { return 0; }
16145 +static inline unsigned long pax_close_kernel(void) { return 0; }
16146 +#endif
16147 +
16148 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16149
16150 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16151 @@ -926,7 +953,7 @@ extern void default_banner(void);
16152
16153 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16154 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16155 -#define PARA_INDIRECT(addr) *%cs:addr
16156 +#define PARA_INDIRECT(addr) *%ss:addr
16157 #endif
16158
16159 #define INTERRUPT_RETURN \
16160 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16161 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16162 CLBR_NONE, \
16163 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16164 +
16165 +#define GET_CR0_INTO_RDI \
16166 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16167 + mov %rax,%rdi
16168 +
16169 +#define SET_RDI_INTO_CR0 \
16170 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16171 +
16172 +#define GET_CR3_INTO_RDI \
16173 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16174 + mov %rax,%rdi
16175 +
16176 +#define SET_RDI_INTO_CR3 \
16177 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16178 +
16179 #endif /* CONFIG_X86_32 */
16180
16181 #endif /* __ASSEMBLY__ */
16182 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16183 index 0db1fca..52310cc 100644
16184 --- a/arch/x86/include/asm/paravirt_types.h
16185 +++ b/arch/x86/include/asm/paravirt_types.h
16186 @@ -84,7 +84,7 @@ struct pv_init_ops {
16187 */
16188 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16189 unsigned long addr, unsigned len);
16190 -};
16191 +} __no_const;
16192
16193
16194 struct pv_lazy_ops {
16195 @@ -98,7 +98,7 @@ struct pv_time_ops {
16196 unsigned long long (*sched_clock)(void);
16197 unsigned long long (*steal_clock)(int cpu);
16198 unsigned long (*get_tsc_khz)(void);
16199 -};
16200 +} __no_const;
16201
16202 struct pv_cpu_ops {
16203 /* hooks for various privileged instructions */
16204 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16205
16206 void (*start_context_switch)(struct task_struct *prev);
16207 void (*end_context_switch)(struct task_struct *next);
16208 -};
16209 +} __no_const;
16210
16211 struct pv_irq_ops {
16212 /*
16213 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16214 unsigned long start_eip,
16215 unsigned long start_esp);
16216 #endif
16217 -};
16218 +} __no_const;
16219
16220 struct pv_mmu_ops {
16221 unsigned long (*read_cr2)(void);
16222 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16223 struct paravirt_callee_save make_pud;
16224
16225 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16226 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16227 #endif /* PAGETABLE_LEVELS == 4 */
16228 #endif /* PAGETABLE_LEVELS >= 3 */
16229
16230 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16231 an mfn. We can tell which is which from the index. */
16232 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16233 phys_addr_t phys, pgprot_t flags);
16234 +
16235 +#ifdef CONFIG_PAX_KERNEXEC
16236 + unsigned long (*pax_open_kernel)(void);
16237 + unsigned long (*pax_close_kernel)(void);
16238 +#endif
16239 +
16240 };
16241
16242 struct arch_spinlock;
16243 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16244 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16245 int (*spin_trylock)(struct arch_spinlock *lock);
16246 void (*spin_unlock)(struct arch_spinlock *lock);
16247 -};
16248 +} __no_const;
16249
16250 /* This contains all the paravirt structures: we get a convenient
16251 * number for each function using the offset which we use to indicate
16252 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16253 index b4389a4..7024269 100644
16254 --- a/arch/x86/include/asm/pgalloc.h
16255 +++ b/arch/x86/include/asm/pgalloc.h
16256 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16257 pmd_t *pmd, pte_t *pte)
16258 {
16259 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16260 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16261 +}
16262 +
16263 +static inline void pmd_populate_user(struct mm_struct *mm,
16264 + pmd_t *pmd, pte_t *pte)
16265 +{
16266 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16267 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16268 }
16269
16270 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16271
16272 #ifdef CONFIG_X86_PAE
16273 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16274 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16275 +{
16276 + pud_populate(mm, pudp, pmd);
16277 +}
16278 #else /* !CONFIG_X86_PAE */
16279 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16280 {
16281 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16282 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16283 }
16284 +
16285 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16286 +{
16287 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16288 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16289 +}
16290 #endif /* CONFIG_X86_PAE */
16291
16292 #if PAGETABLE_LEVELS > 3
16293 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16294 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16295 }
16296
16297 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16298 +{
16299 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16300 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16301 +}
16302 +
16303 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16304 {
16305 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16306 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16307 index 3bf2dd0..23d2a9f 100644
16308 --- a/arch/x86/include/asm/pgtable-2level.h
16309 +++ b/arch/x86/include/asm/pgtable-2level.h
16310 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16311
16312 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16313 {
16314 + pax_open_kernel();
16315 *pmdp = pmd;
16316 + pax_close_kernel();
16317 }
16318
16319 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16320 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16321 index 81bb91b..9392125 100644
16322 --- a/arch/x86/include/asm/pgtable-3level.h
16323 +++ b/arch/x86/include/asm/pgtable-3level.h
16324 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16325
16326 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16327 {
16328 + pax_open_kernel();
16329 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16330 + pax_close_kernel();
16331 }
16332
16333 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16334 {
16335 + pax_open_kernel();
16336 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16337 + pax_close_kernel();
16338 }
16339
16340 /*
16341 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16342 index 1c00631..845f898 100644
16343 --- a/arch/x86/include/asm/pgtable.h
16344 +++ b/arch/x86/include/asm/pgtable.h
16345 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16346
16347 #ifndef __PAGETABLE_PUD_FOLDED
16348 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16349 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16350 #define pgd_clear(pgd) native_pgd_clear(pgd)
16351 #endif
16352
16353 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16354
16355 #define arch_end_context_switch(prev) do {} while(0)
16356
16357 +#define pax_open_kernel() native_pax_open_kernel()
16358 +#define pax_close_kernel() native_pax_close_kernel()
16359 #endif /* CONFIG_PARAVIRT */
16360
16361 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16362 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16363 +
16364 +#ifdef CONFIG_PAX_KERNEXEC
16365 +static inline unsigned long native_pax_open_kernel(void)
16366 +{
16367 + unsigned long cr0;
16368 +
16369 + preempt_disable();
16370 + barrier();
16371 + cr0 = read_cr0() ^ X86_CR0_WP;
16372 + BUG_ON(cr0 & X86_CR0_WP);
16373 + write_cr0(cr0);
16374 + return cr0 ^ X86_CR0_WP;
16375 +}
16376 +
16377 +static inline unsigned long native_pax_close_kernel(void)
16378 +{
16379 + unsigned long cr0;
16380 +
16381 + cr0 = read_cr0() ^ X86_CR0_WP;
16382 + BUG_ON(!(cr0 & X86_CR0_WP));
16383 + write_cr0(cr0);
16384 + barrier();
16385 + preempt_enable_no_resched();
16386 + return cr0 ^ X86_CR0_WP;
16387 +}
16388 +#else
16389 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16390 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16391 +#endif
16392 +
16393 /*
16394 * The following only work if pte_present() is true.
16395 * Undefined behaviour if not..
16396 */
16397 +static inline int pte_user(pte_t pte)
16398 +{
16399 + return pte_val(pte) & _PAGE_USER;
16400 +}
16401 +
16402 static inline int pte_dirty(pte_t pte)
16403 {
16404 return pte_flags(pte) & _PAGE_DIRTY;
16405 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16406 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16407 }
16408
16409 +static inline unsigned long pgd_pfn(pgd_t pgd)
16410 +{
16411 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16412 +}
16413 +
16414 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16415
16416 static inline int pmd_large(pmd_t pte)
16417 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16418 return pte_clear_flags(pte, _PAGE_RW);
16419 }
16420
16421 +static inline pte_t pte_mkread(pte_t pte)
16422 +{
16423 + return __pte(pte_val(pte) | _PAGE_USER);
16424 +}
16425 +
16426 static inline pte_t pte_mkexec(pte_t pte)
16427 {
16428 - return pte_clear_flags(pte, _PAGE_NX);
16429 +#ifdef CONFIG_X86_PAE
16430 + if (__supported_pte_mask & _PAGE_NX)
16431 + return pte_clear_flags(pte, _PAGE_NX);
16432 + else
16433 +#endif
16434 + return pte_set_flags(pte, _PAGE_USER);
16435 +}
16436 +
16437 +static inline pte_t pte_exprotect(pte_t pte)
16438 +{
16439 +#ifdef CONFIG_X86_PAE
16440 + if (__supported_pte_mask & _PAGE_NX)
16441 + return pte_set_flags(pte, _PAGE_NX);
16442 + else
16443 +#endif
16444 + return pte_clear_flags(pte, _PAGE_USER);
16445 }
16446
16447 static inline pte_t pte_mkdirty(pte_t pte)
16448 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16449 #endif
16450
16451 #ifndef __ASSEMBLY__
16452 +
16453 +#ifdef CONFIG_PAX_PER_CPU_PGD
16454 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16455 +enum cpu_pgd_type {kernel = 0, user = 1};
16456 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16457 +{
16458 + return cpu_pgd[cpu][type];
16459 +}
16460 +#endif
16461 +
16462 #include <linux/mm_types.h>
16463 #include <linux/log2.h>
16464
16465 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16466 * Currently stuck as a macro due to indirect forward reference to
16467 * linux/mmzone.h's __section_mem_map_addr() definition:
16468 */
16469 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16470 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16471
16472 /* Find an entry in the second-level page table.. */
16473 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16474 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16475 * Currently stuck as a macro due to indirect forward reference to
16476 * linux/mmzone.h's __section_mem_map_addr() definition:
16477 */
16478 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16479 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16480
16481 /* to find an entry in a page-table-directory. */
16482 static inline unsigned long pud_index(unsigned long address)
16483 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16484
16485 static inline int pgd_bad(pgd_t pgd)
16486 {
16487 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16488 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16489 }
16490
16491 static inline int pgd_none(pgd_t pgd)
16492 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16493 * pgd_offset() returns a (pgd_t *)
16494 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16495 */
16496 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16497 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16498 +
16499 +#ifdef CONFIG_PAX_PER_CPU_PGD
16500 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16501 +#endif
16502 +
16503 /*
16504 * a shortcut which implies the use of the kernel's pgd, instead
16505 * of a process's
16506 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16507 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16508 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16509
16510 +#ifdef CONFIG_X86_32
16511 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16512 +#else
16513 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16514 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16515 +
16516 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16517 +#ifdef __ASSEMBLY__
16518 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16519 +#else
16520 +extern unsigned long pax_user_shadow_base;
16521 +extern pgdval_t clone_pgd_mask;
16522 +#endif
16523 +#endif
16524 +
16525 +#endif
16526 +
16527 #ifndef __ASSEMBLY__
16528
16529 extern int direct_gbpages;
16530 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16531 * dst and src can be on the same page, but the range must not overlap,
16532 * and must not cross a page boundary.
16533 */
16534 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16535 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16536 {
16537 - memcpy(dst, src, count * sizeof(pgd_t));
16538 + pax_open_kernel();
16539 + while (count--)
16540 + *dst++ = *src++;
16541 + pax_close_kernel();
16542 }
16543
16544 +#ifdef CONFIG_PAX_PER_CPU_PGD
16545 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16546 +#endif
16547 +
16548 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16549 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16550 +#else
16551 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16552 +#endif
16553 +
16554 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16555 static inline int page_level_shift(enum pg_level level)
16556 {
16557 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16558 index 9ee3221..b979c6b 100644
16559 --- a/arch/x86/include/asm/pgtable_32.h
16560 +++ b/arch/x86/include/asm/pgtable_32.h
16561 @@ -25,9 +25,6 @@
16562 struct mm_struct;
16563 struct vm_area_struct;
16564
16565 -extern pgd_t swapper_pg_dir[1024];
16566 -extern pgd_t initial_page_table[1024];
16567 -
16568 static inline void pgtable_cache_init(void) { }
16569 static inline void check_pgt_cache(void) { }
16570 void paging_init(void);
16571 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16572 # include <asm/pgtable-2level.h>
16573 #endif
16574
16575 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16576 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16577 +#ifdef CONFIG_X86_PAE
16578 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16579 +#endif
16580 +
16581 #if defined(CONFIG_HIGHPTE)
16582 #define pte_offset_map(dir, address) \
16583 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16584 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16585 /* Clear a kernel PTE and flush it from the TLB */
16586 #define kpte_clear_flush(ptep, vaddr) \
16587 do { \
16588 + pax_open_kernel(); \
16589 pte_clear(&init_mm, (vaddr), (ptep)); \
16590 + pax_close_kernel(); \
16591 __flush_tlb_one((vaddr)); \
16592 } while (0)
16593
16594 #endif /* !__ASSEMBLY__ */
16595
16596 +#define HAVE_ARCH_UNMAPPED_AREA
16597 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16598 +
16599 /*
16600 * kern_addr_valid() is (1) for FLATMEM and (0) for
16601 * SPARSEMEM and DISCONTIGMEM
16602 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16603 index ed5903b..c7fe163 100644
16604 --- a/arch/x86/include/asm/pgtable_32_types.h
16605 +++ b/arch/x86/include/asm/pgtable_32_types.h
16606 @@ -8,7 +8,7 @@
16607 */
16608 #ifdef CONFIG_X86_PAE
16609 # include <asm/pgtable-3level_types.h>
16610 -# define PMD_SIZE (1UL << PMD_SHIFT)
16611 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16612 # define PMD_MASK (~(PMD_SIZE - 1))
16613 #else
16614 # include <asm/pgtable-2level_types.h>
16615 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16616 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16617 #endif
16618
16619 +#ifdef CONFIG_PAX_KERNEXEC
16620 +#ifndef __ASSEMBLY__
16621 +extern unsigned char MODULES_EXEC_VADDR[];
16622 +extern unsigned char MODULES_EXEC_END[];
16623 +#endif
16624 +#include <asm/boot.h>
16625 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16626 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16627 +#else
16628 +#define ktla_ktva(addr) (addr)
16629 +#define ktva_ktla(addr) (addr)
16630 +#endif
16631 +
16632 #define MODULES_VADDR VMALLOC_START
16633 #define MODULES_END VMALLOC_END
16634 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16635 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16636 index e22c1db..23a625a 100644
16637 --- a/arch/x86/include/asm/pgtable_64.h
16638 +++ b/arch/x86/include/asm/pgtable_64.h
16639 @@ -16,10 +16,14 @@
16640
16641 extern pud_t level3_kernel_pgt[512];
16642 extern pud_t level3_ident_pgt[512];
16643 +extern pud_t level3_vmalloc_start_pgt[512];
16644 +extern pud_t level3_vmalloc_end_pgt[512];
16645 +extern pud_t level3_vmemmap_pgt[512];
16646 +extern pud_t level2_vmemmap_pgt[512];
16647 extern pmd_t level2_kernel_pgt[512];
16648 extern pmd_t level2_fixmap_pgt[512];
16649 -extern pmd_t level2_ident_pgt[512];
16650 -extern pgd_t init_level4_pgt[];
16651 +extern pmd_t level2_ident_pgt[512*2];
16652 +extern pgd_t init_level4_pgt[512];
16653
16654 #define swapper_pg_dir init_level4_pgt
16655
16656 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16657
16658 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16659 {
16660 + pax_open_kernel();
16661 *pmdp = pmd;
16662 + pax_close_kernel();
16663 }
16664
16665 static inline void native_pmd_clear(pmd_t *pmd)
16666 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16667
16668 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16669 {
16670 + pax_open_kernel();
16671 *pudp = pud;
16672 + pax_close_kernel();
16673 }
16674
16675 static inline void native_pud_clear(pud_t *pud)
16676 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16677
16678 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16679 {
16680 + pax_open_kernel();
16681 + *pgdp = pgd;
16682 + pax_close_kernel();
16683 +}
16684 +
16685 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16686 +{
16687 *pgdp = pgd;
16688 }
16689
16690 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16691 index 2d88344..4679fc3 100644
16692 --- a/arch/x86/include/asm/pgtable_64_types.h
16693 +++ b/arch/x86/include/asm/pgtable_64_types.h
16694 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16695 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16696 #define MODULES_END _AC(0xffffffffff000000, UL)
16697 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16698 +#define MODULES_EXEC_VADDR MODULES_VADDR
16699 +#define MODULES_EXEC_END MODULES_END
16700 +
16701 +#define ktla_ktva(addr) (addr)
16702 +#define ktva_ktla(addr) (addr)
16703
16704 #define EARLY_DYNAMIC_PAGE_TABLES 64
16705
16706 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16707 index f4843e0..a2526f8 100644
16708 --- a/arch/x86/include/asm/pgtable_types.h
16709 +++ b/arch/x86/include/asm/pgtable_types.h
16710 @@ -16,13 +16,12 @@
16711 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16712 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16713 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16714 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16715 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16716 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16717 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16718 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16719 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16720 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16721 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16722 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16723 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16724 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16725
16726 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16727 @@ -40,7 +39,6 @@
16728 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16729 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16730 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16731 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16732 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16733 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16734 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16735 @@ -84,8 +82,10 @@
16736
16737 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16738 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16739 -#else
16740 +#elif defined(CONFIG_KMEMCHECK)
16741 #define _PAGE_NX (_AT(pteval_t, 0))
16742 +#else
16743 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16744 #endif
16745
16746 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16747 @@ -143,6 +143,9 @@
16748 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16749 _PAGE_ACCESSED)
16750
16751 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16752 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16753 +
16754 #define __PAGE_KERNEL_EXEC \
16755 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16756 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16757 @@ -153,7 +156,7 @@
16758 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16759 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16760 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16761 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16762 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16763 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16764 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16765 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16766 @@ -215,8 +218,8 @@
16767 * bits are combined, this will alow user to access the high address mapped
16768 * VDSO in the presence of CONFIG_COMPAT_VDSO
16769 */
16770 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16771 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16772 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16773 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16774 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16775 #endif
16776
16777 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16778 {
16779 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16780 }
16781 +#endif
16782
16783 +#if PAGETABLE_LEVELS == 3
16784 +#include <asm-generic/pgtable-nopud.h>
16785 +#endif
16786 +
16787 +#if PAGETABLE_LEVELS == 2
16788 +#include <asm-generic/pgtable-nopmd.h>
16789 +#endif
16790 +
16791 +#ifndef __ASSEMBLY__
16792 #if PAGETABLE_LEVELS > 3
16793 typedef struct { pudval_t pud; } pud_t;
16794
16795 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16796 return pud.pud;
16797 }
16798 #else
16799 -#include <asm-generic/pgtable-nopud.h>
16800 -
16801 static inline pudval_t native_pud_val(pud_t pud)
16802 {
16803 return native_pgd_val(pud.pgd);
16804 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16805 return pmd.pmd;
16806 }
16807 #else
16808 -#include <asm-generic/pgtable-nopmd.h>
16809 -
16810 static inline pmdval_t native_pmd_val(pmd_t pmd)
16811 {
16812 return native_pgd_val(pmd.pud.pgd);
16813 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16814
16815 extern pteval_t __supported_pte_mask;
16816 extern void set_nx(void);
16817 -extern int nx_enabled;
16818
16819 #define pgprot_writecombine pgprot_writecombine
16820 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16821 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16822 index 24cf5ae..4d9fa2d 100644
16823 --- a/arch/x86/include/asm/processor.h
16824 +++ b/arch/x86/include/asm/processor.h
16825 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16826 : "memory");
16827 }
16828
16829 +/* invpcid (%rdx),%rax */
16830 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16831 +
16832 +#define INVPCID_SINGLE_ADDRESS 0UL
16833 +#define INVPCID_SINGLE_CONTEXT 1UL
16834 +#define INVPCID_ALL_GLOBAL 2UL
16835 +#define INVPCID_ALL_MONGLOBAL 3UL
16836 +
16837 +#define PCID_KERNEL 0UL
16838 +#define PCID_USER 1UL
16839 +#define PCID_NOFLUSH (1UL << 63)
16840 +
16841 static inline void load_cr3(pgd_t *pgdir)
16842 {
16843 - write_cr3(__pa(pgdir));
16844 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16845 }
16846
16847 #ifdef CONFIG_X86_32
16848 @@ -283,7 +295,7 @@ struct tss_struct {
16849
16850 } ____cacheline_aligned;
16851
16852 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16853 +extern struct tss_struct init_tss[NR_CPUS];
16854
16855 /*
16856 * Save the original ist values for checking stack pointers during debugging
16857 @@ -453,6 +465,7 @@ struct thread_struct {
16858 unsigned short ds;
16859 unsigned short fsindex;
16860 unsigned short gsindex;
16861 + unsigned short ss;
16862 #endif
16863 #ifdef CONFIG_X86_32
16864 unsigned long ip;
16865 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16866 extern unsigned long mmu_cr4_features;
16867 extern u32 *trampoline_cr4_features;
16868
16869 -static inline void set_in_cr4(unsigned long mask)
16870 -{
16871 - unsigned long cr4;
16872 -
16873 - mmu_cr4_features |= mask;
16874 - if (trampoline_cr4_features)
16875 - *trampoline_cr4_features = mmu_cr4_features;
16876 - cr4 = read_cr4();
16877 - cr4 |= mask;
16878 - write_cr4(cr4);
16879 -}
16880 -
16881 -static inline void clear_in_cr4(unsigned long mask)
16882 -{
16883 - unsigned long cr4;
16884 -
16885 - mmu_cr4_features &= ~mask;
16886 - if (trampoline_cr4_features)
16887 - *trampoline_cr4_features = mmu_cr4_features;
16888 - cr4 = read_cr4();
16889 - cr4 &= ~mask;
16890 - write_cr4(cr4);
16891 -}
16892 +extern void set_in_cr4(unsigned long mask);
16893 +extern void clear_in_cr4(unsigned long mask);
16894
16895 typedef struct {
16896 unsigned long seg;
16897 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16898 */
16899 #define TASK_SIZE PAGE_OFFSET
16900 #define TASK_SIZE_MAX TASK_SIZE
16901 +
16902 +#ifdef CONFIG_PAX_SEGMEXEC
16903 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16904 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16905 +#else
16906 #define STACK_TOP TASK_SIZE
16907 -#define STACK_TOP_MAX STACK_TOP
16908 +#endif
16909 +
16910 +#define STACK_TOP_MAX TASK_SIZE
16911
16912 #define INIT_THREAD { \
16913 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16914 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16915 .vm86_info = NULL, \
16916 .sysenter_cs = __KERNEL_CS, \
16917 .io_bitmap_ptr = NULL, \
16918 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16919 */
16920 #define INIT_TSS { \
16921 .x86_tss = { \
16922 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16923 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16924 .ss0 = __KERNEL_DS, \
16925 .ss1 = __KERNEL_CS, \
16926 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16927 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16928 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16929
16930 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16931 -#define KSTK_TOP(info) \
16932 -({ \
16933 - unsigned long *__ptr = (unsigned long *)(info); \
16934 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16935 -})
16936 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16937
16938 /*
16939 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16940 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16941 #define task_pt_regs(task) \
16942 ({ \
16943 struct pt_regs *__regs__; \
16944 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16945 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16946 __regs__ - 1; \
16947 })
16948
16949 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16950 /*
16951 * User space process size. 47bits minus one guard page.
16952 */
16953 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16954 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16955
16956 /* This decides where the kernel will search for a free chunk of vm
16957 * space during mmap's.
16958 */
16959 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16960 - 0xc0000000 : 0xFFFFe000)
16961 + 0xc0000000 : 0xFFFFf000)
16962
16963 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16964 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16965 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16966 #define STACK_TOP_MAX TASK_SIZE_MAX
16967
16968 #define INIT_THREAD { \
16969 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16970 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16971 }
16972
16973 #define INIT_TSS { \
16974 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16975 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16976 }
16977
16978 /*
16979 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16980 */
16981 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16982
16983 +#ifdef CONFIG_PAX_SEGMEXEC
16984 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16985 +#endif
16986 +
16987 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16988
16989 /* Get/set a process' ability to use the timestamp counter instruction */
16990 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16991 extern u16 amd_get_nb_id(int cpu);
16992
16993 struct aperfmperf {
16994 - u64 aperf, mperf;
16995 + u64 aperf __intentional_overflow(0);
16996 + u64 mperf __intentional_overflow(0);
16997 };
16998
16999 static inline void get_aperfmperf(struct aperfmperf *am)
17000 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
17001 return ratio;
17002 }
17003
17004 -extern unsigned long arch_align_stack(unsigned long sp);
17005 +#define arch_align_stack(x) ((x) & ~0xfUL)
17006 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
17007
17008 void default_idle(void);
17009 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
17010 #define xen_set_default_idle 0
17011 #endif
17012
17013 -void stop_this_cpu(void *dummy);
17014 +void stop_this_cpu(void *dummy) __noreturn;
17015 void df_debug(struct pt_regs *regs, long error_code);
17016 #endif /* _ASM_X86_PROCESSOR_H */
17017 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
17018 index 942a086..6c26446 100644
17019 --- a/arch/x86/include/asm/ptrace.h
17020 +++ b/arch/x86/include/asm/ptrace.h
17021 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
17022 }
17023
17024 /*
17025 - * user_mode_vm(regs) determines whether a register set came from user mode.
17026 + * user_mode(regs) determines whether a register set came from user mode.
17027 * This is true if V8086 mode was enabled OR if the register set was from
17028 * protected mode with RPL-3 CS value. This tricky test checks that with
17029 * one comparison. Many places in the kernel can bypass this full check
17030 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17031 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17032 + * be used.
17033 */
17034 -static inline int user_mode(struct pt_regs *regs)
17035 +static inline int user_mode_novm(struct pt_regs *regs)
17036 {
17037 #ifdef CONFIG_X86_32
17038 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17039 #else
17040 - return !!(regs->cs & 3);
17041 + return !!(regs->cs & SEGMENT_RPL_MASK);
17042 #endif
17043 }
17044
17045 -static inline int user_mode_vm(struct pt_regs *regs)
17046 +static inline int user_mode(struct pt_regs *regs)
17047 {
17048 #ifdef CONFIG_X86_32
17049 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17050 USER_RPL;
17051 #else
17052 - return user_mode(regs);
17053 + return user_mode_novm(regs);
17054 #endif
17055 }
17056
17057 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17058 #ifdef CONFIG_X86_64
17059 static inline bool user_64bit_mode(struct pt_regs *regs)
17060 {
17061 + unsigned long cs = regs->cs & 0xffff;
17062 #ifndef CONFIG_PARAVIRT
17063 /*
17064 * On non-paravirt systems, this is the only long mode CPL 3
17065 * selector. We do not allow long mode selectors in the LDT.
17066 */
17067 - return regs->cs == __USER_CS;
17068 + return cs == __USER_CS;
17069 #else
17070 /* Headers are too twisted for this to go in paravirt.h. */
17071 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17072 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17073 #endif
17074 }
17075
17076 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17077 * Traps from the kernel do not save sp and ss.
17078 * Use the helper function to retrieve sp.
17079 */
17080 - if (offset == offsetof(struct pt_regs, sp) &&
17081 - regs->cs == __KERNEL_CS)
17082 - return kernel_stack_pointer(regs);
17083 + if (offset == offsetof(struct pt_regs, sp)) {
17084 + unsigned long cs = regs->cs & 0xffff;
17085 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17086 + return kernel_stack_pointer(regs);
17087 + }
17088 #endif
17089 return *(unsigned long *)((unsigned long)regs + offset);
17090 }
17091 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17092 index 9c6b890..5305f53 100644
17093 --- a/arch/x86/include/asm/realmode.h
17094 +++ b/arch/x86/include/asm/realmode.h
17095 @@ -22,16 +22,14 @@ struct real_mode_header {
17096 #endif
17097 /* APM/BIOS reboot */
17098 u32 machine_real_restart_asm;
17099 -#ifdef CONFIG_X86_64
17100 u32 machine_real_restart_seg;
17101 -#endif
17102 };
17103
17104 /* This must match data at trampoline_32/64.S */
17105 struct trampoline_header {
17106 #ifdef CONFIG_X86_32
17107 u32 start;
17108 - u16 gdt_pad;
17109 + u16 boot_cs;
17110 u16 gdt_limit;
17111 u32 gdt_base;
17112 #else
17113 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17114 index a82c4f1..ac45053 100644
17115 --- a/arch/x86/include/asm/reboot.h
17116 +++ b/arch/x86/include/asm/reboot.h
17117 @@ -6,13 +6,13 @@
17118 struct pt_regs;
17119
17120 struct machine_ops {
17121 - void (*restart)(char *cmd);
17122 - void (*halt)(void);
17123 - void (*power_off)(void);
17124 + void (* __noreturn restart)(char *cmd);
17125 + void (* __noreturn halt)(void);
17126 + void (* __noreturn power_off)(void);
17127 void (*shutdown)(void);
17128 void (*crash_shutdown)(struct pt_regs *);
17129 - void (*emergency_restart)(void);
17130 -};
17131 + void (* __noreturn emergency_restart)(void);
17132 +} __no_const;
17133
17134 extern struct machine_ops machine_ops;
17135
17136 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17137 index cad82c9..2e5c5c1 100644
17138 --- a/arch/x86/include/asm/rwsem.h
17139 +++ b/arch/x86/include/asm/rwsem.h
17140 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17141 {
17142 asm volatile("# beginning down_read\n\t"
17143 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17144 +
17145 +#ifdef CONFIG_PAX_REFCOUNT
17146 + "jno 0f\n"
17147 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17148 + "int $4\n0:\n"
17149 + _ASM_EXTABLE(0b, 0b)
17150 +#endif
17151 +
17152 /* adds 0x00000001 */
17153 " jns 1f\n"
17154 " call call_rwsem_down_read_failed\n"
17155 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17156 "1:\n\t"
17157 " mov %1,%2\n\t"
17158 " add %3,%2\n\t"
17159 +
17160 +#ifdef CONFIG_PAX_REFCOUNT
17161 + "jno 0f\n"
17162 + "sub %3,%2\n"
17163 + "int $4\n0:\n"
17164 + _ASM_EXTABLE(0b, 0b)
17165 +#endif
17166 +
17167 " jle 2f\n\t"
17168 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17169 " jnz 1b\n\t"
17170 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17171 long tmp;
17172 asm volatile("# beginning down_write\n\t"
17173 LOCK_PREFIX " xadd %1,(%2)\n\t"
17174 +
17175 +#ifdef CONFIG_PAX_REFCOUNT
17176 + "jno 0f\n"
17177 + "mov %1,(%2)\n"
17178 + "int $4\n0:\n"
17179 + _ASM_EXTABLE(0b, 0b)
17180 +#endif
17181 +
17182 /* adds 0xffff0001, returns the old value */
17183 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17184 /* was the active mask 0 before? */
17185 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17186 long tmp;
17187 asm volatile("# beginning __up_read\n\t"
17188 LOCK_PREFIX " xadd %1,(%2)\n\t"
17189 +
17190 +#ifdef CONFIG_PAX_REFCOUNT
17191 + "jno 0f\n"
17192 + "mov %1,(%2)\n"
17193 + "int $4\n0:\n"
17194 + _ASM_EXTABLE(0b, 0b)
17195 +#endif
17196 +
17197 /* subtracts 1, returns the old value */
17198 " jns 1f\n\t"
17199 " call call_rwsem_wake\n" /* expects old value in %edx */
17200 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17201 long tmp;
17202 asm volatile("# beginning __up_write\n\t"
17203 LOCK_PREFIX " xadd %1,(%2)\n\t"
17204 +
17205 +#ifdef CONFIG_PAX_REFCOUNT
17206 + "jno 0f\n"
17207 + "mov %1,(%2)\n"
17208 + "int $4\n0:\n"
17209 + _ASM_EXTABLE(0b, 0b)
17210 +#endif
17211 +
17212 /* subtracts 0xffff0001, returns the old value */
17213 " jns 1f\n\t"
17214 " call call_rwsem_wake\n" /* expects old value in %edx */
17215 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17216 {
17217 asm volatile("# beginning __downgrade_write\n\t"
17218 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17219 +
17220 +#ifdef CONFIG_PAX_REFCOUNT
17221 + "jno 0f\n"
17222 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17223 + "int $4\n0:\n"
17224 + _ASM_EXTABLE(0b, 0b)
17225 +#endif
17226 +
17227 /*
17228 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17229 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17230 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17231 */
17232 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17233 {
17234 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17235 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17236 +
17237 +#ifdef CONFIG_PAX_REFCOUNT
17238 + "jno 0f\n"
17239 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17240 + "int $4\n0:\n"
17241 + _ASM_EXTABLE(0b, 0b)
17242 +#endif
17243 +
17244 : "+m" (sem->count)
17245 : "er" (delta));
17246 }
17247 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17248 */
17249 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17250 {
17251 - return delta + xadd(&sem->count, delta);
17252 + return delta + xadd_check_overflow(&sem->count, delta);
17253 }
17254
17255 #endif /* __KERNEL__ */
17256 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17257 index c48a950..bc40804 100644
17258 --- a/arch/x86/include/asm/segment.h
17259 +++ b/arch/x86/include/asm/segment.h
17260 @@ -64,10 +64,15 @@
17261 * 26 - ESPFIX small SS
17262 * 27 - per-cpu [ offset to per-cpu data area ]
17263 * 28 - stack_canary-20 [ for stack protector ]
17264 - * 29 - unused
17265 - * 30 - unused
17266 + * 29 - PCI BIOS CS
17267 + * 30 - PCI BIOS DS
17268 * 31 - TSS for double fault handler
17269 */
17270 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17271 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17272 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17273 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17274 +
17275 #define GDT_ENTRY_TLS_MIN 6
17276 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17277
17278 @@ -79,6 +84,8 @@
17279
17280 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17281
17282 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17283 +
17284 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17285
17286 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17287 @@ -104,6 +111,12 @@
17288 #define __KERNEL_STACK_CANARY 0
17289 #endif
17290
17291 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17292 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17293 +
17294 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17295 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17296 +
17297 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17298
17299 /*
17300 @@ -141,7 +154,7 @@
17301 */
17302
17303 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17304 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17305 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17306
17307
17308 #else
17309 @@ -165,6 +178,8 @@
17310 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17311 #define __USER32_DS __USER_DS
17312
17313 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17314 +
17315 #define GDT_ENTRY_TSS 8 /* needs two entries */
17316 #define GDT_ENTRY_LDT 10 /* needs two entries */
17317 #define GDT_ENTRY_TLS_MIN 12
17318 @@ -173,6 +188,8 @@
17319 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17320 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17321
17322 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17323 +
17324 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17325 #define FS_TLS 0
17326 #define GS_TLS 1
17327 @@ -180,12 +197,14 @@
17328 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17329 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17330
17331 -#define GDT_ENTRIES 16
17332 +#define GDT_ENTRIES 17
17333
17334 #endif
17335
17336 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17337 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17338 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17339 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17340 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17341 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17342 #ifndef CONFIG_PARAVIRT
17343 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17344 {
17345 unsigned long __limit;
17346 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17347 - return __limit + 1;
17348 + return __limit;
17349 }
17350
17351 #endif /* !__ASSEMBLY__ */
17352 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17353 index 8d3120f..352b440 100644
17354 --- a/arch/x86/include/asm/smap.h
17355 +++ b/arch/x86/include/asm/smap.h
17356 @@ -25,11 +25,40 @@
17357
17358 #include <asm/alternative-asm.h>
17359
17360 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17361 +#define ASM_PAX_OPEN_USERLAND \
17362 + 661: jmp 663f; \
17363 + .pushsection .altinstr_replacement, "a" ; \
17364 + 662: pushq %rax; nop; \
17365 + .popsection ; \
17366 + .pushsection .altinstructions, "a" ; \
17367 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17368 + .popsection ; \
17369 + call __pax_open_userland; \
17370 + popq %rax; \
17371 + 663:
17372 +
17373 +#define ASM_PAX_CLOSE_USERLAND \
17374 + 661: jmp 663f; \
17375 + .pushsection .altinstr_replacement, "a" ; \
17376 + 662: pushq %rax; nop; \
17377 + .popsection; \
17378 + .pushsection .altinstructions, "a" ; \
17379 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17380 + .popsection; \
17381 + call __pax_close_userland; \
17382 + popq %rax; \
17383 + 663:
17384 +#else
17385 +#define ASM_PAX_OPEN_USERLAND
17386 +#define ASM_PAX_CLOSE_USERLAND
17387 +#endif
17388 +
17389 #ifdef CONFIG_X86_SMAP
17390
17391 #define ASM_CLAC \
17392 661: ASM_NOP3 ; \
17393 - .pushsection .altinstr_replacement, "ax" ; \
17394 + .pushsection .altinstr_replacement, "a" ; \
17395 662: __ASM_CLAC ; \
17396 .popsection ; \
17397 .pushsection .altinstructions, "a" ; \
17398 @@ -38,7 +67,7 @@
17399
17400 #define ASM_STAC \
17401 661: ASM_NOP3 ; \
17402 - .pushsection .altinstr_replacement, "ax" ; \
17403 + .pushsection .altinstr_replacement, "a" ; \
17404 662: __ASM_STAC ; \
17405 .popsection ; \
17406 .pushsection .altinstructions, "a" ; \
17407 @@ -56,6 +85,37 @@
17408
17409 #include <asm/alternative.h>
17410
17411 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17412 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17413 +
17414 +extern void __pax_open_userland(void);
17415 +static __always_inline unsigned long pax_open_userland(void)
17416 +{
17417 +
17418 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17419 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17420 + :
17421 + : [open] "i" (__pax_open_userland)
17422 + : "memory", "rax");
17423 +#endif
17424 +
17425 + return 0;
17426 +}
17427 +
17428 +extern void __pax_close_userland(void);
17429 +static __always_inline unsigned long pax_close_userland(void)
17430 +{
17431 +
17432 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17433 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17434 + :
17435 + : [close] "i" (__pax_close_userland)
17436 + : "memory", "rax");
17437 +#endif
17438 +
17439 + return 0;
17440 +}
17441 +
17442 #ifdef CONFIG_X86_SMAP
17443
17444 static __always_inline void clac(void)
17445 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17446 index 4137890..03fa172 100644
17447 --- a/arch/x86/include/asm/smp.h
17448 +++ b/arch/x86/include/asm/smp.h
17449 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17450 /* cpus sharing the last level cache: */
17451 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17452 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17453 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17454 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17455
17456 static inline struct cpumask *cpu_sibling_mask(int cpu)
17457 {
17458 @@ -79,7 +79,7 @@ struct smp_ops {
17459
17460 void (*send_call_func_ipi)(const struct cpumask *mask);
17461 void (*send_call_func_single_ipi)(int cpu);
17462 -};
17463 +} __no_const;
17464
17465 /* Globals due to paravirt */
17466 extern void set_cpu_sibling_map(int cpu);
17467 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17468 extern int safe_smp_processor_id(void);
17469
17470 #elif defined(CONFIG_X86_64_SMP)
17471 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17472 -
17473 -#define stack_smp_processor_id() \
17474 -({ \
17475 - struct thread_info *ti; \
17476 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17477 - ti->cpu; \
17478 -})
17479 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17480 +#define stack_smp_processor_id() raw_smp_processor_id()
17481 #define safe_smp_processor_id() smp_processor_id()
17482
17483 #endif
17484 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17485 index e3ddd7d..3611fce 100644
17486 --- a/arch/x86/include/asm/spinlock.h
17487 +++ b/arch/x86/include/asm/spinlock.h
17488 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17489 static inline void arch_read_lock(arch_rwlock_t *rw)
17490 {
17491 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17492 +
17493 +#ifdef CONFIG_PAX_REFCOUNT
17494 + "jno 0f\n"
17495 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17496 + "int $4\n0:\n"
17497 + _ASM_EXTABLE(0b, 0b)
17498 +#endif
17499 +
17500 "jns 1f\n"
17501 "call __read_lock_failed\n\t"
17502 "1:\n"
17503 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17504 static inline void arch_write_lock(arch_rwlock_t *rw)
17505 {
17506 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17507 +
17508 +#ifdef CONFIG_PAX_REFCOUNT
17509 + "jno 0f\n"
17510 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17511 + "int $4\n0:\n"
17512 + _ASM_EXTABLE(0b, 0b)
17513 +#endif
17514 +
17515 "jz 1f\n"
17516 "call __write_lock_failed\n\t"
17517 "1:\n"
17518 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17519
17520 static inline void arch_read_unlock(arch_rwlock_t *rw)
17521 {
17522 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17523 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17524 +
17525 +#ifdef CONFIG_PAX_REFCOUNT
17526 + "jno 0f\n"
17527 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17528 + "int $4\n0:\n"
17529 + _ASM_EXTABLE(0b, 0b)
17530 +#endif
17531 +
17532 :"+m" (rw->lock) : : "memory");
17533 }
17534
17535 static inline void arch_write_unlock(arch_rwlock_t *rw)
17536 {
17537 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17538 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17539 +
17540 +#ifdef CONFIG_PAX_REFCOUNT
17541 + "jno 0f\n"
17542 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17543 + "int $4\n0:\n"
17544 + _ASM_EXTABLE(0b, 0b)
17545 +#endif
17546 +
17547 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17548 }
17549
17550 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17551 index 6a99859..03cb807 100644
17552 --- a/arch/x86/include/asm/stackprotector.h
17553 +++ b/arch/x86/include/asm/stackprotector.h
17554 @@ -47,7 +47,7 @@
17555 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17556 */
17557 #define GDT_STACK_CANARY_INIT \
17558 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17559 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17560
17561 /*
17562 * Initialize the stackprotector canary value.
17563 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17564
17565 static inline void load_stack_canary_segment(void)
17566 {
17567 -#ifdef CONFIG_X86_32
17568 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17569 asm volatile ("mov %0, %%gs" : : "r" (0));
17570 #endif
17571 }
17572 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17573 index 70bbe39..4ae2bd4 100644
17574 --- a/arch/x86/include/asm/stacktrace.h
17575 +++ b/arch/x86/include/asm/stacktrace.h
17576 @@ -11,28 +11,20 @@
17577
17578 extern int kstack_depth_to_print;
17579
17580 -struct thread_info;
17581 +struct task_struct;
17582 struct stacktrace_ops;
17583
17584 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17585 - unsigned long *stack,
17586 - unsigned long bp,
17587 - const struct stacktrace_ops *ops,
17588 - void *data,
17589 - unsigned long *end,
17590 - int *graph);
17591 +typedef unsigned long walk_stack_t(struct task_struct *task,
17592 + void *stack_start,
17593 + unsigned long *stack,
17594 + unsigned long bp,
17595 + const struct stacktrace_ops *ops,
17596 + void *data,
17597 + unsigned long *end,
17598 + int *graph);
17599
17600 -extern unsigned long
17601 -print_context_stack(struct thread_info *tinfo,
17602 - unsigned long *stack, unsigned long bp,
17603 - const struct stacktrace_ops *ops, void *data,
17604 - unsigned long *end, int *graph);
17605 -
17606 -extern unsigned long
17607 -print_context_stack_bp(struct thread_info *tinfo,
17608 - unsigned long *stack, unsigned long bp,
17609 - const struct stacktrace_ops *ops, void *data,
17610 - unsigned long *end, int *graph);
17611 +extern walk_stack_t print_context_stack;
17612 +extern walk_stack_t print_context_stack_bp;
17613
17614 /* Generic stack tracer with callbacks */
17615
17616 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17617 void (*address)(void *data, unsigned long address, int reliable);
17618 /* On negative return stop dumping */
17619 int (*stack)(void *data, char *name);
17620 - walk_stack_t walk_stack;
17621 + walk_stack_t *walk_stack;
17622 };
17623
17624 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17625 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17626 index 4ec45b3..a4f0a8a 100644
17627 --- a/arch/x86/include/asm/switch_to.h
17628 +++ b/arch/x86/include/asm/switch_to.h
17629 @@ -108,7 +108,7 @@ do { \
17630 "call __switch_to\n\t" \
17631 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17632 __switch_canary \
17633 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17634 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17635 "movq %%rax,%%rdi\n\t" \
17636 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17637 "jnz ret_from_fork\n\t" \
17638 @@ -119,7 +119,7 @@ do { \
17639 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17640 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17641 [_tif_fork] "i" (_TIF_FORK), \
17642 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17643 + [thread_info] "m" (current_tinfo), \
17644 [current_task] "m" (current_task) \
17645 __switch_canary_iparam \
17646 : "memory", "cc" __EXTRA_CLOBBER)
17647 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17648 index 2781119..618b59b 100644
17649 --- a/arch/x86/include/asm/thread_info.h
17650 +++ b/arch/x86/include/asm/thread_info.h
17651 @@ -10,6 +10,7 @@
17652 #include <linux/compiler.h>
17653 #include <asm/page.h>
17654 #include <asm/types.h>
17655 +#include <asm/percpu.h>
17656
17657 /*
17658 * low level task data that entry.S needs immediate access to
17659 @@ -23,7 +24,6 @@ struct exec_domain;
17660 #include <linux/atomic.h>
17661
17662 struct thread_info {
17663 - struct task_struct *task; /* main task structure */
17664 struct exec_domain *exec_domain; /* execution domain */
17665 __u32 flags; /* low level flags */
17666 __u32 status; /* thread synchronous flags */
17667 @@ -33,19 +33,13 @@ struct thread_info {
17668 mm_segment_t addr_limit;
17669 struct restart_block restart_block;
17670 void __user *sysenter_return;
17671 -#ifdef CONFIG_X86_32
17672 - unsigned long previous_esp; /* ESP of the previous stack in
17673 - case of nested (IRQ) stacks
17674 - */
17675 - __u8 supervisor_stack[0];
17676 -#endif
17677 + unsigned long lowest_stack;
17678 unsigned int sig_on_uaccess_error:1;
17679 unsigned int uaccess_err:1; /* uaccess failed */
17680 };
17681
17682 -#define INIT_THREAD_INFO(tsk) \
17683 +#define INIT_THREAD_INFO \
17684 { \
17685 - .task = &tsk, \
17686 .exec_domain = &default_exec_domain, \
17687 .flags = 0, \
17688 .cpu = 0, \
17689 @@ -56,7 +50,7 @@ struct thread_info {
17690 }, \
17691 }
17692
17693 -#define init_thread_info (init_thread_union.thread_info)
17694 +#define init_thread_info (init_thread_union.stack)
17695 #define init_stack (init_thread_union.stack)
17696
17697 #else /* !__ASSEMBLY__ */
17698 @@ -96,6 +90,7 @@ struct thread_info {
17699 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17700 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17701 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17702 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17703
17704 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17705 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17706 @@ -119,17 +114,18 @@ struct thread_info {
17707 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17708 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17709 #define _TIF_X32 (1 << TIF_X32)
17710 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17711
17712 /* work to do in syscall_trace_enter() */
17713 #define _TIF_WORK_SYSCALL_ENTRY \
17714 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17715 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17716 - _TIF_NOHZ)
17717 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17718
17719 /* work to do in syscall_trace_leave() */
17720 #define _TIF_WORK_SYSCALL_EXIT \
17721 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17722 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17723 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17724
17725 /* work to do on interrupt/exception return */
17726 #define _TIF_WORK_MASK \
17727 @@ -140,7 +136,7 @@ struct thread_info {
17728 /* work to do on any return to user space */
17729 #define _TIF_ALLWORK_MASK \
17730 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17731 - _TIF_NOHZ)
17732 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17733
17734 /* Only used for 64 bit */
17735 #define _TIF_DO_NOTIFY_MASK \
17736 @@ -156,45 +152,40 @@ struct thread_info {
17737
17738 #define PREEMPT_ACTIVE 0x10000000
17739
17740 -#ifdef CONFIG_X86_32
17741 -
17742 -#define STACK_WARN (THREAD_SIZE/8)
17743 -/*
17744 - * macros/functions for gaining access to the thread information structure
17745 - *
17746 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17747 - */
17748 -#ifndef __ASSEMBLY__
17749 -
17750 -
17751 -/* how to get the current stack pointer from C */
17752 -register unsigned long current_stack_pointer asm("esp") __used;
17753 -
17754 -/* how to get the thread information struct from C */
17755 -static inline struct thread_info *current_thread_info(void)
17756 -{
17757 - return (struct thread_info *)
17758 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17759 -}
17760 -
17761 -#else /* !__ASSEMBLY__ */
17762 -
17763 +#ifdef __ASSEMBLY__
17764 /* how to get the thread information struct from ASM */
17765 #define GET_THREAD_INFO(reg) \
17766 - movl $-THREAD_SIZE, reg; \
17767 - andl %esp, reg
17768 + mov PER_CPU_VAR(current_tinfo), reg
17769
17770 /* use this one if reg already contains %esp */
17771 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17772 - andl $-THREAD_SIZE, reg
17773 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17774 +#else
17775 +/* how to get the thread information struct from C */
17776 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17777 +
17778 +static __always_inline struct thread_info *current_thread_info(void)
17779 +{
17780 + return this_cpu_read_stable(current_tinfo);
17781 +}
17782 +#endif
17783 +
17784 +#ifdef CONFIG_X86_32
17785 +
17786 +#define STACK_WARN (THREAD_SIZE/8)
17787 +/*
17788 + * macros/functions for gaining access to the thread information structure
17789 + *
17790 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17791 + */
17792 +#ifndef __ASSEMBLY__
17793 +
17794 +/* how to get the current stack pointer from C */
17795 +register unsigned long current_stack_pointer asm("esp") __used;
17796
17797 #endif
17798
17799 #else /* X86_32 */
17800
17801 -#include <asm/percpu.h>
17802 -#define KERNEL_STACK_OFFSET (5*8)
17803 -
17804 /*
17805 * macros/functions for gaining access to the thread information structure
17806 * preempt_count needs to be 1 initially, until the scheduler is functional.
17807 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17808 #ifndef __ASSEMBLY__
17809 DECLARE_PER_CPU(unsigned long, kernel_stack);
17810
17811 -static inline struct thread_info *current_thread_info(void)
17812 -{
17813 - struct thread_info *ti;
17814 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17815 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17816 - return ti;
17817 -}
17818 -
17819 -#else /* !__ASSEMBLY__ */
17820 -
17821 -/* how to get the thread information struct from ASM */
17822 -#define GET_THREAD_INFO(reg) \
17823 - movq PER_CPU_VAR(kernel_stack),reg ; \
17824 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17825 -
17826 -/*
17827 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17828 - * a certain register (to be used in assembler memory operands).
17829 - */
17830 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17831 -
17832 +/* how to get the current stack pointer from C */
17833 +register unsigned long current_stack_pointer asm("rsp") __used;
17834 #endif
17835
17836 #endif /* !X86_32 */
17837 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17838 extern void arch_task_cache_init(void);
17839 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17840 extern void arch_release_task_struct(struct task_struct *tsk);
17841 +
17842 +#define __HAVE_THREAD_FUNCTIONS
17843 +#define task_thread_info(task) (&(task)->tinfo)
17844 +#define task_stack_page(task) ((task)->stack)
17845 +#define setup_thread_stack(p, org) do {} while (0)
17846 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17847 +
17848 #endif
17849 #endif /* _ASM_X86_THREAD_INFO_H */
17850 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17851 index cf51200..63ff068 100644
17852 --- a/arch/x86/include/asm/tlbflush.h
17853 +++ b/arch/x86/include/asm/tlbflush.h
17854 @@ -17,18 +17,44 @@
17855
17856 static inline void __native_flush_tlb(void)
17857 {
17858 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17859 + u64 descriptor[2];
17860 +
17861 + descriptor[0] = PCID_KERNEL;
17862 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17863 + return;
17864 + }
17865 +
17866 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17867 + if (static_cpu_has(X86_FEATURE_PCID)) {
17868 + unsigned int cpu = raw_get_cpu();
17869 +
17870 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17871 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17872 + raw_put_cpu_no_resched();
17873 + return;
17874 + }
17875 +#endif
17876 +
17877 native_write_cr3(native_read_cr3());
17878 }
17879
17880 static inline void __native_flush_tlb_global_irq_disabled(void)
17881 {
17882 - unsigned long cr4;
17883 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17884 + u64 descriptor[2];
17885
17886 - cr4 = native_read_cr4();
17887 - /* clear PGE */
17888 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17889 - /* write old PGE again and flush TLBs */
17890 - native_write_cr4(cr4);
17891 + descriptor[0] = PCID_KERNEL;
17892 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17893 + } else {
17894 + unsigned long cr4;
17895 +
17896 + cr4 = native_read_cr4();
17897 + /* clear PGE */
17898 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17899 + /* write old PGE again and flush TLBs */
17900 + native_write_cr4(cr4);
17901 + }
17902 }
17903
17904 static inline void __native_flush_tlb_global(void)
17905 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17906
17907 static inline void __native_flush_tlb_single(unsigned long addr)
17908 {
17909 +
17910 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17911 + u64 descriptor[2];
17912 +
17913 + descriptor[0] = PCID_KERNEL;
17914 + descriptor[1] = addr;
17915 +
17916 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17917 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17918 + if (addr < TASK_SIZE_MAX)
17919 + descriptor[1] += pax_user_shadow_base;
17920 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17921 + }
17922 +
17923 + descriptor[0] = PCID_USER;
17924 + descriptor[1] = addr;
17925 +#endif
17926 +
17927 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17928 + return;
17929 + }
17930 +
17931 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17932 + if (static_cpu_has(X86_FEATURE_PCID)) {
17933 + unsigned int cpu = raw_get_cpu();
17934 +
17935 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17936 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17937 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17938 + raw_put_cpu_no_resched();
17939 +
17940 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17941 + addr += pax_user_shadow_base;
17942 + }
17943 +#endif
17944 +
17945 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17946 }
17947
17948 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17949 index 5ee2687..74590b9 100644
17950 --- a/arch/x86/include/asm/uaccess.h
17951 +++ b/arch/x86/include/asm/uaccess.h
17952 @@ -7,6 +7,7 @@
17953 #include <linux/compiler.h>
17954 #include <linux/thread_info.h>
17955 #include <linux/string.h>
17956 +#include <linux/sched.h>
17957 #include <asm/asm.h>
17958 #include <asm/page.h>
17959 #include <asm/smap.h>
17960 @@ -29,7 +30,12 @@
17961
17962 #define get_ds() (KERNEL_DS)
17963 #define get_fs() (current_thread_info()->addr_limit)
17964 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17965 +void __set_fs(mm_segment_t x);
17966 +void set_fs(mm_segment_t x);
17967 +#else
17968 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17969 +#endif
17970
17971 #define segment_eq(a, b) ((a).seg == (b).seg)
17972
17973 @@ -77,8 +83,33 @@
17974 * checks that the pointer is in the user space range - after calling
17975 * this function, memory access functions may still return -EFAULT.
17976 */
17977 -#define access_ok(type, addr, size) \
17978 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17979 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17980 +#define access_ok(type, addr, size) \
17981 +({ \
17982 + long __size = size; \
17983 + unsigned long __addr = (unsigned long)addr; \
17984 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17985 + unsigned long __end_ao = __addr + __size - 1; \
17986 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17987 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17988 + while(__addr_ao <= __end_ao) { \
17989 + char __c_ao; \
17990 + __addr_ao += PAGE_SIZE; \
17991 + if (__size > PAGE_SIZE) \
17992 + cond_resched(); \
17993 + if (__get_user(__c_ao, (char __user *)__addr)) \
17994 + break; \
17995 + if (type != VERIFY_WRITE) { \
17996 + __addr = __addr_ao; \
17997 + continue; \
17998 + } \
17999 + if (__put_user(__c_ao, (char __user *)__addr)) \
18000 + break; \
18001 + __addr = __addr_ao; \
18002 + } \
18003 + } \
18004 + __ret_ao; \
18005 +})
18006
18007 /*
18008 * The exception table consists of pairs of addresses relative to the
18009 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18010 register __inttype(*(ptr)) __val_gu asm("%edx"); \
18011 __chk_user_ptr(ptr); \
18012 might_fault(); \
18013 + pax_open_userland(); \
18014 asm volatile("call __get_user_%P3" \
18015 : "=a" (__ret_gu), "=r" (__val_gu) \
18016 : "0" (ptr), "i" (sizeof(*(ptr)))); \
18017 (x) = (__typeof__(*(ptr))) __val_gu; \
18018 + pax_close_userland(); \
18019 __ret_gu; \
18020 })
18021
18022 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18023 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
18024 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
18025
18026 -
18027 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18028 +#define __copyuser_seg "gs;"
18029 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
18030 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18031 +#else
18032 +#define __copyuser_seg
18033 +#define __COPYUSER_SET_ES
18034 +#define __COPYUSER_RESTORE_ES
18035 +#endif
18036
18037 #ifdef CONFIG_X86_32
18038 #define __put_user_asm_u64(x, addr, err, errret) \
18039 asm volatile(ASM_STAC "\n" \
18040 - "1: movl %%eax,0(%2)\n" \
18041 - "2: movl %%edx,4(%2)\n" \
18042 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18043 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18044 "3: " ASM_CLAC "\n" \
18045 ".section .fixup,\"ax\"\n" \
18046 "4: movl %3,%0\n" \
18047 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18048
18049 #define __put_user_asm_ex_u64(x, addr) \
18050 asm volatile(ASM_STAC "\n" \
18051 - "1: movl %%eax,0(%1)\n" \
18052 - "2: movl %%edx,4(%1)\n" \
18053 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18054 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18055 "3: " ASM_CLAC "\n" \
18056 _ASM_EXTABLE_EX(1b, 2b) \
18057 _ASM_EXTABLE_EX(2b, 3b) \
18058 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18059 __typeof__(*(ptr)) __pu_val; \
18060 __chk_user_ptr(ptr); \
18061 might_fault(); \
18062 - __pu_val = x; \
18063 + __pu_val = (x); \
18064 + pax_open_userland(); \
18065 switch (sizeof(*(ptr))) { \
18066 case 1: \
18067 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18068 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18069 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18070 break; \
18071 } \
18072 + pax_close_userland(); \
18073 __ret_pu; \
18074 })
18075
18076 @@ -344,8 +387,10 @@ do { \
18077 } while (0)
18078
18079 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18080 +do { \
18081 + pax_open_userland(); \
18082 asm volatile(ASM_STAC "\n" \
18083 - "1: mov"itype" %2,%"rtype"1\n" \
18084 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18085 "2: " ASM_CLAC "\n" \
18086 ".section .fixup,\"ax\"\n" \
18087 "3: mov %3,%0\n" \
18088 @@ -353,8 +398,10 @@ do { \
18089 " jmp 2b\n" \
18090 ".previous\n" \
18091 _ASM_EXTABLE(1b, 3b) \
18092 - : "=r" (err), ltype(x) \
18093 - : "m" (__m(addr)), "i" (errret), "0" (err))
18094 + : "=r" (err), ltype (x) \
18095 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18096 + pax_close_userland(); \
18097 +} while (0)
18098
18099 #define __get_user_size_ex(x, ptr, size) \
18100 do { \
18101 @@ -378,7 +425,7 @@ do { \
18102 } while (0)
18103
18104 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18105 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18106 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18107 "2:\n" \
18108 _ASM_EXTABLE_EX(1b, 2b) \
18109 : ltype(x) : "m" (__m(addr)))
18110 @@ -395,13 +442,24 @@ do { \
18111 int __gu_err; \
18112 unsigned long __gu_val; \
18113 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18114 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18115 + (x) = (__typeof__(*(ptr)))__gu_val; \
18116 __gu_err; \
18117 })
18118
18119 /* FIXME: this hack is definitely wrong -AK */
18120 struct __large_struct { unsigned long buf[100]; };
18121 -#define __m(x) (*(struct __large_struct __user *)(x))
18122 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18123 +#define ____m(x) \
18124 +({ \
18125 + unsigned long ____x = (unsigned long)(x); \
18126 + if (____x < pax_user_shadow_base) \
18127 + ____x += pax_user_shadow_base; \
18128 + (typeof(x))____x; \
18129 +})
18130 +#else
18131 +#define ____m(x) (x)
18132 +#endif
18133 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18134
18135 /*
18136 * Tell gcc we read from memory instead of writing: this is because
18137 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18138 * aliasing issues.
18139 */
18140 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18141 +do { \
18142 + pax_open_userland(); \
18143 asm volatile(ASM_STAC "\n" \
18144 - "1: mov"itype" %"rtype"1,%2\n" \
18145 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18146 "2: " ASM_CLAC "\n" \
18147 ".section .fixup,\"ax\"\n" \
18148 "3: mov %3,%0\n" \
18149 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18150 ".previous\n" \
18151 _ASM_EXTABLE(1b, 3b) \
18152 : "=r"(err) \
18153 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18154 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18155 + pax_close_userland(); \
18156 +} while (0)
18157
18158 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18159 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18160 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18161 "2:\n" \
18162 _ASM_EXTABLE_EX(1b, 2b) \
18163 : : ltype(x), "m" (__m(addr)))
18164 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18165 */
18166 #define uaccess_try do { \
18167 current_thread_info()->uaccess_err = 0; \
18168 + pax_open_userland(); \
18169 stac(); \
18170 barrier();
18171
18172 #define uaccess_catch(err) \
18173 clac(); \
18174 + pax_close_userland(); \
18175 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18176 } while (0)
18177
18178 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18179 * On error, the variable @x is set to zero.
18180 */
18181
18182 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18183 +#define __get_user(x, ptr) get_user((x), (ptr))
18184 +#else
18185 #define __get_user(x, ptr) \
18186 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18187 +#endif
18188
18189 /**
18190 * __put_user: - Write a simple value into user space, with less checking.
18191 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18192 * Returns zero on success, or -EFAULT on error.
18193 */
18194
18195 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18196 +#define __put_user(x, ptr) put_user((x), (ptr))
18197 +#else
18198 #define __put_user(x, ptr) \
18199 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18200 +#endif
18201
18202 #define __get_user_unaligned __get_user
18203 #define __put_user_unaligned __put_user
18204 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18205 #define get_user_ex(x, ptr) do { \
18206 unsigned long __gue_val; \
18207 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18208 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18209 + (x) = (__typeof__(*(ptr)))__gue_val; \
18210 } while (0)
18211
18212 #define put_user_try uaccess_try
18213 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18214 extern __must_check long strlen_user(const char __user *str);
18215 extern __must_check long strnlen_user(const char __user *str, long n);
18216
18217 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18218 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18219 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18220 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18221
18222 /*
18223 * movsl can be slow when source and dest are not both 8-byte aligned
18224 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18225 index 7f760a9..04b1c65 100644
18226 --- a/arch/x86/include/asm/uaccess_32.h
18227 +++ b/arch/x86/include/asm/uaccess_32.h
18228 @@ -11,15 +11,15 @@
18229 #include <asm/page.h>
18230
18231 unsigned long __must_check __copy_to_user_ll
18232 - (void __user *to, const void *from, unsigned long n);
18233 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18234 unsigned long __must_check __copy_from_user_ll
18235 - (void *to, const void __user *from, unsigned long n);
18236 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18237 unsigned long __must_check __copy_from_user_ll_nozero
18238 - (void *to, const void __user *from, unsigned long n);
18239 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18240 unsigned long __must_check __copy_from_user_ll_nocache
18241 - (void *to, const void __user *from, unsigned long n);
18242 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18243 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18244 - (void *to, const void __user *from, unsigned long n);
18245 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18246
18247 /**
18248 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18249 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18250 static __always_inline unsigned long __must_check
18251 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18252 {
18253 + if ((long)n < 0)
18254 + return n;
18255 +
18256 + check_object_size(from, n, true);
18257 +
18258 if (__builtin_constant_p(n)) {
18259 unsigned long ret;
18260
18261 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18262 __copy_to_user(void __user *to, const void *from, unsigned long n)
18263 {
18264 might_fault();
18265 +
18266 return __copy_to_user_inatomic(to, from, n);
18267 }
18268
18269 static __always_inline unsigned long
18270 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18271 {
18272 + if ((long)n < 0)
18273 + return n;
18274 +
18275 /* Avoid zeroing the tail if the copy fails..
18276 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18277 * but as the zeroing behaviour is only significant when n is not
18278 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18279 __copy_from_user(void *to, const void __user *from, unsigned long n)
18280 {
18281 might_fault();
18282 +
18283 + if ((long)n < 0)
18284 + return n;
18285 +
18286 + check_object_size(to, n, false);
18287 +
18288 if (__builtin_constant_p(n)) {
18289 unsigned long ret;
18290
18291 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18292 const void __user *from, unsigned long n)
18293 {
18294 might_fault();
18295 +
18296 + if ((long)n < 0)
18297 + return n;
18298 +
18299 if (__builtin_constant_p(n)) {
18300 unsigned long ret;
18301
18302 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18303 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18304 unsigned long n)
18305 {
18306 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18307 + if ((long)n < 0)
18308 + return n;
18309 +
18310 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18311 }
18312
18313 -unsigned long __must_check copy_to_user(void __user *to,
18314 - const void *from, unsigned long n);
18315 -unsigned long __must_check _copy_from_user(void *to,
18316 - const void __user *from,
18317 - unsigned long n);
18318 -
18319 +extern void copy_to_user_overflow(void)
18320 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18321 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18322 +#else
18323 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18324 +#endif
18325 +;
18326
18327 extern void copy_from_user_overflow(void)
18328 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18329 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18330 #endif
18331 ;
18332
18333 -static inline unsigned long __must_check copy_from_user(void *to,
18334 - const void __user *from,
18335 - unsigned long n)
18336 +/**
18337 + * copy_to_user: - Copy a block of data into user space.
18338 + * @to: Destination address, in user space.
18339 + * @from: Source address, in kernel space.
18340 + * @n: Number of bytes to copy.
18341 + *
18342 + * Context: User context only. This function may sleep.
18343 + *
18344 + * Copy data from kernel space to user space.
18345 + *
18346 + * Returns number of bytes that could not be copied.
18347 + * On success, this will be zero.
18348 + */
18349 +static inline unsigned long __must_check
18350 +copy_to_user(void __user *to, const void *from, unsigned long n)
18351 {
18352 - int sz = __compiletime_object_size(to);
18353 + size_t sz = __compiletime_object_size(from);
18354
18355 - if (likely(sz == -1 || sz >= n))
18356 - n = _copy_from_user(to, from, n);
18357 - else
18358 + if (unlikely(sz != (size_t)-1 && sz < n))
18359 + copy_to_user_overflow();
18360 + else if (access_ok(VERIFY_WRITE, to, n))
18361 + n = __copy_to_user(to, from, n);
18362 + return n;
18363 +}
18364 +
18365 +/**
18366 + * copy_from_user: - Copy a block of data from user space.
18367 + * @to: Destination address, in kernel space.
18368 + * @from: Source address, in user space.
18369 + * @n: Number of bytes to copy.
18370 + *
18371 + * Context: User context only. This function may sleep.
18372 + *
18373 + * Copy data from user space to kernel space.
18374 + *
18375 + * Returns number of bytes that could not be copied.
18376 + * On success, this will be zero.
18377 + *
18378 + * If some data could not be copied, this function will pad the copied
18379 + * data to the requested size using zero bytes.
18380 + */
18381 +static inline unsigned long __must_check
18382 +copy_from_user(void *to, const void __user *from, unsigned long n)
18383 +{
18384 + size_t sz = __compiletime_object_size(to);
18385 +
18386 + check_object_size(to, n, false);
18387 +
18388 + if (unlikely(sz != (size_t)-1 && sz < n))
18389 copy_from_user_overflow();
18390 -
18391 + else if (access_ok(VERIFY_READ, from, n))
18392 + n = __copy_from_user(to, from, n);
18393 + else if ((long)n > 0)
18394 + memset(to, 0, n);
18395 return n;
18396 }
18397
18398 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18399 index 4f7923d..20cb24e 100644
18400 --- a/arch/x86/include/asm/uaccess_64.h
18401 +++ b/arch/x86/include/asm/uaccess_64.h
18402 @@ -10,6 +10,9 @@
18403 #include <asm/alternative.h>
18404 #include <asm/cpufeature.h>
18405 #include <asm/page.h>
18406 +#include <asm/pgtable.h>
18407 +
18408 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18409
18410 /*
18411 * Copy To/From Userspace
18412 @@ -17,13 +20,13 @@
18413
18414 /* Handles exceptions in both to and from, but doesn't do access_ok */
18415 __must_check unsigned long
18416 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18417 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18418 __must_check unsigned long
18419 -copy_user_generic_string(void *to, const void *from, unsigned len);
18420 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18421 __must_check unsigned long
18422 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18423 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18424
18425 -static __always_inline __must_check unsigned long
18426 +static __always_inline __must_check __size_overflow(3) unsigned long
18427 copy_user_generic(void *to, const void *from, unsigned len)
18428 {
18429 unsigned ret;
18430 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
18431 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
18432 "=d" (len)),
18433 "1" (to), "2" (from), "3" (len)
18434 - : "memory", "rcx", "r8", "r9", "r10", "r11");
18435 + : "memory", "rcx", "r8", "r9", "r11");
18436 return ret;
18437 }
18438
18439 +static __always_inline __must_check unsigned long
18440 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18441 +static __always_inline __must_check unsigned long
18442 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18443 __must_check unsigned long
18444 -_copy_to_user(void __user *to, const void *from, unsigned len);
18445 -__must_check unsigned long
18446 -_copy_from_user(void *to, const void __user *from, unsigned len);
18447 -__must_check unsigned long
18448 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18449 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18450 +
18451 +extern void copy_to_user_overflow(void)
18452 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18453 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18454 +#else
18455 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18456 +#endif
18457 +;
18458 +
18459 +extern void copy_from_user_overflow(void)
18460 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18461 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18462 +#else
18463 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18464 +#endif
18465 +;
18466
18467 static inline unsigned long __must_check copy_from_user(void *to,
18468 const void __user *from,
18469 unsigned long n)
18470 {
18471 - int sz = __compiletime_object_size(to);
18472 -
18473 might_fault();
18474 - if (likely(sz == -1 || sz >= n))
18475 - n = _copy_from_user(to, from, n);
18476 -#ifdef CONFIG_DEBUG_VM
18477 - else
18478 - WARN(1, "Buffer overflow detected!\n");
18479 -#endif
18480 +
18481 + check_object_size(to, n, false);
18482 +
18483 + if (access_ok(VERIFY_READ, from, n))
18484 + n = __copy_from_user(to, from, n);
18485 + else if (n < INT_MAX)
18486 + memset(to, 0, n);
18487 return n;
18488 }
18489
18490 static __always_inline __must_check
18491 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18492 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18493 {
18494 might_fault();
18495
18496 - return _copy_to_user(dst, src, size);
18497 + if (access_ok(VERIFY_WRITE, dst, size))
18498 + size = __copy_to_user(dst, src, size);
18499 + return size;
18500 }
18501
18502 static __always_inline __must_check
18503 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18504 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18505 {
18506 - int ret = 0;
18507 + size_t sz = __compiletime_object_size(dst);
18508 + unsigned ret = 0;
18509
18510 might_fault();
18511 +
18512 + if (size > INT_MAX)
18513 + return size;
18514 +
18515 + check_object_size(dst, size, false);
18516 +
18517 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18518 + if (!__access_ok(VERIFY_READ, src, size))
18519 + return size;
18520 +#endif
18521 +
18522 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18523 + copy_from_user_overflow();
18524 + return size;
18525 + }
18526 +
18527 if (!__builtin_constant_p(size))
18528 - return copy_user_generic(dst, (__force void *)src, size);
18529 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18530 switch (size) {
18531 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18532 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18533 ret, "b", "b", "=q", 1);
18534 return ret;
18535 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18536 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18537 ret, "w", "w", "=r", 2);
18538 return ret;
18539 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18540 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18541 ret, "l", "k", "=r", 4);
18542 return ret;
18543 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18544 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18545 ret, "q", "", "=r", 8);
18546 return ret;
18547 case 10:
18548 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18549 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18550 ret, "q", "", "=r", 10);
18551 if (unlikely(ret))
18552 return ret;
18553 __get_user_asm(*(u16 *)(8 + (char *)dst),
18554 - (u16 __user *)(8 + (char __user *)src),
18555 + (const u16 __user *)(8 + (const char __user *)src),
18556 ret, "w", "w", "=r", 2);
18557 return ret;
18558 case 16:
18559 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18560 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18561 ret, "q", "", "=r", 16);
18562 if (unlikely(ret))
18563 return ret;
18564 __get_user_asm(*(u64 *)(8 + (char *)dst),
18565 - (u64 __user *)(8 + (char __user *)src),
18566 + (const u64 __user *)(8 + (const char __user *)src),
18567 ret, "q", "", "=r", 8);
18568 return ret;
18569 default:
18570 - return copy_user_generic(dst, (__force void *)src, size);
18571 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18572 }
18573 }
18574
18575 static __always_inline __must_check
18576 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18577 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18578 {
18579 - int ret = 0;
18580 + size_t sz = __compiletime_object_size(src);
18581 + unsigned ret = 0;
18582
18583 might_fault();
18584 +
18585 + if (size > INT_MAX)
18586 + return size;
18587 +
18588 + check_object_size(src, size, true);
18589 +
18590 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18591 + if (!__access_ok(VERIFY_WRITE, dst, size))
18592 + return size;
18593 +#endif
18594 +
18595 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18596 + copy_to_user_overflow();
18597 + return size;
18598 + }
18599 +
18600 if (!__builtin_constant_p(size))
18601 - return copy_user_generic((__force void *)dst, src, size);
18602 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18603 switch (size) {
18604 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18605 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18606 ret, "b", "b", "iq", 1);
18607 return ret;
18608 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18609 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18610 ret, "w", "w", "ir", 2);
18611 return ret;
18612 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18613 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18614 ret, "l", "k", "ir", 4);
18615 return ret;
18616 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18617 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18618 ret, "q", "", "er", 8);
18619 return ret;
18620 case 10:
18621 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18622 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18623 ret, "q", "", "er", 10);
18624 if (unlikely(ret))
18625 return ret;
18626 asm("":::"memory");
18627 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18628 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18629 ret, "w", "w", "ir", 2);
18630 return ret;
18631 case 16:
18632 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18633 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18634 ret, "q", "", "er", 16);
18635 if (unlikely(ret))
18636 return ret;
18637 asm("":::"memory");
18638 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18639 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18640 ret, "q", "", "er", 8);
18641 return ret;
18642 default:
18643 - return copy_user_generic((__force void *)dst, src, size);
18644 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18645 }
18646 }
18647
18648 static __always_inline __must_check
18649 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18650 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18651 {
18652 - int ret = 0;
18653 + unsigned ret = 0;
18654
18655 might_fault();
18656 +
18657 + if (size > INT_MAX)
18658 + return size;
18659 +
18660 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18661 + if (!__access_ok(VERIFY_READ, src, size))
18662 + return size;
18663 + if (!__access_ok(VERIFY_WRITE, dst, size))
18664 + return size;
18665 +#endif
18666 +
18667 if (!__builtin_constant_p(size))
18668 - return copy_user_generic((__force void *)dst,
18669 - (__force void *)src, size);
18670 + return copy_user_generic((__force_kernel void *)____m(dst),
18671 + (__force_kernel const void *)____m(src), size);
18672 switch (size) {
18673 case 1: {
18674 u8 tmp;
18675 - __get_user_asm(tmp, (u8 __user *)src,
18676 + __get_user_asm(tmp, (const u8 __user *)src,
18677 ret, "b", "b", "=q", 1);
18678 if (likely(!ret))
18679 __put_user_asm(tmp, (u8 __user *)dst,
18680 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18681 }
18682 case 2: {
18683 u16 tmp;
18684 - __get_user_asm(tmp, (u16 __user *)src,
18685 + __get_user_asm(tmp, (const u16 __user *)src,
18686 ret, "w", "w", "=r", 2);
18687 if (likely(!ret))
18688 __put_user_asm(tmp, (u16 __user *)dst,
18689 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18690
18691 case 4: {
18692 u32 tmp;
18693 - __get_user_asm(tmp, (u32 __user *)src,
18694 + __get_user_asm(tmp, (const u32 __user *)src,
18695 ret, "l", "k", "=r", 4);
18696 if (likely(!ret))
18697 __put_user_asm(tmp, (u32 __user *)dst,
18698 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18699 }
18700 case 8: {
18701 u64 tmp;
18702 - __get_user_asm(tmp, (u64 __user *)src,
18703 + __get_user_asm(tmp, (const u64 __user *)src,
18704 ret, "q", "", "=r", 8);
18705 if (likely(!ret))
18706 __put_user_asm(tmp, (u64 __user *)dst,
18707 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18708 return ret;
18709 }
18710 default:
18711 - return copy_user_generic((__force void *)dst,
18712 - (__force void *)src, size);
18713 + return copy_user_generic((__force_kernel void *)____m(dst),
18714 + (__force_kernel const void *)____m(src), size);
18715 }
18716 }
18717
18718 -static __must_check __always_inline int
18719 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18720 +static __must_check __always_inline unsigned long
18721 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18722 {
18723 - return copy_user_generic(dst, (__force const void *)src, size);
18724 + if (size > INT_MAX)
18725 + return size;
18726 +
18727 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18728 + if (!__access_ok(VERIFY_READ, src, size))
18729 + return size;
18730 +#endif
18731 +
18732 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18733 }
18734
18735 -static __must_check __always_inline int
18736 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18737 +static __must_check __always_inline unsigned long
18738 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18739 {
18740 - return copy_user_generic((__force void *)dst, src, size);
18741 + if (size > INT_MAX)
18742 + return size;
18743 +
18744 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18745 + if (!__access_ok(VERIFY_WRITE, dst, size))
18746 + return size;
18747 +#endif
18748 +
18749 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18750 }
18751
18752 -extern long __copy_user_nocache(void *dst, const void __user *src,
18753 - unsigned size, int zerorest);
18754 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18755 + unsigned long size, int zerorest) __size_overflow(3);
18756
18757 -static inline int
18758 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18759 +static inline unsigned long
18760 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18761 {
18762 might_fault();
18763 +
18764 + if (size > INT_MAX)
18765 + return size;
18766 +
18767 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18768 + if (!__access_ok(VERIFY_READ, src, size))
18769 + return size;
18770 +#endif
18771 +
18772 return __copy_user_nocache(dst, src, size, 1);
18773 }
18774
18775 -static inline int
18776 +static inline unsigned long
18777 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18778 - unsigned size)
18779 + unsigned long size)
18780 {
18781 + if (size > INT_MAX)
18782 + return size;
18783 +
18784 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18785 + if (!__access_ok(VERIFY_READ, src, size))
18786 + return size;
18787 +#endif
18788 +
18789 return __copy_user_nocache(dst, src, size, 0);
18790 }
18791
18792 unsigned long
18793 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18794 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18795
18796 #endif /* _ASM_X86_UACCESS_64_H */
18797 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18798 index 5b238981..77fdd78 100644
18799 --- a/arch/x86/include/asm/word-at-a-time.h
18800 +++ b/arch/x86/include/asm/word-at-a-time.h
18801 @@ -11,7 +11,7 @@
18802 * and shift, for example.
18803 */
18804 struct word_at_a_time {
18805 - const unsigned long one_bits, high_bits;
18806 + unsigned long one_bits, high_bits;
18807 };
18808
18809 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18810 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18811 index 828a156..650e625 100644
18812 --- a/arch/x86/include/asm/x86_init.h
18813 +++ b/arch/x86/include/asm/x86_init.h
18814 @@ -129,7 +129,7 @@ struct x86_init_ops {
18815 struct x86_init_timers timers;
18816 struct x86_init_iommu iommu;
18817 struct x86_init_pci pci;
18818 -};
18819 +} __no_const;
18820
18821 /**
18822 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18823 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18824 void (*setup_percpu_clockev)(void);
18825 void (*early_percpu_clock_init)(void);
18826 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18827 -};
18828 +} __no_const;
18829
18830 struct timespec;
18831
18832 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18833 void (*save_sched_clock_state)(void);
18834 void (*restore_sched_clock_state)(void);
18835 void (*apic_post_init)(void);
18836 -};
18837 +} __no_const;
18838
18839 struct pci_dev;
18840 struct msi_msg;
18841 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18842 void (*teardown_msi_irqs)(struct pci_dev *dev);
18843 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18844 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18845 -};
18846 +} __no_const;
18847
18848 struct IO_APIC_route_entry;
18849 struct io_apic_irq_attr;
18850 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18851 unsigned int destination, int vector,
18852 struct io_apic_irq_attr *attr);
18853 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18854 -};
18855 +} __no_const;
18856
18857 extern struct x86_init_ops x86_init;
18858 extern struct x86_cpuinit_ops x86_cpuinit;
18859 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18860 index 0415cda..3b22adc 100644
18861 --- a/arch/x86/include/asm/xsave.h
18862 +++ b/arch/x86/include/asm/xsave.h
18863 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18864 if (unlikely(err))
18865 return -EFAULT;
18866
18867 + pax_open_userland();
18868 __asm__ __volatile__(ASM_STAC "\n"
18869 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18870 + "1:"
18871 + __copyuser_seg
18872 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18873 "2: " ASM_CLAC "\n"
18874 ".section .fixup,\"ax\"\n"
18875 "3: movl $-1,%[err]\n"
18876 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18877 : [err] "=r" (err)
18878 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18879 : "memory");
18880 + pax_close_userland();
18881 return err;
18882 }
18883
18884 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18885 {
18886 int err;
18887 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18888 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18889 u32 lmask = mask;
18890 u32 hmask = mask >> 32;
18891
18892 + pax_open_userland();
18893 __asm__ __volatile__(ASM_STAC "\n"
18894 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18895 + "1:"
18896 + __copyuser_seg
18897 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18898 "2: " ASM_CLAC "\n"
18899 ".section .fixup,\"ax\"\n"
18900 "3: movl $-1,%[err]\n"
18901 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18902 : [err] "=r" (err)
18903 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18904 : "memory"); /* memory required? */
18905 + pax_close_userland();
18906 return err;
18907 }
18908
18909 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18910 index bbae024..e1528f9 100644
18911 --- a/arch/x86/include/uapi/asm/e820.h
18912 +++ b/arch/x86/include/uapi/asm/e820.h
18913 @@ -63,7 +63,7 @@ struct e820map {
18914 #define ISA_START_ADDRESS 0xa0000
18915 #define ISA_END_ADDRESS 0x100000
18916
18917 -#define BIOS_BEGIN 0x000a0000
18918 +#define BIOS_BEGIN 0x000c0000
18919 #define BIOS_END 0x00100000
18920
18921 #define BIOS_ROM_BASE 0xffe00000
18922 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18923 index 88d99ea..9fc7e17 100644
18924 --- a/arch/x86/kernel/Makefile
18925 +++ b/arch/x86/kernel/Makefile
18926 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18927 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18928 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18929 obj-y += probe_roms.o
18930 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18931 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18932 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18933 obj-y += syscall_$(BITS).o
18934 obj-$(CONFIG_X86_64) += vsyscall_64.o
18935 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18936 index 2627a81..cd8325e 100644
18937 --- a/arch/x86/kernel/acpi/boot.c
18938 +++ b/arch/x86/kernel/acpi/boot.c
18939 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18940 * If your system is blacklisted here, but you find that acpi=force
18941 * works for you, please contact linux-acpi@vger.kernel.org
18942 */
18943 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18944 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18945 /*
18946 * Boxes that need ACPI disabled
18947 */
18948 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18949 };
18950
18951 /* second table for DMI checks that should run after early-quirks */
18952 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18953 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18954 /*
18955 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18956 * which includes some code which overrides all temperature
18957 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18958 index 3312010..a65ca7b 100644
18959 --- a/arch/x86/kernel/acpi/sleep.c
18960 +++ b/arch/x86/kernel/acpi/sleep.c
18961 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18962 #else /* CONFIG_64BIT */
18963 #ifdef CONFIG_SMP
18964 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18965 +
18966 + pax_open_kernel();
18967 early_gdt_descr.address =
18968 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18969 + pax_close_kernel();
18970 +
18971 initial_gs = per_cpu_offset(smp_processor_id());
18972 #endif
18973 initial_code = (unsigned long)wakeup_long64;
18974 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18975 index d1daa66..59fecba 100644
18976 --- a/arch/x86/kernel/acpi/wakeup_32.S
18977 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18978 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18979 # and restore the stack ... but you need gdt for this to work
18980 movl saved_context_esp, %esp
18981
18982 - movl %cs:saved_magic, %eax
18983 - cmpl $0x12345678, %eax
18984 + cmpl $0x12345678, saved_magic
18985 jne bogus_magic
18986
18987 # jump to place where we left off
18988 - movl saved_eip, %eax
18989 - jmp *%eax
18990 + jmp *(saved_eip)
18991
18992 bogus_magic:
18993 jmp bogus_magic
18994 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18995 index c15cf9a..0e63558 100644
18996 --- a/arch/x86/kernel/alternative.c
18997 +++ b/arch/x86/kernel/alternative.c
18998 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18999 */
19000 for (a = start; a < end; a++) {
19001 instr = (u8 *)&a->instr_offset + a->instr_offset;
19002 +
19003 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19004 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19005 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
19006 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19007 +#endif
19008 +
19009 replacement = (u8 *)&a->repl_offset + a->repl_offset;
19010 BUG_ON(a->replacementlen > a->instrlen);
19011 BUG_ON(a->instrlen > sizeof(insnbuf));
19012 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
19013 for (poff = start; poff < end; poff++) {
19014 u8 *ptr = (u8 *)poff + *poff;
19015
19016 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19017 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19018 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19019 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19020 +#endif
19021 +
19022 if (!*poff || ptr < text || ptr >= text_end)
19023 continue;
19024 /* turn DS segment override prefix into lock prefix */
19025 - if (*ptr == 0x3e)
19026 + if (*ktla_ktva(ptr) == 0x3e)
19027 text_poke(ptr, ((unsigned char []){0xf0}), 1);
19028 }
19029 mutex_unlock(&text_mutex);
19030 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
19031 for (poff = start; poff < end; poff++) {
19032 u8 *ptr = (u8 *)poff + *poff;
19033
19034 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19035 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19036 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19037 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19038 +#endif
19039 +
19040 if (!*poff || ptr < text || ptr >= text_end)
19041 continue;
19042 /* turn lock prefix into DS segment override prefix */
19043 - if (*ptr == 0xf0)
19044 + if (*ktla_ktva(ptr) == 0xf0)
19045 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19046 }
19047 mutex_unlock(&text_mutex);
19048 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19049
19050 BUG_ON(p->len > MAX_PATCH_LEN);
19051 /* prep the buffer with the original instructions */
19052 - memcpy(insnbuf, p->instr, p->len);
19053 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19054 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19055 (unsigned long)p->instr, p->len);
19056
19057 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19058 if (!uniproc_patched || num_possible_cpus() == 1)
19059 free_init_pages("SMP alternatives",
19060 (unsigned long)__smp_locks,
19061 - (unsigned long)__smp_locks_end);
19062 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19063 #endif
19064
19065 apply_paravirt(__parainstructions, __parainstructions_end);
19066 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19067 * instructions. And on the local CPU you need to be protected again NMI or MCE
19068 * handlers seeing an inconsistent instruction while you patch.
19069 */
19070 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19071 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19072 size_t len)
19073 {
19074 unsigned long flags;
19075 local_irq_save(flags);
19076 - memcpy(addr, opcode, len);
19077 +
19078 + pax_open_kernel();
19079 + memcpy(ktla_ktva(addr), opcode, len);
19080 sync_core();
19081 + pax_close_kernel();
19082 +
19083 local_irq_restore(flags);
19084 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19085 that causes hangs on some VIA CPUs. */
19086 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19087 */
19088 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19089 {
19090 - unsigned long flags;
19091 - char *vaddr;
19092 + unsigned char *vaddr = ktla_ktva(addr);
19093 struct page *pages[2];
19094 - int i;
19095 + size_t i;
19096
19097 if (!core_kernel_text((unsigned long)addr)) {
19098 - pages[0] = vmalloc_to_page(addr);
19099 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19100 + pages[0] = vmalloc_to_page(vaddr);
19101 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19102 } else {
19103 - pages[0] = virt_to_page(addr);
19104 + pages[0] = virt_to_page(vaddr);
19105 WARN_ON(!PageReserved(pages[0]));
19106 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19107 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19108 }
19109 BUG_ON(!pages[0]);
19110 - local_irq_save(flags);
19111 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19112 - if (pages[1])
19113 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19114 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19115 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19116 - clear_fixmap(FIX_TEXT_POKE0);
19117 - if (pages[1])
19118 - clear_fixmap(FIX_TEXT_POKE1);
19119 - local_flush_tlb();
19120 - sync_core();
19121 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19122 - that causes hangs on some VIA CPUs. */
19123 + text_poke_early(addr, opcode, len);
19124 for (i = 0; i < len; i++)
19125 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19126 - local_irq_restore(flags);
19127 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19128 return addr;
19129 }
19130
19131 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19132 index eca89c5..d566b78 100644
19133 --- a/arch/x86/kernel/apic/apic.c
19134 +++ b/arch/x86/kernel/apic/apic.c
19135 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19136 /*
19137 * Debug level, exported for io_apic.c
19138 */
19139 -unsigned int apic_verbosity;
19140 +int apic_verbosity;
19141
19142 int pic_mode;
19143
19144 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19145 apic_write(APIC_ESR, 0);
19146 v1 = apic_read(APIC_ESR);
19147 ack_APIC_irq();
19148 - atomic_inc(&irq_err_count);
19149 + atomic_inc_unchecked(&irq_err_count);
19150
19151 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19152 smp_processor_id(), v0 , v1);
19153 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19154 index 00c77cf..2dc6a2d 100644
19155 --- a/arch/x86/kernel/apic/apic_flat_64.c
19156 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19157 @@ -157,7 +157,7 @@ static int flat_probe(void)
19158 return 1;
19159 }
19160
19161 -static struct apic apic_flat = {
19162 +static struct apic apic_flat __read_only = {
19163 .name = "flat",
19164 .probe = flat_probe,
19165 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19166 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19167 return 0;
19168 }
19169
19170 -static struct apic apic_physflat = {
19171 +static struct apic apic_physflat __read_only = {
19172
19173 .name = "physical flat",
19174 .probe = physflat_probe,
19175 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19176 index e145f28..2752888 100644
19177 --- a/arch/x86/kernel/apic/apic_noop.c
19178 +++ b/arch/x86/kernel/apic/apic_noop.c
19179 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19180 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19181 }
19182
19183 -struct apic apic_noop = {
19184 +struct apic apic_noop __read_only = {
19185 .name = "noop",
19186 .probe = noop_probe,
19187 .acpi_madt_oem_check = NULL,
19188 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19189 index d50e364..543bee3 100644
19190 --- a/arch/x86/kernel/apic/bigsmp_32.c
19191 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19192 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19193 return dmi_bigsmp;
19194 }
19195
19196 -static struct apic apic_bigsmp = {
19197 +static struct apic apic_bigsmp __read_only = {
19198
19199 .name = "bigsmp",
19200 .probe = probe_bigsmp,
19201 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19202 index c552247..587a316 100644
19203 --- a/arch/x86/kernel/apic/es7000_32.c
19204 +++ b/arch/x86/kernel/apic/es7000_32.c
19205 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19206 return ret && es7000_apic_is_cluster();
19207 }
19208
19209 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19210 -static struct apic __refdata apic_es7000_cluster = {
19211 +static struct apic apic_es7000_cluster __read_only = {
19212
19213 .name = "es7000",
19214 .probe = probe_es7000,
19215 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19216 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19217 };
19218
19219 -static struct apic __refdata apic_es7000 = {
19220 +static struct apic apic_es7000 __read_only = {
19221
19222 .name = "es7000",
19223 .probe = probe_es7000,
19224 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19225 index 9ed796c..e930fe4 100644
19226 --- a/arch/x86/kernel/apic/io_apic.c
19227 +++ b/arch/x86/kernel/apic/io_apic.c
19228 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19229 }
19230 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19231
19232 -void lock_vector_lock(void)
19233 +void lock_vector_lock(void) __acquires(vector_lock)
19234 {
19235 /* Used to the online set of cpus does not change
19236 * during assign_irq_vector.
19237 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19238 raw_spin_lock(&vector_lock);
19239 }
19240
19241 -void unlock_vector_lock(void)
19242 +void unlock_vector_lock(void) __releases(vector_lock)
19243 {
19244 raw_spin_unlock(&vector_lock);
19245 }
19246 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19247 ack_APIC_irq();
19248 }
19249
19250 -atomic_t irq_mis_count;
19251 +atomic_unchecked_t irq_mis_count;
19252
19253 #ifdef CONFIG_GENERIC_PENDING_IRQ
19254 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19255 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19256 * at the cpu.
19257 */
19258 if (!(v & (1 << (i & 0x1f)))) {
19259 - atomic_inc(&irq_mis_count);
19260 + atomic_inc_unchecked(&irq_mis_count);
19261
19262 eoi_ioapic_irq(irq, cfg);
19263 }
19264 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19265 index 1e42e8f..daacf44 100644
19266 --- a/arch/x86/kernel/apic/numaq_32.c
19267 +++ b/arch/x86/kernel/apic/numaq_32.c
19268 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19269 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19270 }
19271
19272 -/* Use __refdata to keep false positive warning calm. */
19273 -static struct apic __refdata apic_numaq = {
19274 +static struct apic apic_numaq __read_only = {
19275
19276 .name = "NUMAQ",
19277 .probe = probe_numaq,
19278 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19279 index eb35ef9..f184a21 100644
19280 --- a/arch/x86/kernel/apic/probe_32.c
19281 +++ b/arch/x86/kernel/apic/probe_32.c
19282 @@ -72,7 +72,7 @@ static int probe_default(void)
19283 return 1;
19284 }
19285
19286 -static struct apic apic_default = {
19287 +static struct apic apic_default __read_only = {
19288
19289 .name = "default",
19290 .probe = probe_default,
19291 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19292 index 77c95c0..434f8a4 100644
19293 --- a/arch/x86/kernel/apic/summit_32.c
19294 +++ b/arch/x86/kernel/apic/summit_32.c
19295 @@ -486,7 +486,7 @@ void setup_summit(void)
19296 }
19297 #endif
19298
19299 -static struct apic apic_summit = {
19300 +static struct apic apic_summit __read_only = {
19301
19302 .name = "summit",
19303 .probe = probe_summit,
19304 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19305 index 140e29d..d88bc95 100644
19306 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19307 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19308 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19309 return notifier_from_errno(err);
19310 }
19311
19312 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19313 +static struct notifier_block x2apic_cpu_notifier = {
19314 .notifier_call = update_clusterinfo,
19315 };
19316
19317 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19318 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19319 }
19320
19321 -static struct apic apic_x2apic_cluster = {
19322 +static struct apic apic_x2apic_cluster __read_only = {
19323
19324 .name = "cluster x2apic",
19325 .probe = x2apic_cluster_probe,
19326 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19327 index 562a76d..a003c0f 100644
19328 --- a/arch/x86/kernel/apic/x2apic_phys.c
19329 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19330 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19331 return apic == &apic_x2apic_phys;
19332 }
19333
19334 -static struct apic apic_x2apic_phys = {
19335 +static struct apic apic_x2apic_phys __read_only = {
19336
19337 .name = "physical x2apic",
19338 .probe = x2apic_phys_probe,
19339 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19340 index 1191ac1..2335fa4 100644
19341 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19342 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19343 @@ -357,7 +357,7 @@ static int uv_probe(void)
19344 return apic == &apic_x2apic_uv_x;
19345 }
19346
19347 -static struct apic __refdata apic_x2apic_uv_x = {
19348 +static struct apic apic_x2apic_uv_x __read_only = {
19349
19350 .name = "UV large system",
19351 .probe = uv_probe,
19352 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19353 index 53a4e27..038760a 100644
19354 --- a/arch/x86/kernel/apm_32.c
19355 +++ b/arch/x86/kernel/apm_32.c
19356 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19357 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19358 * even though they are called in protected mode.
19359 */
19360 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19361 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19362 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19363
19364 static const char driver_version[] = "1.16ac"; /* no spaces */
19365 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19366 BUG_ON(cpu != 0);
19367 gdt = get_cpu_gdt_table(cpu);
19368 save_desc_40 = gdt[0x40 / 8];
19369 +
19370 + pax_open_kernel();
19371 gdt[0x40 / 8] = bad_bios_desc;
19372 + pax_close_kernel();
19373
19374 apm_irq_save(flags);
19375 APM_DO_SAVE_SEGS;
19376 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19377 &call->esi);
19378 APM_DO_RESTORE_SEGS;
19379 apm_irq_restore(flags);
19380 +
19381 + pax_open_kernel();
19382 gdt[0x40 / 8] = save_desc_40;
19383 + pax_close_kernel();
19384 +
19385 put_cpu();
19386
19387 return call->eax & 0xff;
19388 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19389 BUG_ON(cpu != 0);
19390 gdt = get_cpu_gdt_table(cpu);
19391 save_desc_40 = gdt[0x40 / 8];
19392 +
19393 + pax_open_kernel();
19394 gdt[0x40 / 8] = bad_bios_desc;
19395 + pax_close_kernel();
19396
19397 apm_irq_save(flags);
19398 APM_DO_SAVE_SEGS;
19399 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19400 &call->eax);
19401 APM_DO_RESTORE_SEGS;
19402 apm_irq_restore(flags);
19403 +
19404 + pax_open_kernel();
19405 gdt[0x40 / 8] = save_desc_40;
19406 + pax_close_kernel();
19407 +
19408 put_cpu();
19409 return error;
19410 }
19411 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19412 * code to that CPU.
19413 */
19414 gdt = get_cpu_gdt_table(0);
19415 +
19416 + pax_open_kernel();
19417 set_desc_base(&gdt[APM_CS >> 3],
19418 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19419 set_desc_base(&gdt[APM_CS_16 >> 3],
19420 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19421 set_desc_base(&gdt[APM_DS >> 3],
19422 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19423 + pax_close_kernel();
19424
19425 proc_create("apm", 0, NULL, &apm_file_ops);
19426
19427 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19428 index 2861082..6d4718e 100644
19429 --- a/arch/x86/kernel/asm-offsets.c
19430 +++ b/arch/x86/kernel/asm-offsets.c
19431 @@ -33,6 +33,8 @@ void common(void) {
19432 OFFSET(TI_status, thread_info, status);
19433 OFFSET(TI_addr_limit, thread_info, addr_limit);
19434 OFFSET(TI_preempt_count, thread_info, preempt_count);
19435 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19436 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19437
19438 BLANK();
19439 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19440 @@ -53,8 +55,26 @@ void common(void) {
19441 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19442 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19443 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19444 +
19445 +#ifdef CONFIG_PAX_KERNEXEC
19446 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19447 #endif
19448
19449 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19450 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19451 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19452 +#ifdef CONFIG_X86_64
19453 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19454 +#endif
19455 +#endif
19456 +
19457 +#endif
19458 +
19459 + BLANK();
19460 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19461 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19462 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19463 +
19464 #ifdef CONFIG_XEN
19465 BLANK();
19466 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19467 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19468 index e7c798b..2b2019b 100644
19469 --- a/arch/x86/kernel/asm-offsets_64.c
19470 +++ b/arch/x86/kernel/asm-offsets_64.c
19471 @@ -77,6 +77,7 @@ int main(void)
19472 BLANK();
19473 #undef ENTRY
19474
19475 + DEFINE(TSS_size, sizeof(struct tss_struct));
19476 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19477 BLANK();
19478
19479 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19480 index 47b56a7..efc2bc6 100644
19481 --- a/arch/x86/kernel/cpu/Makefile
19482 +++ b/arch/x86/kernel/cpu/Makefile
19483 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19484 CFLAGS_REMOVE_perf_event.o = -pg
19485 endif
19486
19487 -# Make sure load_percpu_segment has no stackprotector
19488 -nostackp := $(call cc-option, -fno-stack-protector)
19489 -CFLAGS_common.o := $(nostackp)
19490 -
19491 obj-y := intel_cacheinfo.o scattered.o topology.o
19492 obj-y += proc.o capflags.o powerflags.o common.o
19493 obj-y += rdrand.o
19494 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19495 index 08a0890..e557865 100644
19496 --- a/arch/x86/kernel/cpu/amd.c
19497 +++ b/arch/x86/kernel/cpu/amd.c
19498 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19499 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19500 {
19501 /* AMD errata T13 (order #21922) */
19502 - if ((c->x86 == 6)) {
19503 + if (c->x86 == 6) {
19504 /* Duron Rev A0 */
19505 if (c->x86_model == 3 && c->x86_mask == 0)
19506 size = 64;
19507 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19508 index 25eb274..3a92d93 100644
19509 --- a/arch/x86/kernel/cpu/common.c
19510 +++ b/arch/x86/kernel/cpu/common.c
19511 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19512
19513 static const struct cpu_dev *this_cpu = &default_cpu;
19514
19515 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19516 -#ifdef CONFIG_X86_64
19517 - /*
19518 - * We need valid kernel segments for data and code in long mode too
19519 - * IRET will check the segment types kkeil 2000/10/28
19520 - * Also sysret mandates a special GDT layout
19521 - *
19522 - * TLS descriptors are currently at a different place compared to i386.
19523 - * Hopefully nobody expects them at a fixed place (Wine?)
19524 - */
19525 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19526 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19527 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19528 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19529 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19530 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19531 -#else
19532 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19533 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19534 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19535 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19536 - /*
19537 - * Segments used for calling PnP BIOS have byte granularity.
19538 - * They code segments and data segments have fixed 64k limits,
19539 - * the transfer segment sizes are set at run time.
19540 - */
19541 - /* 32-bit code */
19542 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19543 - /* 16-bit code */
19544 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19545 - /* 16-bit data */
19546 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19547 - /* 16-bit data */
19548 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19549 - /* 16-bit data */
19550 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19551 - /*
19552 - * The APM segments have byte granularity and their bases
19553 - * are set at run time. All have 64k limits.
19554 - */
19555 - /* 32-bit code */
19556 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19557 - /* 16-bit code */
19558 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19559 - /* data */
19560 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19561 -
19562 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19563 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19564 - GDT_STACK_CANARY_INIT
19565 -#endif
19566 -} };
19567 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19568 -
19569 static int __init x86_xsave_setup(char *s)
19570 {
19571 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19572 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19573 set_in_cr4(X86_CR4_SMAP);
19574 }
19575
19576 +#ifdef CONFIG_X86_64
19577 +static __init int setup_disable_pcid(char *arg)
19578 +{
19579 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19580 +
19581 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19582 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19583 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19584 +#endif
19585 +
19586 + return 1;
19587 +}
19588 +__setup("nopcid", setup_disable_pcid);
19589 +
19590 +static void setup_pcid(struct cpuinfo_x86 *c)
19591 +{
19592 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19593 +
19594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19595 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19596 + pax_open_kernel();
19597 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19598 + pax_close_kernel();
19599 + printk("PAX: slow and weak UDEREF enabled\n");
19600 + } else
19601 + printk("PAX: UDEREF disabled\n");
19602 +#endif
19603 +
19604 + return;
19605 + }
19606 +
19607 + printk("PAX: PCID detected\n");
19608 + set_in_cr4(X86_CR4_PCIDE);
19609 +
19610 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19611 + pax_open_kernel();
19612 + clone_pgd_mask = ~(pgdval_t)0UL;
19613 + pax_close_kernel();
19614 + if (pax_user_shadow_base)
19615 + printk("PAX: weak UDEREF enabled\n");
19616 + else {
19617 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19618 + printk("PAX: strong UDEREF enabled\n");
19619 + }
19620 +#endif
19621 +
19622 + if (cpu_has(c, X86_FEATURE_INVPCID))
19623 + printk("PAX: INVPCID detected\n");
19624 +}
19625 +#endif
19626 +
19627 /*
19628 * Some CPU features depend on higher CPUID levels, which may not always
19629 * be available due to CPUID level capping or broken virtualization
19630 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19631 {
19632 struct desc_ptr gdt_descr;
19633
19634 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19635 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19636 gdt_descr.size = GDT_SIZE - 1;
19637 load_gdt(&gdt_descr);
19638 /* Reload the per-cpu base */
19639 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19640 setup_smep(c);
19641 setup_smap(c);
19642
19643 +#ifdef CONFIG_X86_64
19644 + setup_pcid(c);
19645 +#endif
19646 +
19647 /*
19648 * The vendor-specific functions might have changed features.
19649 * Now we do "generic changes."
19650 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19651 /* Filter out anything that depends on CPUID levels we don't have */
19652 filter_cpuid_features(c, true);
19653
19654 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19655 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19656 +#endif
19657 +
19658 /* If the model name is still unset, do table lookup. */
19659 if (!c->x86_model_id[0]) {
19660 const char *p;
19661 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19662 }
19663 __setup("clearcpuid=", setup_disablecpuid);
19664
19665 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19666 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19667 +
19668 #ifdef CONFIG_X86_64
19669 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19670 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19671 - (unsigned long) debug_idt_table };
19672 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19673 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19674
19675 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19676 irq_stack_union) __aligned(PAGE_SIZE);
19677 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19678 EXPORT_PER_CPU_SYMBOL(current_task);
19679
19680 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19681 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19682 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19683 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19684
19685 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19686 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19687 load_ucode_ap();
19688
19689 cpu = stack_smp_processor_id();
19690 - t = &per_cpu(init_tss, cpu);
19691 + t = init_tss + cpu;
19692 oist = &per_cpu(orig_ist, cpu);
19693
19694 #ifdef CONFIG_NUMA
19695 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19696 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19697 barrier();
19698
19699 - x86_configure_nx();
19700 enable_x2apic();
19701
19702 /*
19703 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19704 {
19705 int cpu = smp_processor_id();
19706 struct task_struct *curr = current;
19707 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19708 + struct tss_struct *t = init_tss + cpu;
19709 struct thread_struct *thread = &curr->thread;
19710
19711 show_ucode_info_early();
19712 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19713 index 1414c90..1159406 100644
19714 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19715 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19716 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19717 };
19718
19719 #ifdef CONFIG_AMD_NB
19720 +static struct attribute *default_attrs_amd_nb[] = {
19721 + &type.attr,
19722 + &level.attr,
19723 + &coherency_line_size.attr,
19724 + &physical_line_partition.attr,
19725 + &ways_of_associativity.attr,
19726 + &number_of_sets.attr,
19727 + &size.attr,
19728 + &shared_cpu_map.attr,
19729 + &shared_cpu_list.attr,
19730 + NULL,
19731 + NULL,
19732 + NULL,
19733 + NULL
19734 +};
19735 +
19736 static struct attribute **amd_l3_attrs(void)
19737 {
19738 static struct attribute **attrs;
19739 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19740
19741 n = ARRAY_SIZE(default_attrs);
19742
19743 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19744 - n += 2;
19745 -
19746 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19747 - n += 1;
19748 -
19749 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19750 - if (attrs == NULL)
19751 - return attrs = default_attrs;
19752 -
19753 - for (n = 0; default_attrs[n]; n++)
19754 - attrs[n] = default_attrs[n];
19755 + attrs = default_attrs_amd_nb;
19756
19757 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19758 attrs[n++] = &cache_disable_0.attr;
19759 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19760 .default_attrs = default_attrs,
19761 };
19762
19763 +#ifdef CONFIG_AMD_NB
19764 +static struct kobj_type ktype_cache_amd_nb = {
19765 + .sysfs_ops = &sysfs_ops,
19766 + .default_attrs = default_attrs_amd_nb,
19767 +};
19768 +#endif
19769 +
19770 static struct kobj_type ktype_percpu_entry = {
19771 .sysfs_ops = &sysfs_ops,
19772 };
19773 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19774 return retval;
19775 }
19776
19777 +#ifdef CONFIG_AMD_NB
19778 + amd_l3_attrs();
19779 +#endif
19780 +
19781 for (i = 0; i < num_cache_leaves; i++) {
19782 + struct kobj_type *ktype;
19783 +
19784 this_object = INDEX_KOBJECT_PTR(cpu, i);
19785 this_object->cpu = cpu;
19786 this_object->index = i;
19787
19788 this_leaf = CPUID4_INFO_IDX(cpu, i);
19789
19790 - ktype_cache.default_attrs = default_attrs;
19791 + ktype = &ktype_cache;
19792 #ifdef CONFIG_AMD_NB
19793 if (this_leaf->base.nb)
19794 - ktype_cache.default_attrs = amd_l3_attrs();
19795 + ktype = &ktype_cache_amd_nb;
19796 #endif
19797 retval = kobject_init_and_add(&(this_object->kobj),
19798 - &ktype_cache,
19799 + ktype,
19800 per_cpu(ici_cache_kobject, cpu),
19801 "index%1lu", i);
19802 if (unlikely(retval)) {
19803 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19804 index 87a65c9..92fcce6 100644
19805 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19806 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19807 @@ -45,6 +45,7 @@
19808 #include <asm/processor.h>
19809 #include <asm/mce.h>
19810 #include <asm/msr.h>
19811 +#include <asm/local.h>
19812
19813 #include "mce-internal.h"
19814
19815 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19816 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19817 m->cs, m->ip);
19818
19819 - if (m->cs == __KERNEL_CS)
19820 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19821 print_symbol("{%s}", m->ip);
19822 pr_cont("\n");
19823 }
19824 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19825
19826 #define PANIC_TIMEOUT 5 /* 5 seconds */
19827
19828 -static atomic_t mce_paniced;
19829 +static atomic_unchecked_t mce_paniced;
19830
19831 static int fake_panic;
19832 -static atomic_t mce_fake_paniced;
19833 +static atomic_unchecked_t mce_fake_paniced;
19834
19835 /* Panic in progress. Enable interrupts and wait for final IPI */
19836 static void wait_for_panic(void)
19837 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19838 /*
19839 * Make sure only one CPU runs in machine check panic
19840 */
19841 - if (atomic_inc_return(&mce_paniced) > 1)
19842 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19843 wait_for_panic();
19844 barrier();
19845
19846 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19847 console_verbose();
19848 } else {
19849 /* Don't log too much for fake panic */
19850 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19851 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19852 return;
19853 }
19854 /* First print corrected ones that are still unlogged */
19855 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19856 if (!fake_panic) {
19857 if (panic_timeout == 0)
19858 panic_timeout = mca_cfg.panic_timeout;
19859 - panic(msg);
19860 + panic("%s", msg);
19861 } else
19862 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19863 }
19864 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19865 * might have been modified by someone else.
19866 */
19867 rmb();
19868 - if (atomic_read(&mce_paniced))
19869 + if (atomic_read_unchecked(&mce_paniced))
19870 wait_for_panic();
19871 if (!mca_cfg.monarch_timeout)
19872 goto out;
19873 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19874 }
19875
19876 /* Call the installed machine check handler for this CPU setup. */
19877 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19878 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19879 unexpected_machine_check;
19880
19881 /*
19882 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19883 return;
19884 }
19885
19886 + pax_open_kernel();
19887 machine_check_vector = do_machine_check;
19888 + pax_close_kernel();
19889
19890 __mcheck_cpu_init_generic();
19891 __mcheck_cpu_init_vendor(c);
19892 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19893 */
19894
19895 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19896 -static int mce_chrdev_open_count; /* #times opened */
19897 +static local_t mce_chrdev_open_count; /* #times opened */
19898 static int mce_chrdev_open_exclu; /* already open exclusive? */
19899
19900 static int mce_chrdev_open(struct inode *inode, struct file *file)
19901 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19902 spin_lock(&mce_chrdev_state_lock);
19903
19904 if (mce_chrdev_open_exclu ||
19905 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19906 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19907 spin_unlock(&mce_chrdev_state_lock);
19908
19909 return -EBUSY;
19910 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19911
19912 if (file->f_flags & O_EXCL)
19913 mce_chrdev_open_exclu = 1;
19914 - mce_chrdev_open_count++;
19915 + local_inc(&mce_chrdev_open_count);
19916
19917 spin_unlock(&mce_chrdev_state_lock);
19918
19919 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19920 {
19921 spin_lock(&mce_chrdev_state_lock);
19922
19923 - mce_chrdev_open_count--;
19924 + local_dec(&mce_chrdev_open_count);
19925 mce_chrdev_open_exclu = 0;
19926
19927 spin_unlock(&mce_chrdev_state_lock);
19928 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19929
19930 for (i = 0; i < mca_cfg.banks; i++) {
19931 struct mce_bank *b = &mce_banks[i];
19932 - struct device_attribute *a = &b->attr;
19933 + device_attribute_no_const *a = &b->attr;
19934
19935 sysfs_attr_init(&a->attr);
19936 a->attr.name = b->attrname;
19937 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19938 static void mce_reset(void)
19939 {
19940 cpu_missing = 0;
19941 - atomic_set(&mce_fake_paniced, 0);
19942 + atomic_set_unchecked(&mce_fake_paniced, 0);
19943 atomic_set(&mce_executing, 0);
19944 atomic_set(&mce_callin, 0);
19945 atomic_set(&global_nwo, 0);
19946 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19947 index 1c044b1..37a2a43 100644
19948 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19949 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19950 @@ -11,6 +11,7 @@
19951 #include <asm/processor.h>
19952 #include <asm/mce.h>
19953 #include <asm/msr.h>
19954 +#include <asm/pgtable.h>
19955
19956 /* By default disabled */
19957 int mce_p5_enabled __read_mostly;
19958 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19959 if (!cpu_has(c, X86_FEATURE_MCE))
19960 return;
19961
19962 + pax_open_kernel();
19963 machine_check_vector = pentium_machine_check;
19964 + pax_close_kernel();
19965 /* Make sure the vector pointer is visible before we enable MCEs: */
19966 wmb();
19967
19968 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19969 index e9a701a..35317d6 100644
19970 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19971 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19972 @@ -10,6 +10,7 @@
19973 #include <asm/processor.h>
19974 #include <asm/mce.h>
19975 #include <asm/msr.h>
19976 +#include <asm/pgtable.h>
19977
19978 /* Machine check handler for WinChip C6: */
19979 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19980 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19981 {
19982 u32 lo, hi;
19983
19984 + pax_open_kernel();
19985 machine_check_vector = winchip_machine_check;
19986 + pax_close_kernel();
19987 /* Make sure the vector pointer is visible before we enable MCEs: */
19988 wmb();
19989
19990 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19991 index f961de9..8a9d332 100644
19992 --- a/arch/x86/kernel/cpu/mtrr/main.c
19993 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19994 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19995 u64 size_or_mask, size_and_mask;
19996 static bool mtrr_aps_delayed_init;
19997
19998 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19999 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
20000
20001 const struct mtrr_ops *mtrr_if;
20002
20003 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
20004 index df5e41f..816c719 100644
20005 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
20006 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
20007 @@ -25,7 +25,7 @@ struct mtrr_ops {
20008 int (*validate_add_page)(unsigned long base, unsigned long size,
20009 unsigned int type);
20010 int (*have_wrcomb)(void);
20011 -};
20012 +} __do_const;
20013
20014 extern int generic_get_free_region(unsigned long base, unsigned long size,
20015 int replace_reg);
20016 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
20017 index a7c7305..b9705ab 100644
20018 --- a/arch/x86/kernel/cpu/perf_event.c
20019 +++ b/arch/x86/kernel/cpu/perf_event.c
20020 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
20021 pr_info("no hardware sampling interrupt available.\n");
20022 }
20023
20024 -static struct attribute_group x86_pmu_format_group = {
20025 +static attribute_group_no_const x86_pmu_format_group = {
20026 .name = "format",
20027 .attrs = NULL,
20028 };
20029 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
20030 NULL,
20031 };
20032
20033 -static struct attribute_group x86_pmu_events_group = {
20034 +static attribute_group_no_const x86_pmu_events_group = {
20035 .name = "events",
20036 .attrs = events_attr,
20037 };
20038 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
20039 if (idx > GDT_ENTRIES)
20040 return 0;
20041
20042 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20043 + desc = get_cpu_gdt_table(smp_processor_id());
20044 }
20045
20046 return get_desc_base(desc + idx);
20047 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20048 break;
20049
20050 perf_callchain_store(entry, frame.return_address);
20051 - fp = frame.next_frame;
20052 + fp = (const void __force_user *)frame.next_frame;
20053 }
20054 }
20055
20056 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20057 index 639d128..e92d7e5 100644
20058 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20059 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20060 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20061 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20062 {
20063 struct attribute **attrs;
20064 - struct attribute_group *attr_group;
20065 + attribute_group_no_const *attr_group;
20066 int i = 0, j;
20067
20068 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20069 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20070 index a45d8d4..8abd32c 100644
20071 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20072 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20073 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20074 * v2 and above have a perf capabilities MSR
20075 */
20076 if (version > 1) {
20077 - u64 capabilities;
20078 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20079
20080 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20081 - x86_pmu.intel_cap.capabilities = capabilities;
20082 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20083 + x86_pmu.intel_cap.capabilities = capabilities;
20084 }
20085
20086 intel_ds_init();
20087 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20088 index 1fb6c72..f5fa2a3 100644
20089 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20090 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20091 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20092 static int __init uncore_type_init(struct intel_uncore_type *type)
20093 {
20094 struct intel_uncore_pmu *pmus;
20095 - struct attribute_group *attr_group;
20096 + attribute_group_no_const *attr_group;
20097 struct attribute **attrs;
20098 int i, j;
20099
20100 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20101 index 47b3d00c..2cf1751 100644
20102 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20103 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20104 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20105 struct uncore_event_desc {
20106 struct kobj_attribute attr;
20107 const char *config;
20108 -};
20109 +} __do_const;
20110
20111 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20112 { \
20113 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20114 index 7d9481c..99c7e4b 100644
20115 --- a/arch/x86/kernel/cpuid.c
20116 +++ b/arch/x86/kernel/cpuid.c
20117 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20118 return notifier_from_errno(err);
20119 }
20120
20121 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20122 +static struct notifier_block cpuid_class_cpu_notifier =
20123 {
20124 .notifier_call = cpuid_class_cpu_callback,
20125 };
20126 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20127 index 74467fe..18793d5 100644
20128 --- a/arch/x86/kernel/crash.c
20129 +++ b/arch/x86/kernel/crash.c
20130 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20131 {
20132 #ifdef CONFIG_X86_32
20133 struct pt_regs fixed_regs;
20134 -#endif
20135
20136 -#ifdef CONFIG_X86_32
20137 - if (!user_mode_vm(regs)) {
20138 + if (!user_mode(regs)) {
20139 crash_fixup_ss_esp(&fixed_regs, regs);
20140 regs = &fixed_regs;
20141 }
20142 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20143 index afa64ad..dce67dd 100644
20144 --- a/arch/x86/kernel/crash_dump_64.c
20145 +++ b/arch/x86/kernel/crash_dump_64.c
20146 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20147 return -ENOMEM;
20148
20149 if (userbuf) {
20150 - if (copy_to_user(buf, vaddr + offset, csize)) {
20151 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20152 iounmap(vaddr);
20153 return -EFAULT;
20154 }
20155 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20156 index 5d3fe8d..02e1429 100644
20157 --- a/arch/x86/kernel/doublefault.c
20158 +++ b/arch/x86/kernel/doublefault.c
20159 @@ -13,7 +13,7 @@
20160
20161 #define DOUBLEFAULT_STACKSIZE (1024)
20162 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20163 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20164 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20165
20166 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20167
20168 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20169 unsigned long gdt, tss;
20170
20171 native_store_gdt(&gdt_desc);
20172 - gdt = gdt_desc.address;
20173 + gdt = (unsigned long)gdt_desc.address;
20174
20175 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20176
20177 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20178 /* 0x2 bit is always set */
20179 .flags = X86_EFLAGS_SF | 0x2,
20180 .sp = STACK_START,
20181 - .es = __USER_DS,
20182 + .es = __KERNEL_DS,
20183 .cs = __KERNEL_CS,
20184 .ss = __KERNEL_DS,
20185 - .ds = __USER_DS,
20186 + .ds = __KERNEL_DS,
20187 .fs = __KERNEL_PERCPU,
20188
20189 .__cr3 = __pa_nodebug(swapper_pg_dir),
20190 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20191 index deb6421..76bbc12 100644
20192 --- a/arch/x86/kernel/dumpstack.c
20193 +++ b/arch/x86/kernel/dumpstack.c
20194 @@ -2,6 +2,9 @@
20195 * Copyright (C) 1991, 1992 Linus Torvalds
20196 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20197 */
20198 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20199 +#define __INCLUDED_BY_HIDESYM 1
20200 +#endif
20201 #include <linux/kallsyms.h>
20202 #include <linux/kprobes.h>
20203 #include <linux/uaccess.h>
20204 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20205 static void
20206 print_ftrace_graph_addr(unsigned long addr, void *data,
20207 const struct stacktrace_ops *ops,
20208 - struct thread_info *tinfo, int *graph)
20209 + struct task_struct *task, int *graph)
20210 {
20211 - struct task_struct *task;
20212 unsigned long ret_addr;
20213 int index;
20214
20215 if (addr != (unsigned long)return_to_handler)
20216 return;
20217
20218 - task = tinfo->task;
20219 index = task->curr_ret_stack;
20220
20221 if (!task->ret_stack || index < *graph)
20222 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20223 static inline void
20224 print_ftrace_graph_addr(unsigned long addr, void *data,
20225 const struct stacktrace_ops *ops,
20226 - struct thread_info *tinfo, int *graph)
20227 + struct task_struct *task, int *graph)
20228 { }
20229 #endif
20230
20231 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20232 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20233 */
20234
20235 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20236 - void *p, unsigned int size, void *end)
20237 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20238 {
20239 - void *t = tinfo;
20240 if (end) {
20241 if (p < end && p >= (end-THREAD_SIZE))
20242 return 1;
20243 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20244 }
20245
20246 unsigned long
20247 -print_context_stack(struct thread_info *tinfo,
20248 +print_context_stack(struct task_struct *task, void *stack_start,
20249 unsigned long *stack, unsigned long bp,
20250 const struct stacktrace_ops *ops, void *data,
20251 unsigned long *end, int *graph)
20252 {
20253 struct stack_frame *frame = (struct stack_frame *)bp;
20254
20255 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20256 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20257 unsigned long addr;
20258
20259 addr = *stack;
20260 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20261 } else {
20262 ops->address(data, addr, 0);
20263 }
20264 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20265 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20266 }
20267 stack++;
20268 }
20269 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20270 EXPORT_SYMBOL_GPL(print_context_stack);
20271
20272 unsigned long
20273 -print_context_stack_bp(struct thread_info *tinfo,
20274 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20275 unsigned long *stack, unsigned long bp,
20276 const struct stacktrace_ops *ops, void *data,
20277 unsigned long *end, int *graph)
20278 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20279 struct stack_frame *frame = (struct stack_frame *)bp;
20280 unsigned long *ret_addr = &frame->return_address;
20281
20282 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20283 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20284 unsigned long addr = *ret_addr;
20285
20286 if (!__kernel_text_address(addr))
20287 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20288 ops->address(data, addr, 1);
20289 frame = frame->next_frame;
20290 ret_addr = &frame->return_address;
20291 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20292 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20293 }
20294
20295 return (unsigned long)frame;
20296 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20297 static void print_trace_address(void *data, unsigned long addr, int reliable)
20298 {
20299 touch_nmi_watchdog();
20300 - printk(data);
20301 + printk("%s", (char *)data);
20302 printk_address(addr, reliable);
20303 }
20304
20305 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20306 }
20307 EXPORT_SYMBOL_GPL(oops_begin);
20308
20309 +extern void gr_handle_kernel_exploit(void);
20310 +
20311 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20312 {
20313 if (regs && kexec_should_crash(current))
20314 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20315 panic("Fatal exception in interrupt");
20316 if (panic_on_oops)
20317 panic("Fatal exception");
20318 - do_exit(signr);
20319 +
20320 + gr_handle_kernel_exploit();
20321 +
20322 + do_group_exit(signr);
20323 }
20324
20325 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20326 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20327 print_modules();
20328 show_regs(regs);
20329 #ifdef CONFIG_X86_32
20330 - if (user_mode_vm(regs)) {
20331 + if (user_mode(regs)) {
20332 sp = regs->sp;
20333 ss = regs->ss & 0xffff;
20334 } else {
20335 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20336 unsigned long flags = oops_begin();
20337 int sig = SIGSEGV;
20338
20339 - if (!user_mode_vm(regs))
20340 + if (!user_mode(regs))
20341 report_bug(regs->ip, regs);
20342
20343 if (__die(str, regs, err))
20344 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20345 index f2a1770..540657f 100644
20346 --- a/arch/x86/kernel/dumpstack_32.c
20347 +++ b/arch/x86/kernel/dumpstack_32.c
20348 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20349 bp = stack_frame(task, regs);
20350
20351 for (;;) {
20352 - struct thread_info *context;
20353 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20354
20355 - context = (struct thread_info *)
20356 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20357 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20358 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20359
20360 - stack = (unsigned long *)context->previous_esp;
20361 - if (!stack)
20362 + if (stack_start == task_stack_page(task))
20363 break;
20364 + stack = *(unsigned long **)stack_start;
20365 if (ops->stack(data, "IRQ") < 0)
20366 break;
20367 touch_nmi_watchdog();
20368 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20369 int i;
20370
20371 show_regs_print_info(KERN_EMERG);
20372 - __show_regs(regs, !user_mode_vm(regs));
20373 + __show_regs(regs, !user_mode(regs));
20374
20375 /*
20376 * When in-kernel, we also print out the stack and code at the
20377 * time of the fault..
20378 */
20379 - if (!user_mode_vm(regs)) {
20380 + if (!user_mode(regs)) {
20381 unsigned int code_prologue = code_bytes * 43 / 64;
20382 unsigned int code_len = code_bytes;
20383 unsigned char c;
20384 u8 *ip;
20385 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20386
20387 pr_emerg("Stack:\n");
20388 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20389
20390 pr_emerg("Code:");
20391
20392 - ip = (u8 *)regs->ip - code_prologue;
20393 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20394 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20395 /* try starting at IP */
20396 - ip = (u8 *)regs->ip;
20397 + ip = (u8 *)regs->ip + cs_base;
20398 code_len = code_len - code_prologue + 1;
20399 }
20400 for (i = 0; i < code_len; i++, ip++) {
20401 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20402 pr_cont(" Bad EIP value.");
20403 break;
20404 }
20405 - if (ip == (u8 *)regs->ip)
20406 + if (ip == (u8 *)regs->ip + cs_base)
20407 pr_cont(" <%02x>", c);
20408 else
20409 pr_cont(" %02x", c);
20410 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20411 {
20412 unsigned short ud2;
20413
20414 + ip = ktla_ktva(ip);
20415 if (ip < PAGE_OFFSET)
20416 return 0;
20417 if (probe_kernel_address((unsigned short *)ip, ud2))
20418 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20419
20420 return ud2 == 0x0b0f;
20421 }
20422 +
20423 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20424 +void pax_check_alloca(unsigned long size)
20425 +{
20426 + unsigned long sp = (unsigned long)&sp, stack_left;
20427 +
20428 + /* all kernel stacks are of the same size */
20429 + stack_left = sp & (THREAD_SIZE - 1);
20430 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20431 +}
20432 +EXPORT_SYMBOL(pax_check_alloca);
20433 +#endif
20434 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20435 index addb207..99635fa 100644
20436 --- a/arch/x86/kernel/dumpstack_64.c
20437 +++ b/arch/x86/kernel/dumpstack_64.c
20438 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20439 unsigned long *irq_stack_end =
20440 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20441 unsigned used = 0;
20442 - struct thread_info *tinfo;
20443 int graph = 0;
20444 unsigned long dummy;
20445 + void *stack_start;
20446
20447 if (!task)
20448 task = current;
20449 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20450 * current stack address. If the stacks consist of nested
20451 * exceptions
20452 */
20453 - tinfo = task_thread_info(task);
20454 for (;;) {
20455 char *id;
20456 unsigned long *estack_end;
20457 +
20458 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20459 &used, &id);
20460
20461 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20462 if (ops->stack(data, id) < 0)
20463 break;
20464
20465 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20466 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20467 data, estack_end, &graph);
20468 ops->stack(data, "<EOE>");
20469 /*
20470 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20471 * second-to-last pointer (index -2 to end) in the
20472 * exception stack:
20473 */
20474 + if ((u16)estack_end[-1] != __KERNEL_DS)
20475 + goto out;
20476 stack = (unsigned long *) estack_end[-2];
20477 continue;
20478 }
20479 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20480 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20481 if (ops->stack(data, "IRQ") < 0)
20482 break;
20483 - bp = ops->walk_stack(tinfo, stack, bp,
20484 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20485 ops, data, irq_stack_end, &graph);
20486 /*
20487 * We link to the next stack (which would be
20488 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20489 /*
20490 * This handles the process stack:
20491 */
20492 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20493 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20494 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20495 +out:
20496 put_cpu();
20497 }
20498 EXPORT_SYMBOL(dump_trace);
20499 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20500
20501 return ud2 == 0x0b0f;
20502 }
20503 +
20504 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20505 +void pax_check_alloca(unsigned long size)
20506 +{
20507 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20508 + unsigned cpu, used;
20509 + char *id;
20510 +
20511 + /* check the process stack first */
20512 + stack_start = (unsigned long)task_stack_page(current);
20513 + stack_end = stack_start + THREAD_SIZE;
20514 + if (likely(stack_start <= sp && sp < stack_end)) {
20515 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20516 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20517 + return;
20518 + }
20519 +
20520 + cpu = get_cpu();
20521 +
20522 + /* check the irq stacks */
20523 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20524 + stack_start = stack_end - IRQ_STACK_SIZE;
20525 + if (stack_start <= sp && sp < stack_end) {
20526 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20527 + put_cpu();
20528 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20529 + return;
20530 + }
20531 +
20532 + /* check the exception stacks */
20533 + used = 0;
20534 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20535 + stack_start = stack_end - EXCEPTION_STKSZ;
20536 + if (stack_end && stack_start <= sp && sp < stack_end) {
20537 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20538 + put_cpu();
20539 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20540 + return;
20541 + }
20542 +
20543 + put_cpu();
20544 +
20545 + /* unknown stack */
20546 + BUG();
20547 +}
20548 +EXPORT_SYMBOL(pax_check_alloca);
20549 +#endif
20550 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20551 index d32abea..74daf4f 100644
20552 --- a/arch/x86/kernel/e820.c
20553 +++ b/arch/x86/kernel/e820.c
20554 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20555
20556 static void early_panic(char *msg)
20557 {
20558 - early_printk(msg);
20559 - panic(msg);
20560 + early_printk("%s", msg);
20561 + panic("%s", msg);
20562 }
20563
20564 static int userdef __initdata;
20565 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20566 index d15f575..d692043 100644
20567 --- a/arch/x86/kernel/early_printk.c
20568 +++ b/arch/x86/kernel/early_printk.c
20569 @@ -7,6 +7,7 @@
20570 #include <linux/pci_regs.h>
20571 #include <linux/pci_ids.h>
20572 #include <linux/errno.h>
20573 +#include <linux/sched.h>
20574 #include <asm/io.h>
20575 #include <asm/processor.h>
20576 #include <asm/fcntl.h>
20577 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20578 index 2cfbc3a..b756682 100644
20579 --- a/arch/x86/kernel/entry_32.S
20580 +++ b/arch/x86/kernel/entry_32.S
20581 @@ -177,13 +177,153 @@
20582 /*CFI_REL_OFFSET gs, PT_GS*/
20583 .endm
20584 .macro SET_KERNEL_GS reg
20585 +
20586 +#ifdef CONFIG_CC_STACKPROTECTOR
20587 movl $(__KERNEL_STACK_CANARY), \reg
20588 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20589 + movl $(__USER_DS), \reg
20590 +#else
20591 + xorl \reg, \reg
20592 +#endif
20593 +
20594 movl \reg, %gs
20595 .endm
20596
20597 #endif /* CONFIG_X86_32_LAZY_GS */
20598
20599 -.macro SAVE_ALL
20600 +.macro pax_enter_kernel
20601 +#ifdef CONFIG_PAX_KERNEXEC
20602 + call pax_enter_kernel
20603 +#endif
20604 +.endm
20605 +
20606 +.macro pax_exit_kernel
20607 +#ifdef CONFIG_PAX_KERNEXEC
20608 + call pax_exit_kernel
20609 +#endif
20610 +.endm
20611 +
20612 +#ifdef CONFIG_PAX_KERNEXEC
20613 +ENTRY(pax_enter_kernel)
20614 +#ifdef CONFIG_PARAVIRT
20615 + pushl %eax
20616 + pushl %ecx
20617 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20618 + mov %eax, %esi
20619 +#else
20620 + mov %cr0, %esi
20621 +#endif
20622 + bts $16, %esi
20623 + jnc 1f
20624 + mov %cs, %esi
20625 + cmp $__KERNEL_CS, %esi
20626 + jz 3f
20627 + ljmp $__KERNEL_CS, $3f
20628 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20629 +2:
20630 +#ifdef CONFIG_PARAVIRT
20631 + mov %esi, %eax
20632 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20633 +#else
20634 + mov %esi, %cr0
20635 +#endif
20636 +3:
20637 +#ifdef CONFIG_PARAVIRT
20638 + popl %ecx
20639 + popl %eax
20640 +#endif
20641 + ret
20642 +ENDPROC(pax_enter_kernel)
20643 +
20644 +ENTRY(pax_exit_kernel)
20645 +#ifdef CONFIG_PARAVIRT
20646 + pushl %eax
20647 + pushl %ecx
20648 +#endif
20649 + mov %cs, %esi
20650 + cmp $__KERNEXEC_KERNEL_CS, %esi
20651 + jnz 2f
20652 +#ifdef CONFIG_PARAVIRT
20653 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20654 + mov %eax, %esi
20655 +#else
20656 + mov %cr0, %esi
20657 +#endif
20658 + btr $16, %esi
20659 + ljmp $__KERNEL_CS, $1f
20660 +1:
20661 +#ifdef CONFIG_PARAVIRT
20662 + mov %esi, %eax
20663 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20664 +#else
20665 + mov %esi, %cr0
20666 +#endif
20667 +2:
20668 +#ifdef CONFIG_PARAVIRT
20669 + popl %ecx
20670 + popl %eax
20671 +#endif
20672 + ret
20673 +ENDPROC(pax_exit_kernel)
20674 +#endif
20675 +
20676 + .macro pax_erase_kstack
20677 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20678 + call pax_erase_kstack
20679 +#endif
20680 + .endm
20681 +
20682 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20683 +/*
20684 + * ebp: thread_info
20685 + */
20686 +ENTRY(pax_erase_kstack)
20687 + pushl %edi
20688 + pushl %ecx
20689 + pushl %eax
20690 +
20691 + mov TI_lowest_stack(%ebp), %edi
20692 + mov $-0xBEEF, %eax
20693 + std
20694 +
20695 +1: mov %edi, %ecx
20696 + and $THREAD_SIZE_asm - 1, %ecx
20697 + shr $2, %ecx
20698 + repne scasl
20699 + jecxz 2f
20700 +
20701 + cmp $2*16, %ecx
20702 + jc 2f
20703 +
20704 + mov $2*16, %ecx
20705 + repe scasl
20706 + jecxz 2f
20707 + jne 1b
20708 +
20709 +2: cld
20710 + mov %esp, %ecx
20711 + sub %edi, %ecx
20712 +
20713 + cmp $THREAD_SIZE_asm, %ecx
20714 + jb 3f
20715 + ud2
20716 +3:
20717 +
20718 + shr $2, %ecx
20719 + rep stosl
20720 +
20721 + mov TI_task_thread_sp0(%ebp), %edi
20722 + sub $128, %edi
20723 + mov %edi, TI_lowest_stack(%ebp)
20724 +
20725 + popl %eax
20726 + popl %ecx
20727 + popl %edi
20728 + ret
20729 +ENDPROC(pax_erase_kstack)
20730 +#endif
20731 +
20732 +.macro __SAVE_ALL _DS
20733 cld
20734 PUSH_GS
20735 pushl_cfi %fs
20736 @@ -206,7 +346,7 @@
20737 CFI_REL_OFFSET ecx, 0
20738 pushl_cfi %ebx
20739 CFI_REL_OFFSET ebx, 0
20740 - movl $(__USER_DS), %edx
20741 + movl $\_DS, %edx
20742 movl %edx, %ds
20743 movl %edx, %es
20744 movl $(__KERNEL_PERCPU), %edx
20745 @@ -214,6 +354,15 @@
20746 SET_KERNEL_GS %edx
20747 .endm
20748
20749 +.macro SAVE_ALL
20750 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20751 + __SAVE_ALL __KERNEL_DS
20752 + pax_enter_kernel
20753 +#else
20754 + __SAVE_ALL __USER_DS
20755 +#endif
20756 +.endm
20757 +
20758 .macro RESTORE_INT_REGS
20759 popl_cfi %ebx
20760 CFI_RESTORE ebx
20761 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20762 popfl_cfi
20763 jmp syscall_exit
20764 CFI_ENDPROC
20765 -END(ret_from_fork)
20766 +ENDPROC(ret_from_fork)
20767
20768 ENTRY(ret_from_kernel_thread)
20769 CFI_STARTPROC
20770 @@ -344,7 +493,15 @@ ret_from_intr:
20771 andl $SEGMENT_RPL_MASK, %eax
20772 #endif
20773 cmpl $USER_RPL, %eax
20774 +
20775 +#ifdef CONFIG_PAX_KERNEXEC
20776 + jae resume_userspace
20777 +
20778 + pax_exit_kernel
20779 + jmp resume_kernel
20780 +#else
20781 jb resume_kernel # not returning to v8086 or userspace
20782 +#endif
20783
20784 ENTRY(resume_userspace)
20785 LOCKDEP_SYS_EXIT
20786 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20787 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20788 # int/exception return?
20789 jne work_pending
20790 - jmp restore_all
20791 -END(ret_from_exception)
20792 + jmp restore_all_pax
20793 +ENDPROC(ret_from_exception)
20794
20795 #ifdef CONFIG_PREEMPT
20796 ENTRY(resume_kernel)
20797 @@ -372,7 +529,7 @@ need_resched:
20798 jz restore_all
20799 call preempt_schedule_irq
20800 jmp need_resched
20801 -END(resume_kernel)
20802 +ENDPROC(resume_kernel)
20803 #endif
20804 CFI_ENDPROC
20805 /*
20806 @@ -406,30 +563,45 @@ sysenter_past_esp:
20807 /*CFI_REL_OFFSET cs, 0*/
20808 /*
20809 * Push current_thread_info()->sysenter_return to the stack.
20810 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20811 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20812 */
20813 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20814 + pushl_cfi $0
20815 CFI_REL_OFFSET eip, 0
20816
20817 pushl_cfi %eax
20818 SAVE_ALL
20819 + GET_THREAD_INFO(%ebp)
20820 + movl TI_sysenter_return(%ebp),%ebp
20821 + movl %ebp,PT_EIP(%esp)
20822 ENABLE_INTERRUPTS(CLBR_NONE)
20823
20824 /*
20825 * Load the potential sixth argument from user stack.
20826 * Careful about security.
20827 */
20828 + movl PT_OLDESP(%esp),%ebp
20829 +
20830 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20831 + mov PT_OLDSS(%esp),%ds
20832 +1: movl %ds:(%ebp),%ebp
20833 + push %ss
20834 + pop %ds
20835 +#else
20836 cmpl $__PAGE_OFFSET-3,%ebp
20837 jae syscall_fault
20838 ASM_STAC
20839 1: movl (%ebp),%ebp
20840 ASM_CLAC
20841 +#endif
20842 +
20843 movl %ebp,PT_EBP(%esp)
20844 _ASM_EXTABLE(1b,syscall_fault)
20845
20846 GET_THREAD_INFO(%ebp)
20847
20848 +#ifdef CONFIG_PAX_RANDKSTACK
20849 + pax_erase_kstack
20850 +#endif
20851 +
20852 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20853 jnz sysenter_audit
20854 sysenter_do_call:
20855 @@ -444,12 +616,24 @@ sysenter_do_call:
20856 testl $_TIF_ALLWORK_MASK, %ecx
20857 jne sysexit_audit
20858 sysenter_exit:
20859 +
20860 +#ifdef CONFIG_PAX_RANDKSTACK
20861 + pushl_cfi %eax
20862 + movl %esp, %eax
20863 + call pax_randomize_kstack
20864 + popl_cfi %eax
20865 +#endif
20866 +
20867 + pax_erase_kstack
20868 +
20869 /* if something modifies registers it must also disable sysexit */
20870 movl PT_EIP(%esp), %edx
20871 movl PT_OLDESP(%esp), %ecx
20872 xorl %ebp,%ebp
20873 TRACE_IRQS_ON
20874 1: mov PT_FS(%esp), %fs
20875 +2: mov PT_DS(%esp), %ds
20876 +3: mov PT_ES(%esp), %es
20877 PTGS_TO_GS
20878 ENABLE_INTERRUPTS_SYSEXIT
20879
20880 @@ -466,6 +650,9 @@ sysenter_audit:
20881 movl %eax,%edx /* 2nd arg: syscall number */
20882 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20883 call __audit_syscall_entry
20884 +
20885 + pax_erase_kstack
20886 +
20887 pushl_cfi %ebx
20888 movl PT_EAX(%esp),%eax /* reload syscall number */
20889 jmp sysenter_do_call
20890 @@ -491,10 +678,16 @@ sysexit_audit:
20891
20892 CFI_ENDPROC
20893 .pushsection .fixup,"ax"
20894 -2: movl $0,PT_FS(%esp)
20895 +4: movl $0,PT_FS(%esp)
20896 + jmp 1b
20897 +5: movl $0,PT_DS(%esp)
20898 + jmp 1b
20899 +6: movl $0,PT_ES(%esp)
20900 jmp 1b
20901 .popsection
20902 - _ASM_EXTABLE(1b,2b)
20903 + _ASM_EXTABLE(1b,4b)
20904 + _ASM_EXTABLE(2b,5b)
20905 + _ASM_EXTABLE(3b,6b)
20906 PTGS_TO_GS_EX
20907 ENDPROC(ia32_sysenter_target)
20908
20909 @@ -509,6 +702,11 @@ ENTRY(system_call)
20910 pushl_cfi %eax # save orig_eax
20911 SAVE_ALL
20912 GET_THREAD_INFO(%ebp)
20913 +
20914 +#ifdef CONFIG_PAX_RANDKSTACK
20915 + pax_erase_kstack
20916 +#endif
20917 +
20918 # system call tracing in operation / emulation
20919 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20920 jnz syscall_trace_entry
20921 @@ -527,6 +725,15 @@ syscall_exit:
20922 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20923 jne syscall_exit_work
20924
20925 +restore_all_pax:
20926 +
20927 +#ifdef CONFIG_PAX_RANDKSTACK
20928 + movl %esp, %eax
20929 + call pax_randomize_kstack
20930 +#endif
20931 +
20932 + pax_erase_kstack
20933 +
20934 restore_all:
20935 TRACE_IRQS_IRET
20936 restore_all_notrace:
20937 @@ -583,14 +790,34 @@ ldt_ss:
20938 * compensating for the offset by changing to the ESPFIX segment with
20939 * a base address that matches for the difference.
20940 */
20941 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20942 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20943 mov %esp, %edx /* load kernel esp */
20944 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20945 mov %dx, %ax /* eax: new kernel esp */
20946 sub %eax, %edx /* offset (low word is 0) */
20947 +#ifdef CONFIG_SMP
20948 + movl PER_CPU_VAR(cpu_number), %ebx
20949 + shll $PAGE_SHIFT_asm, %ebx
20950 + addl $cpu_gdt_table, %ebx
20951 +#else
20952 + movl $cpu_gdt_table, %ebx
20953 +#endif
20954 shr $16, %edx
20955 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20956 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20957 +
20958 +#ifdef CONFIG_PAX_KERNEXEC
20959 + mov %cr0, %esi
20960 + btr $16, %esi
20961 + mov %esi, %cr0
20962 +#endif
20963 +
20964 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20965 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20966 +
20967 +#ifdef CONFIG_PAX_KERNEXEC
20968 + bts $16, %esi
20969 + mov %esi, %cr0
20970 +#endif
20971 +
20972 pushl_cfi $__ESPFIX_SS
20973 pushl_cfi %eax /* new kernel esp */
20974 /* Disable interrupts, but do not irqtrace this section: we
20975 @@ -619,20 +846,18 @@ work_resched:
20976 movl TI_flags(%ebp), %ecx
20977 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20978 # than syscall tracing?
20979 - jz restore_all
20980 + jz restore_all_pax
20981 testb $_TIF_NEED_RESCHED, %cl
20982 jnz work_resched
20983
20984 work_notifysig: # deal with pending signals and
20985 # notify-resume requests
20986 + movl %esp, %eax
20987 #ifdef CONFIG_VM86
20988 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20989 - movl %esp, %eax
20990 jne work_notifysig_v86 # returning to kernel-space or
20991 # vm86-space
20992 1:
20993 -#else
20994 - movl %esp, %eax
20995 #endif
20996 TRACE_IRQS_ON
20997 ENABLE_INTERRUPTS(CLBR_NONE)
20998 @@ -653,7 +878,7 @@ work_notifysig_v86:
20999 movl %eax, %esp
21000 jmp 1b
21001 #endif
21002 -END(work_pending)
21003 +ENDPROC(work_pending)
21004
21005 # perform syscall exit tracing
21006 ALIGN
21007 @@ -661,11 +886,14 @@ syscall_trace_entry:
21008 movl $-ENOSYS,PT_EAX(%esp)
21009 movl %esp, %eax
21010 call syscall_trace_enter
21011 +
21012 + pax_erase_kstack
21013 +
21014 /* What it returned is what we'll actually use. */
21015 cmpl $(NR_syscalls), %eax
21016 jnae syscall_call
21017 jmp syscall_exit
21018 -END(syscall_trace_entry)
21019 +ENDPROC(syscall_trace_entry)
21020
21021 # perform syscall exit tracing
21022 ALIGN
21023 @@ -678,21 +906,25 @@ syscall_exit_work:
21024 movl %esp, %eax
21025 call syscall_trace_leave
21026 jmp resume_userspace
21027 -END(syscall_exit_work)
21028 +ENDPROC(syscall_exit_work)
21029 CFI_ENDPROC
21030
21031 RING0_INT_FRAME # can't unwind into user space anyway
21032 syscall_fault:
21033 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21034 + push %ss
21035 + pop %ds
21036 +#endif
21037 ASM_CLAC
21038 GET_THREAD_INFO(%ebp)
21039 movl $-EFAULT,PT_EAX(%esp)
21040 jmp resume_userspace
21041 -END(syscall_fault)
21042 +ENDPROC(syscall_fault)
21043
21044 syscall_badsys:
21045 movl $-ENOSYS,PT_EAX(%esp)
21046 jmp resume_userspace
21047 -END(syscall_badsys)
21048 +ENDPROC(syscall_badsys)
21049 CFI_ENDPROC
21050 /*
21051 * End of kprobes section
21052 @@ -708,8 +940,15 @@ END(syscall_badsys)
21053 * normal stack and adjusts ESP with the matching offset.
21054 */
21055 /* fixup the stack */
21056 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21057 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21058 +#ifdef CONFIG_SMP
21059 + movl PER_CPU_VAR(cpu_number), %ebx
21060 + shll $PAGE_SHIFT_asm, %ebx
21061 + addl $cpu_gdt_table, %ebx
21062 +#else
21063 + movl $cpu_gdt_table, %ebx
21064 +#endif
21065 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21066 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21067 shl $16, %eax
21068 addl %esp, %eax /* the adjusted stack pointer */
21069 pushl_cfi $__KERNEL_DS
21070 @@ -762,7 +1001,7 @@ vector=vector+1
21071 .endr
21072 2: jmp common_interrupt
21073 .endr
21074 -END(irq_entries_start)
21075 +ENDPROC(irq_entries_start)
21076
21077 .previous
21078 END(interrupt)
21079 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21080 pushl_cfi $do_coprocessor_error
21081 jmp error_code
21082 CFI_ENDPROC
21083 -END(coprocessor_error)
21084 +ENDPROC(coprocessor_error)
21085
21086 ENTRY(simd_coprocessor_error)
21087 RING0_INT_FRAME
21088 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21089 .section .altinstructions,"a"
21090 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21091 .previous
21092 -.section .altinstr_replacement,"ax"
21093 +.section .altinstr_replacement,"a"
21094 663: pushl $do_simd_coprocessor_error
21095 664:
21096 .previous
21097 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21098 #endif
21099 jmp error_code
21100 CFI_ENDPROC
21101 -END(simd_coprocessor_error)
21102 +ENDPROC(simd_coprocessor_error)
21103
21104 ENTRY(device_not_available)
21105 RING0_INT_FRAME
21106 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21107 pushl_cfi $do_device_not_available
21108 jmp error_code
21109 CFI_ENDPROC
21110 -END(device_not_available)
21111 +ENDPROC(device_not_available)
21112
21113 #ifdef CONFIG_PARAVIRT
21114 ENTRY(native_iret)
21115 iret
21116 _ASM_EXTABLE(native_iret, iret_exc)
21117 -END(native_iret)
21118 +ENDPROC(native_iret)
21119
21120 ENTRY(native_irq_enable_sysexit)
21121 sti
21122 sysexit
21123 -END(native_irq_enable_sysexit)
21124 +ENDPROC(native_irq_enable_sysexit)
21125 #endif
21126
21127 ENTRY(overflow)
21128 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21129 pushl_cfi $do_overflow
21130 jmp error_code
21131 CFI_ENDPROC
21132 -END(overflow)
21133 +ENDPROC(overflow)
21134
21135 ENTRY(bounds)
21136 RING0_INT_FRAME
21137 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21138 pushl_cfi $do_bounds
21139 jmp error_code
21140 CFI_ENDPROC
21141 -END(bounds)
21142 +ENDPROC(bounds)
21143
21144 ENTRY(invalid_op)
21145 RING0_INT_FRAME
21146 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21147 pushl_cfi $do_invalid_op
21148 jmp error_code
21149 CFI_ENDPROC
21150 -END(invalid_op)
21151 +ENDPROC(invalid_op)
21152
21153 ENTRY(coprocessor_segment_overrun)
21154 RING0_INT_FRAME
21155 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21156 pushl_cfi $do_coprocessor_segment_overrun
21157 jmp error_code
21158 CFI_ENDPROC
21159 -END(coprocessor_segment_overrun)
21160 +ENDPROC(coprocessor_segment_overrun)
21161
21162 ENTRY(invalid_TSS)
21163 RING0_EC_FRAME
21164 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21165 pushl_cfi $do_invalid_TSS
21166 jmp error_code
21167 CFI_ENDPROC
21168 -END(invalid_TSS)
21169 +ENDPROC(invalid_TSS)
21170
21171 ENTRY(segment_not_present)
21172 RING0_EC_FRAME
21173 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21174 pushl_cfi $do_segment_not_present
21175 jmp error_code
21176 CFI_ENDPROC
21177 -END(segment_not_present)
21178 +ENDPROC(segment_not_present)
21179
21180 ENTRY(stack_segment)
21181 RING0_EC_FRAME
21182 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21183 pushl_cfi $do_stack_segment
21184 jmp error_code
21185 CFI_ENDPROC
21186 -END(stack_segment)
21187 +ENDPROC(stack_segment)
21188
21189 ENTRY(alignment_check)
21190 RING0_EC_FRAME
21191 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21192 pushl_cfi $do_alignment_check
21193 jmp error_code
21194 CFI_ENDPROC
21195 -END(alignment_check)
21196 +ENDPROC(alignment_check)
21197
21198 ENTRY(divide_error)
21199 RING0_INT_FRAME
21200 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21201 pushl_cfi $do_divide_error
21202 jmp error_code
21203 CFI_ENDPROC
21204 -END(divide_error)
21205 +ENDPROC(divide_error)
21206
21207 #ifdef CONFIG_X86_MCE
21208 ENTRY(machine_check)
21209 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21210 pushl_cfi machine_check_vector
21211 jmp error_code
21212 CFI_ENDPROC
21213 -END(machine_check)
21214 +ENDPROC(machine_check)
21215 #endif
21216
21217 ENTRY(spurious_interrupt_bug)
21218 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21219 pushl_cfi $do_spurious_interrupt_bug
21220 jmp error_code
21221 CFI_ENDPROC
21222 -END(spurious_interrupt_bug)
21223 +ENDPROC(spurious_interrupt_bug)
21224 /*
21225 * End of kprobes section
21226 */
21227 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21228
21229 ENTRY(mcount)
21230 ret
21231 -END(mcount)
21232 +ENDPROC(mcount)
21233
21234 ENTRY(ftrace_caller)
21235 cmpl $0, function_trace_stop
21236 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21237 .globl ftrace_stub
21238 ftrace_stub:
21239 ret
21240 -END(ftrace_caller)
21241 +ENDPROC(ftrace_caller)
21242
21243 ENTRY(ftrace_regs_caller)
21244 pushf /* push flags before compare (in cs location) */
21245 @@ -1207,7 +1446,7 @@ trace:
21246 popl %ecx
21247 popl %eax
21248 jmp ftrace_stub
21249 -END(mcount)
21250 +ENDPROC(mcount)
21251 #endif /* CONFIG_DYNAMIC_FTRACE */
21252 #endif /* CONFIG_FUNCTION_TRACER */
21253
21254 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21255 popl %ecx
21256 popl %eax
21257 ret
21258 -END(ftrace_graph_caller)
21259 +ENDPROC(ftrace_graph_caller)
21260
21261 .globl return_to_handler
21262 return_to_handler:
21263 @@ -1281,15 +1520,18 @@ error_code:
21264 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21265 REG_TO_PTGS %ecx
21266 SET_KERNEL_GS %ecx
21267 - movl $(__USER_DS), %ecx
21268 + movl $(__KERNEL_DS), %ecx
21269 movl %ecx, %ds
21270 movl %ecx, %es
21271 +
21272 + pax_enter_kernel
21273 +
21274 TRACE_IRQS_OFF
21275 movl %esp,%eax # pt_regs pointer
21276 call *%edi
21277 jmp ret_from_exception
21278 CFI_ENDPROC
21279 -END(page_fault)
21280 +ENDPROC(page_fault)
21281
21282 /*
21283 * Debug traps and NMI can happen at the one SYSENTER instruction
21284 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21285 call do_debug
21286 jmp ret_from_exception
21287 CFI_ENDPROC
21288 -END(debug)
21289 +ENDPROC(debug)
21290
21291 /*
21292 * NMI is doubly nasty. It can happen _while_ we're handling
21293 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21294 xorl %edx,%edx # zero error code
21295 movl %esp,%eax # pt_regs pointer
21296 call do_nmi
21297 +
21298 + pax_exit_kernel
21299 +
21300 jmp restore_all_notrace
21301 CFI_ENDPROC
21302
21303 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21304 FIXUP_ESPFIX_STACK # %eax == %esp
21305 xorl %edx,%edx # zero error code
21306 call do_nmi
21307 +
21308 + pax_exit_kernel
21309 +
21310 RESTORE_REGS
21311 lss 12+4(%esp), %esp # back to espfix stack
21312 CFI_ADJUST_CFA_OFFSET -24
21313 jmp irq_return
21314 CFI_ENDPROC
21315 -END(nmi)
21316 +ENDPROC(nmi)
21317
21318 ENTRY(int3)
21319 RING0_INT_FRAME
21320 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21321 call do_int3
21322 jmp ret_from_exception
21323 CFI_ENDPROC
21324 -END(int3)
21325 +ENDPROC(int3)
21326
21327 ENTRY(general_protection)
21328 RING0_EC_FRAME
21329 pushl_cfi $do_general_protection
21330 jmp error_code
21331 CFI_ENDPROC
21332 -END(general_protection)
21333 +ENDPROC(general_protection)
21334
21335 #ifdef CONFIG_KVM_GUEST
21336 ENTRY(async_page_fault)
21337 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21338 pushl_cfi $do_async_page_fault
21339 jmp error_code
21340 CFI_ENDPROC
21341 -END(async_page_fault)
21342 +ENDPROC(async_page_fault)
21343 #endif
21344
21345 /*
21346 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21347 index 1b69951..8430a6d 100644
21348 --- a/arch/x86/kernel/entry_64.S
21349 +++ b/arch/x86/kernel/entry_64.S
21350 @@ -59,6 +59,8 @@
21351 #include <asm/context_tracking.h>
21352 #include <asm/smap.h>
21353 #include <linux/err.h>
21354 +#include <asm/pgtable.h>
21355 +#include <asm/alternative-asm.h>
21356
21357 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21358 #include <linux/elf-em.h>
21359 @@ -80,8 +82,9 @@
21360 #ifdef CONFIG_DYNAMIC_FTRACE
21361
21362 ENTRY(function_hook)
21363 + pax_force_retaddr
21364 retq
21365 -END(function_hook)
21366 +ENDPROC(function_hook)
21367
21368 /* skip is set if stack has been adjusted */
21369 .macro ftrace_caller_setup skip=0
21370 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21371 #endif
21372
21373 GLOBAL(ftrace_stub)
21374 + pax_force_retaddr
21375 retq
21376 -END(ftrace_caller)
21377 +ENDPROC(ftrace_caller)
21378
21379 ENTRY(ftrace_regs_caller)
21380 /* Save the current flags before compare (in SS location)*/
21381 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21382 popfq
21383 jmp ftrace_stub
21384
21385 -END(ftrace_regs_caller)
21386 +ENDPROC(ftrace_regs_caller)
21387
21388
21389 #else /* ! CONFIG_DYNAMIC_FTRACE */
21390 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21391 #endif
21392
21393 GLOBAL(ftrace_stub)
21394 + pax_force_retaddr
21395 retq
21396
21397 trace:
21398 @@ -225,12 +230,13 @@ trace:
21399 #endif
21400 subq $MCOUNT_INSN_SIZE, %rdi
21401
21402 + pax_force_fptr ftrace_trace_function
21403 call *ftrace_trace_function
21404
21405 MCOUNT_RESTORE_FRAME
21406
21407 jmp ftrace_stub
21408 -END(function_hook)
21409 +ENDPROC(function_hook)
21410 #endif /* CONFIG_DYNAMIC_FTRACE */
21411 #endif /* CONFIG_FUNCTION_TRACER */
21412
21413 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21414
21415 MCOUNT_RESTORE_FRAME
21416
21417 + pax_force_retaddr
21418 retq
21419 -END(ftrace_graph_caller)
21420 +ENDPROC(ftrace_graph_caller)
21421
21422 GLOBAL(return_to_handler)
21423 subq $24, %rsp
21424 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21425 movq 8(%rsp), %rdx
21426 movq (%rsp), %rax
21427 addq $24, %rsp
21428 + pax_force_fptr %rdi
21429 jmp *%rdi
21430 +ENDPROC(return_to_handler)
21431 #endif
21432
21433
21434 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21435 ENDPROC(native_usergs_sysret64)
21436 #endif /* CONFIG_PARAVIRT */
21437
21438 + .macro ljmpq sel, off
21439 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21440 + .byte 0x48; ljmp *1234f(%rip)
21441 + .pushsection .rodata
21442 + .align 16
21443 + 1234: .quad \off; .word \sel
21444 + .popsection
21445 +#else
21446 + pushq $\sel
21447 + pushq $\off
21448 + lretq
21449 +#endif
21450 + .endm
21451 +
21452 + .macro pax_enter_kernel
21453 + pax_set_fptr_mask
21454 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21455 + call pax_enter_kernel
21456 +#endif
21457 + .endm
21458 +
21459 + .macro pax_exit_kernel
21460 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21461 + call pax_exit_kernel
21462 +#endif
21463 +
21464 + .endm
21465 +
21466 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21467 +ENTRY(pax_enter_kernel)
21468 + pushq %rdi
21469 +
21470 +#ifdef CONFIG_PARAVIRT
21471 + PV_SAVE_REGS(CLBR_RDI)
21472 +#endif
21473 +
21474 +#ifdef CONFIG_PAX_KERNEXEC
21475 + GET_CR0_INTO_RDI
21476 + bts $16,%rdi
21477 + jnc 3f
21478 + mov %cs,%edi
21479 + cmp $__KERNEL_CS,%edi
21480 + jnz 2f
21481 +1:
21482 +#endif
21483 +
21484 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21485 + 661: jmp 111f
21486 + .pushsection .altinstr_replacement, "a"
21487 + 662: ASM_NOP2
21488 + .popsection
21489 + .pushsection .altinstructions, "a"
21490 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21491 + .popsection
21492 + GET_CR3_INTO_RDI
21493 + cmp $0,%dil
21494 + jnz 112f
21495 + mov $__KERNEL_DS,%edi
21496 + mov %edi,%ss
21497 + jmp 111f
21498 +112: cmp $1,%dil
21499 + jz 113f
21500 + ud2
21501 +113: sub $4097,%rdi
21502 + bts $63,%rdi
21503 + SET_RDI_INTO_CR3
21504 + mov $__UDEREF_KERNEL_DS,%edi
21505 + mov %edi,%ss
21506 +111:
21507 +#endif
21508 +
21509 +#ifdef CONFIG_PARAVIRT
21510 + PV_RESTORE_REGS(CLBR_RDI)
21511 +#endif
21512 +
21513 + popq %rdi
21514 + pax_force_retaddr
21515 + retq
21516 +
21517 +#ifdef CONFIG_PAX_KERNEXEC
21518 +2: ljmpq __KERNEL_CS,1b
21519 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21520 +4: SET_RDI_INTO_CR0
21521 + jmp 1b
21522 +#endif
21523 +ENDPROC(pax_enter_kernel)
21524 +
21525 +ENTRY(pax_exit_kernel)
21526 + pushq %rdi
21527 +
21528 +#ifdef CONFIG_PARAVIRT
21529 + PV_SAVE_REGS(CLBR_RDI)
21530 +#endif
21531 +
21532 +#ifdef CONFIG_PAX_KERNEXEC
21533 + mov %cs,%rdi
21534 + cmp $__KERNEXEC_KERNEL_CS,%edi
21535 + jz 2f
21536 + GET_CR0_INTO_RDI
21537 + bts $16,%rdi
21538 + jnc 4f
21539 +1:
21540 +#endif
21541 +
21542 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21543 + 661: jmp 111f
21544 + .pushsection .altinstr_replacement, "a"
21545 + 662: ASM_NOP2
21546 + .popsection
21547 + .pushsection .altinstructions, "a"
21548 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21549 + .popsection
21550 + mov %ss,%edi
21551 + cmp $__UDEREF_KERNEL_DS,%edi
21552 + jnz 111f
21553 + GET_CR3_INTO_RDI
21554 + cmp $0,%dil
21555 + jz 112f
21556 + ud2
21557 +112: add $4097,%rdi
21558 + bts $63,%rdi
21559 + SET_RDI_INTO_CR3
21560 + mov $__KERNEL_DS,%edi
21561 + mov %edi,%ss
21562 +111:
21563 +#endif
21564 +
21565 +#ifdef CONFIG_PARAVIRT
21566 + PV_RESTORE_REGS(CLBR_RDI);
21567 +#endif
21568 +
21569 + popq %rdi
21570 + pax_force_retaddr
21571 + retq
21572 +
21573 +#ifdef CONFIG_PAX_KERNEXEC
21574 +2: GET_CR0_INTO_RDI
21575 + btr $16,%rdi
21576 + jnc 4f
21577 + ljmpq __KERNEL_CS,3f
21578 +3: SET_RDI_INTO_CR0
21579 + jmp 1b
21580 +4: ud2
21581 + jmp 4b
21582 +#endif
21583 +ENDPROC(pax_exit_kernel)
21584 +#endif
21585 +
21586 + .macro pax_enter_kernel_user
21587 + pax_set_fptr_mask
21588 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21589 + call pax_enter_kernel_user
21590 +#endif
21591 + .endm
21592 +
21593 + .macro pax_exit_kernel_user
21594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21595 + call pax_exit_kernel_user
21596 +#endif
21597 +#ifdef CONFIG_PAX_RANDKSTACK
21598 + pushq %rax
21599 + pushq %r11
21600 + call pax_randomize_kstack
21601 + popq %r11
21602 + popq %rax
21603 +#endif
21604 + .endm
21605 +
21606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21607 +ENTRY(pax_enter_kernel_user)
21608 + pushq %rdi
21609 + pushq %rbx
21610 +
21611 +#ifdef CONFIG_PARAVIRT
21612 + PV_SAVE_REGS(CLBR_RDI)
21613 +#endif
21614 +
21615 + 661: jmp 111f
21616 + .pushsection .altinstr_replacement, "a"
21617 + 662: ASM_NOP2
21618 + .popsection
21619 + .pushsection .altinstructions, "a"
21620 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21621 + .popsection
21622 + GET_CR3_INTO_RDI
21623 + cmp $1,%dil
21624 + jnz 4f
21625 + sub $4097,%rdi
21626 + bts $63,%rdi
21627 + SET_RDI_INTO_CR3
21628 + jmp 3f
21629 +111:
21630 +
21631 + GET_CR3_INTO_RDI
21632 + mov %rdi,%rbx
21633 + add $__START_KERNEL_map,%rbx
21634 + sub phys_base(%rip),%rbx
21635 +
21636 +#ifdef CONFIG_PARAVIRT
21637 + cmpl $0, pv_info+PARAVIRT_enabled
21638 + jz 1f
21639 + pushq %rdi
21640 + i = 0
21641 + .rept USER_PGD_PTRS
21642 + mov i*8(%rbx),%rsi
21643 + mov $0,%sil
21644 + lea i*8(%rbx),%rdi
21645 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21646 + i = i + 1
21647 + .endr
21648 + popq %rdi
21649 + jmp 2f
21650 +1:
21651 +#endif
21652 +
21653 + i = 0
21654 + .rept USER_PGD_PTRS
21655 + movb $0,i*8(%rbx)
21656 + i = i + 1
21657 + .endr
21658 +
21659 +2: SET_RDI_INTO_CR3
21660 +
21661 +#ifdef CONFIG_PAX_KERNEXEC
21662 + GET_CR0_INTO_RDI
21663 + bts $16,%rdi
21664 + SET_RDI_INTO_CR0
21665 +#endif
21666 +
21667 +3:
21668 +
21669 +#ifdef CONFIG_PARAVIRT
21670 + PV_RESTORE_REGS(CLBR_RDI)
21671 +#endif
21672 +
21673 + popq %rbx
21674 + popq %rdi
21675 + pax_force_retaddr
21676 + retq
21677 +4: ud2
21678 +ENDPROC(pax_enter_kernel_user)
21679 +
21680 +ENTRY(pax_exit_kernel_user)
21681 + pushq %rdi
21682 + pushq %rbx
21683 +
21684 +#ifdef CONFIG_PARAVIRT
21685 + PV_SAVE_REGS(CLBR_RDI)
21686 +#endif
21687 +
21688 + GET_CR3_INTO_RDI
21689 + 661: jmp 1f
21690 + .pushsection .altinstr_replacement, "a"
21691 + 662: ASM_NOP2
21692 + .popsection
21693 + .pushsection .altinstructions, "a"
21694 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21695 + .popsection
21696 + cmp $0,%dil
21697 + jnz 3f
21698 + add $4097,%rdi
21699 + bts $63,%rdi
21700 + SET_RDI_INTO_CR3
21701 + jmp 2f
21702 +1:
21703 +
21704 + mov %rdi,%rbx
21705 +
21706 +#ifdef CONFIG_PAX_KERNEXEC
21707 + GET_CR0_INTO_RDI
21708 + btr $16,%rdi
21709 + jnc 3f
21710 + SET_RDI_INTO_CR0
21711 +#endif
21712 +
21713 + add $__START_KERNEL_map,%rbx
21714 + sub phys_base(%rip),%rbx
21715 +
21716 +#ifdef CONFIG_PARAVIRT
21717 + cmpl $0, pv_info+PARAVIRT_enabled
21718 + jz 1f
21719 + i = 0
21720 + .rept USER_PGD_PTRS
21721 + mov i*8(%rbx),%rsi
21722 + mov $0x67,%sil
21723 + lea i*8(%rbx),%rdi
21724 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21725 + i = i + 1
21726 + .endr
21727 + jmp 2f
21728 +1:
21729 +#endif
21730 +
21731 + i = 0
21732 + .rept USER_PGD_PTRS
21733 + movb $0x67,i*8(%rbx)
21734 + i = i + 1
21735 + .endr
21736 +2:
21737 +
21738 +#ifdef CONFIG_PARAVIRT
21739 + PV_RESTORE_REGS(CLBR_RDI)
21740 +#endif
21741 +
21742 + popq %rbx
21743 + popq %rdi
21744 + pax_force_retaddr
21745 + retq
21746 +3: ud2
21747 +ENDPROC(pax_exit_kernel_user)
21748 +#endif
21749 +
21750 + .macro pax_enter_kernel_nmi
21751 + pax_set_fptr_mask
21752 +
21753 +#ifdef CONFIG_PAX_KERNEXEC
21754 + GET_CR0_INTO_RDI
21755 + bts $16,%rdi
21756 + jc 110f
21757 + SET_RDI_INTO_CR0
21758 + or $2,%ebx
21759 +110:
21760 +#endif
21761 +
21762 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21763 + 661: jmp 111f
21764 + .pushsection .altinstr_replacement, "a"
21765 + 662: ASM_NOP2
21766 + .popsection
21767 + .pushsection .altinstructions, "a"
21768 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21769 + .popsection
21770 + GET_CR3_INTO_RDI
21771 + cmp $0,%dil
21772 + jz 111f
21773 + sub $4097,%rdi
21774 + or $4,%ebx
21775 + bts $63,%rdi
21776 + SET_RDI_INTO_CR3
21777 + mov $__UDEREF_KERNEL_DS,%edi
21778 + mov %edi,%ss
21779 +111:
21780 +#endif
21781 + .endm
21782 +
21783 + .macro pax_exit_kernel_nmi
21784 +#ifdef CONFIG_PAX_KERNEXEC
21785 + btr $1,%ebx
21786 + jnc 110f
21787 + GET_CR0_INTO_RDI
21788 + btr $16,%rdi
21789 + SET_RDI_INTO_CR0
21790 +110:
21791 +#endif
21792 +
21793 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21794 + btr $2,%ebx
21795 + jnc 111f
21796 + GET_CR3_INTO_RDI
21797 + add $4097,%rdi
21798 + bts $63,%rdi
21799 + SET_RDI_INTO_CR3
21800 + mov $__KERNEL_DS,%edi
21801 + mov %edi,%ss
21802 +111:
21803 +#endif
21804 + .endm
21805 +
21806 + .macro pax_erase_kstack
21807 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21808 + call pax_erase_kstack
21809 +#endif
21810 + .endm
21811 +
21812 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21813 +ENTRY(pax_erase_kstack)
21814 + pushq %rdi
21815 + pushq %rcx
21816 + pushq %rax
21817 + pushq %r11
21818 +
21819 + GET_THREAD_INFO(%r11)
21820 + mov TI_lowest_stack(%r11), %rdi
21821 + mov $-0xBEEF, %rax
21822 + std
21823 +
21824 +1: mov %edi, %ecx
21825 + and $THREAD_SIZE_asm - 1, %ecx
21826 + shr $3, %ecx
21827 + repne scasq
21828 + jecxz 2f
21829 +
21830 + cmp $2*8, %ecx
21831 + jc 2f
21832 +
21833 + mov $2*8, %ecx
21834 + repe scasq
21835 + jecxz 2f
21836 + jne 1b
21837 +
21838 +2: cld
21839 + mov %esp, %ecx
21840 + sub %edi, %ecx
21841 +
21842 + cmp $THREAD_SIZE_asm, %rcx
21843 + jb 3f
21844 + ud2
21845 +3:
21846 +
21847 + shr $3, %ecx
21848 + rep stosq
21849 +
21850 + mov TI_task_thread_sp0(%r11), %rdi
21851 + sub $256, %rdi
21852 + mov %rdi, TI_lowest_stack(%r11)
21853 +
21854 + popq %r11
21855 + popq %rax
21856 + popq %rcx
21857 + popq %rdi
21858 + pax_force_retaddr
21859 + ret
21860 +ENDPROC(pax_erase_kstack)
21861 +#endif
21862
21863 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21864 #ifdef CONFIG_TRACE_IRQFLAGS
21865 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21866 .endm
21867
21868 .macro UNFAKE_STACK_FRAME
21869 - addq $8*6, %rsp
21870 - CFI_ADJUST_CFA_OFFSET -(6*8)
21871 + addq $8*6 + ARG_SKIP, %rsp
21872 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21873 .endm
21874
21875 /*
21876 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21877 movq %rsp, %rsi
21878
21879 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21880 - testl $3, CS-RBP(%rsi)
21881 + testb $3, CS-RBP(%rsi)
21882 je 1f
21883 SWAPGS
21884 /*
21885 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21886 movq_cfi r15, R15+16
21887 movq %r11, 8(%rsp) /* return address */
21888 FIXUP_TOP_OF_STACK %r11, 16
21889 + pax_force_retaddr
21890 ret
21891 CFI_ENDPROC
21892 -END(save_rest)
21893 +ENDPROC(save_rest)
21894
21895 /* save complete stack frame */
21896 .pushsection .kprobes.text, "ax"
21897 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21898 js 1f /* negative -> in kernel */
21899 SWAPGS
21900 xorl %ebx,%ebx
21901 -1: ret
21902 +1: pax_force_retaddr_bts
21903 + ret
21904 CFI_ENDPROC
21905 -END(save_paranoid)
21906 +ENDPROC(save_paranoid)
21907 .popsection
21908
21909 /*
21910 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21911
21912 RESTORE_REST
21913
21914 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21915 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21916 jz 1f
21917
21918 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21919 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21920 RESTORE_REST
21921 jmp int_ret_from_sys_call
21922 CFI_ENDPROC
21923 -END(ret_from_fork)
21924 +ENDPROC(ret_from_fork)
21925
21926 /*
21927 * System call entry. Up to 6 arguments in registers are supported.
21928 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21929 ENTRY(system_call)
21930 CFI_STARTPROC simple
21931 CFI_SIGNAL_FRAME
21932 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21933 + CFI_DEF_CFA rsp,0
21934 CFI_REGISTER rip,rcx
21935 /*CFI_REGISTER rflags,r11*/
21936 SWAPGS_UNSAFE_STACK
21937 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21938
21939 movq %rsp,PER_CPU_VAR(old_rsp)
21940 movq PER_CPU_VAR(kernel_stack),%rsp
21941 + SAVE_ARGS 8*6,0
21942 + pax_enter_kernel_user
21943 +
21944 +#ifdef CONFIG_PAX_RANDKSTACK
21945 + pax_erase_kstack
21946 +#endif
21947 +
21948 /*
21949 * No need to follow this irqs off/on section - it's straight
21950 * and short:
21951 */
21952 ENABLE_INTERRUPTS(CLBR_NONE)
21953 - SAVE_ARGS 8,0
21954 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21955 movq %rcx,RIP-ARGOFFSET(%rsp)
21956 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21957 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21958 + GET_THREAD_INFO(%rcx)
21959 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21960 jnz tracesys
21961 system_call_fastpath:
21962 #if __SYSCALL_MASK == ~0
21963 @@ -640,7 +1082,7 @@ system_call_fastpath:
21964 cmpl $__NR_syscall_max,%eax
21965 #endif
21966 ja badsys
21967 - movq %r10,%rcx
21968 + movq R10-ARGOFFSET(%rsp),%rcx
21969 call *sys_call_table(,%rax,8) # XXX: rip relative
21970 movq %rax,RAX-ARGOFFSET(%rsp)
21971 /*
21972 @@ -654,10 +1096,13 @@ sysret_check:
21973 LOCKDEP_SYS_EXIT
21974 DISABLE_INTERRUPTS(CLBR_NONE)
21975 TRACE_IRQS_OFF
21976 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21977 + GET_THREAD_INFO(%rcx)
21978 + movl TI_flags(%rcx),%edx
21979 andl %edi,%edx
21980 jnz sysret_careful
21981 CFI_REMEMBER_STATE
21982 + pax_exit_kernel_user
21983 + pax_erase_kstack
21984 /*
21985 * sysretq will re-enable interrupts:
21986 */
21987 @@ -709,14 +1154,18 @@ badsys:
21988 * jump back to the normal fast path.
21989 */
21990 auditsys:
21991 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21992 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21993 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21994 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21995 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21996 movq %rax,%rsi /* 2nd arg: syscall number */
21997 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21998 call __audit_syscall_entry
21999 +
22000 + pax_erase_kstack
22001 +
22002 LOAD_ARGS 0 /* reload call-clobbered registers */
22003 + pax_set_fptr_mask
22004 jmp system_call_fastpath
22005
22006 /*
22007 @@ -737,7 +1186,7 @@ sysret_audit:
22008 /* Do syscall tracing */
22009 tracesys:
22010 #ifdef CONFIG_AUDITSYSCALL
22011 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22012 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
22013 jz auditsys
22014 #endif
22015 SAVE_REST
22016 @@ -745,12 +1194,16 @@ tracesys:
22017 FIXUP_TOP_OF_STACK %rdi
22018 movq %rsp,%rdi
22019 call syscall_trace_enter
22020 +
22021 + pax_erase_kstack
22022 +
22023 /*
22024 * Reload arg registers from stack in case ptrace changed them.
22025 * We don't reload %rax because syscall_trace_enter() returned
22026 * the value it wants us to use in the table lookup.
22027 */
22028 LOAD_ARGS ARGOFFSET, 1
22029 + pax_set_fptr_mask
22030 RESTORE_REST
22031 #if __SYSCALL_MASK == ~0
22032 cmpq $__NR_syscall_max,%rax
22033 @@ -759,7 +1212,7 @@ tracesys:
22034 cmpl $__NR_syscall_max,%eax
22035 #endif
22036 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
22037 - movq %r10,%rcx /* fixup for C */
22038 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
22039 call *sys_call_table(,%rax,8)
22040 movq %rax,RAX-ARGOFFSET(%rsp)
22041 /* Use IRET because user could have changed frame */
22042 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
22043 andl %edi,%edx
22044 jnz int_careful
22045 andl $~TS_COMPAT,TI_status(%rcx)
22046 - jmp retint_swapgs
22047 + pax_exit_kernel_user
22048 + pax_erase_kstack
22049 + jmp retint_swapgs_pax
22050
22051 /* Either reschedule or signal or syscall exit tracking needed. */
22052 /* First do a reschedule test. */
22053 @@ -826,7 +1281,7 @@ int_restore_rest:
22054 TRACE_IRQS_OFF
22055 jmp int_with_check
22056 CFI_ENDPROC
22057 -END(system_call)
22058 +ENDPROC(system_call)
22059
22060 .macro FORK_LIKE func
22061 ENTRY(stub_\func)
22062 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22063 DEFAULT_FRAME 0 8 /* offset 8: return address */
22064 call sys_\func
22065 RESTORE_TOP_OF_STACK %r11, 8
22066 + pax_force_retaddr
22067 ret $REST_SKIP /* pop extended registers */
22068 CFI_ENDPROC
22069 -END(stub_\func)
22070 +ENDPROC(stub_\func)
22071 .endm
22072
22073 .macro FIXED_FRAME label,func
22074 @@ -851,9 +1307,10 @@ ENTRY(\label)
22075 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22076 call \func
22077 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22078 + pax_force_retaddr
22079 ret
22080 CFI_ENDPROC
22081 -END(\label)
22082 +ENDPROC(\label)
22083 .endm
22084
22085 FORK_LIKE clone
22086 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22087 movq_cfi_restore R12+8, r12
22088 movq_cfi_restore RBP+8, rbp
22089 movq_cfi_restore RBX+8, rbx
22090 + pax_force_retaddr
22091 ret $REST_SKIP /* pop extended registers */
22092 CFI_ENDPROC
22093 -END(ptregscall_common)
22094 +ENDPROC(ptregscall_common)
22095
22096 ENTRY(stub_execve)
22097 CFI_STARTPROC
22098 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22099 RESTORE_REST
22100 jmp int_ret_from_sys_call
22101 CFI_ENDPROC
22102 -END(stub_execve)
22103 +ENDPROC(stub_execve)
22104
22105 /*
22106 * sigreturn is special because it needs to restore all registers on return.
22107 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22108 RESTORE_REST
22109 jmp int_ret_from_sys_call
22110 CFI_ENDPROC
22111 -END(stub_rt_sigreturn)
22112 +ENDPROC(stub_rt_sigreturn)
22113
22114 #ifdef CONFIG_X86_X32_ABI
22115 ENTRY(stub_x32_rt_sigreturn)
22116 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22117 RESTORE_REST
22118 jmp int_ret_from_sys_call
22119 CFI_ENDPROC
22120 -END(stub_x32_rt_sigreturn)
22121 +ENDPROC(stub_x32_rt_sigreturn)
22122
22123 ENTRY(stub_x32_execve)
22124 CFI_STARTPROC
22125 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22126 RESTORE_REST
22127 jmp int_ret_from_sys_call
22128 CFI_ENDPROC
22129 -END(stub_x32_execve)
22130 +ENDPROC(stub_x32_execve)
22131
22132 #endif
22133
22134 @@ -967,7 +1425,7 @@ vector=vector+1
22135 2: jmp common_interrupt
22136 .endr
22137 CFI_ENDPROC
22138 -END(irq_entries_start)
22139 +ENDPROC(irq_entries_start)
22140
22141 .previous
22142 END(interrupt)
22143 @@ -987,6 +1445,16 @@ END(interrupt)
22144 subq $ORIG_RAX-RBP, %rsp
22145 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22146 SAVE_ARGS_IRQ
22147 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22148 + testb $3, CS(%rdi)
22149 + jnz 1f
22150 + pax_enter_kernel
22151 + jmp 2f
22152 +1: pax_enter_kernel_user
22153 +2:
22154 +#else
22155 + pax_enter_kernel
22156 +#endif
22157 call \func
22158 .endm
22159
22160 @@ -1019,7 +1487,7 @@ ret_from_intr:
22161
22162 exit_intr:
22163 GET_THREAD_INFO(%rcx)
22164 - testl $3,CS-ARGOFFSET(%rsp)
22165 + testb $3,CS-ARGOFFSET(%rsp)
22166 je retint_kernel
22167
22168 /* Interrupt came from user space */
22169 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22170 * The iretq could re-enable interrupts:
22171 */
22172 DISABLE_INTERRUPTS(CLBR_ANY)
22173 + pax_exit_kernel_user
22174 +retint_swapgs_pax:
22175 TRACE_IRQS_IRETQ
22176 SWAPGS
22177 jmp restore_args
22178
22179 retint_restore_args: /* return to kernel space */
22180 DISABLE_INTERRUPTS(CLBR_ANY)
22181 + pax_exit_kernel
22182 + pax_force_retaddr (RIP-ARGOFFSET)
22183 /*
22184 * The iretq could re-enable interrupts:
22185 */
22186 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22187 #endif
22188
22189 CFI_ENDPROC
22190 -END(common_interrupt)
22191 +ENDPROC(common_interrupt)
22192 /*
22193 * End of kprobes section
22194 */
22195 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22196 interrupt \do_sym
22197 jmp ret_from_intr
22198 CFI_ENDPROC
22199 -END(\sym)
22200 +ENDPROC(\sym)
22201 .endm
22202
22203 #ifdef CONFIG_TRACING
22204 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22205 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22206 call error_entry
22207 DEFAULT_FRAME 0
22208 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22209 + testb $3, CS(%rsp)
22210 + jnz 1f
22211 + pax_enter_kernel
22212 + jmp 2f
22213 +1: pax_enter_kernel_user
22214 +2:
22215 +#else
22216 + pax_enter_kernel
22217 +#endif
22218 movq %rsp,%rdi /* pt_regs pointer */
22219 xorl %esi,%esi /* no error code */
22220 call \do_sym
22221 jmp error_exit /* %ebx: no swapgs flag */
22222 CFI_ENDPROC
22223 -END(\sym)
22224 +ENDPROC(\sym)
22225 .endm
22226
22227 .macro paranoidzeroentry sym do_sym
22228 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22229 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22230 call save_paranoid
22231 TRACE_IRQS_OFF
22232 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22233 + testb $3, CS(%rsp)
22234 + jnz 1f
22235 + pax_enter_kernel
22236 + jmp 2f
22237 +1: pax_enter_kernel_user
22238 +2:
22239 +#else
22240 + pax_enter_kernel
22241 +#endif
22242 movq %rsp,%rdi /* pt_regs pointer */
22243 xorl %esi,%esi /* no error code */
22244 call \do_sym
22245 jmp paranoid_exit /* %ebx: no swapgs flag */
22246 CFI_ENDPROC
22247 -END(\sym)
22248 +ENDPROC(\sym)
22249 .endm
22250
22251 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22252 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22253 .macro paranoidzeroentry_ist sym do_sym ist
22254 ENTRY(\sym)
22255 INTR_FRAME
22256 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22257 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22258 call save_paranoid
22259 TRACE_IRQS_OFF_DEBUG
22260 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22261 + testb $3, CS(%rsp)
22262 + jnz 1f
22263 + pax_enter_kernel
22264 + jmp 2f
22265 +1: pax_enter_kernel_user
22266 +2:
22267 +#else
22268 + pax_enter_kernel
22269 +#endif
22270 movq %rsp,%rdi /* pt_regs pointer */
22271 xorl %esi,%esi /* no error code */
22272 +#ifdef CONFIG_SMP
22273 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22274 + lea init_tss(%r12), %r12
22275 +#else
22276 + lea init_tss(%rip), %r12
22277 +#endif
22278 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22279 call \do_sym
22280 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22281 jmp paranoid_exit /* %ebx: no swapgs flag */
22282 CFI_ENDPROC
22283 -END(\sym)
22284 +ENDPROC(\sym)
22285 .endm
22286
22287 .macro errorentry sym do_sym
22288 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22289 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22290 call error_entry
22291 DEFAULT_FRAME 0
22292 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22293 + testb $3, CS(%rsp)
22294 + jnz 1f
22295 + pax_enter_kernel
22296 + jmp 2f
22297 +1: pax_enter_kernel_user
22298 +2:
22299 +#else
22300 + pax_enter_kernel
22301 +#endif
22302 movq %rsp,%rdi /* pt_regs pointer */
22303 movq ORIG_RAX(%rsp),%rsi /* get error code */
22304 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22305 call \do_sym
22306 jmp error_exit /* %ebx: no swapgs flag */
22307 CFI_ENDPROC
22308 -END(\sym)
22309 +ENDPROC(\sym)
22310 .endm
22311
22312 /* error code is on the stack already */
22313 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22314 call save_paranoid
22315 DEFAULT_FRAME 0
22316 TRACE_IRQS_OFF
22317 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22318 + testb $3, CS(%rsp)
22319 + jnz 1f
22320 + pax_enter_kernel
22321 + jmp 2f
22322 +1: pax_enter_kernel_user
22323 +2:
22324 +#else
22325 + pax_enter_kernel
22326 +#endif
22327 movq %rsp,%rdi /* pt_regs pointer */
22328 movq ORIG_RAX(%rsp),%rsi /* get error code */
22329 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22330 call \do_sym
22331 jmp paranoid_exit /* %ebx: no swapgs flag */
22332 CFI_ENDPROC
22333 -END(\sym)
22334 +ENDPROC(\sym)
22335 .endm
22336
22337 zeroentry divide_error do_divide_error
22338 @@ -1342,9 +1870,10 @@ gs_change:
22339 2: mfence /* workaround */
22340 SWAPGS
22341 popfq_cfi
22342 + pax_force_retaddr
22343 ret
22344 CFI_ENDPROC
22345 -END(native_load_gs_index)
22346 +ENDPROC(native_load_gs_index)
22347
22348 _ASM_EXTABLE(gs_change,bad_gs)
22349 .section .fixup,"ax"
22350 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22351 CFI_DEF_CFA_REGISTER rsp
22352 CFI_ADJUST_CFA_OFFSET -8
22353 decl PER_CPU_VAR(irq_count)
22354 + pax_force_retaddr
22355 ret
22356 CFI_ENDPROC
22357 -END(call_softirq)
22358 +ENDPROC(call_softirq)
22359
22360 #ifdef CONFIG_XEN
22361 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22362 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22363 decl PER_CPU_VAR(irq_count)
22364 jmp error_exit
22365 CFI_ENDPROC
22366 -END(xen_do_hypervisor_callback)
22367 +ENDPROC(xen_do_hypervisor_callback)
22368
22369 /*
22370 * Hypervisor uses this for application faults while it executes.
22371 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22372 SAVE_ALL
22373 jmp error_exit
22374 CFI_ENDPROC
22375 -END(xen_failsafe_callback)
22376 +ENDPROC(xen_failsafe_callback)
22377
22378 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22379 xen_hvm_callback_vector xen_evtchn_do_upcall
22380 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22381 DEFAULT_FRAME
22382 DISABLE_INTERRUPTS(CLBR_NONE)
22383 TRACE_IRQS_OFF_DEBUG
22384 - testl %ebx,%ebx /* swapgs needed? */
22385 + testl $1,%ebx /* swapgs needed? */
22386 jnz paranoid_restore
22387 - testl $3,CS(%rsp)
22388 + testb $3,CS(%rsp)
22389 jnz paranoid_userspace
22390 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22391 + pax_exit_kernel
22392 + TRACE_IRQS_IRETQ 0
22393 + SWAPGS_UNSAFE_STACK
22394 + RESTORE_ALL 8
22395 + pax_force_retaddr_bts
22396 + jmp irq_return
22397 +#endif
22398 paranoid_swapgs:
22399 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22400 + pax_exit_kernel_user
22401 +#else
22402 + pax_exit_kernel
22403 +#endif
22404 TRACE_IRQS_IRETQ 0
22405 SWAPGS_UNSAFE_STACK
22406 RESTORE_ALL 8
22407 jmp irq_return
22408 paranoid_restore:
22409 + pax_exit_kernel
22410 TRACE_IRQS_IRETQ_DEBUG 0
22411 RESTORE_ALL 8
22412 + pax_force_retaddr_bts
22413 jmp irq_return
22414 paranoid_userspace:
22415 GET_THREAD_INFO(%rcx)
22416 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22417 TRACE_IRQS_OFF
22418 jmp paranoid_userspace
22419 CFI_ENDPROC
22420 -END(paranoid_exit)
22421 +ENDPROC(paranoid_exit)
22422
22423 /*
22424 * Exception entry point. This expects an error code/orig_rax on the stack.
22425 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22426 movq_cfi r14, R14+8
22427 movq_cfi r15, R15+8
22428 xorl %ebx,%ebx
22429 - testl $3,CS+8(%rsp)
22430 + testb $3,CS+8(%rsp)
22431 je error_kernelspace
22432 error_swapgs:
22433 SWAPGS
22434 error_sti:
22435 TRACE_IRQS_OFF
22436 + pax_force_retaddr_bts
22437 ret
22438
22439 /*
22440 @@ -1622,7 +2168,7 @@ bstep_iret:
22441 movq %rcx,RIP+8(%rsp)
22442 jmp error_swapgs
22443 CFI_ENDPROC
22444 -END(error_entry)
22445 +ENDPROC(error_entry)
22446
22447
22448 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22449 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22450 DISABLE_INTERRUPTS(CLBR_NONE)
22451 TRACE_IRQS_OFF
22452 GET_THREAD_INFO(%rcx)
22453 - testl %eax,%eax
22454 + testl $1,%eax
22455 jne retint_kernel
22456 LOCKDEP_SYS_EXIT_IRQ
22457 movl TI_flags(%rcx),%edx
22458 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22459 jnz retint_careful
22460 jmp retint_swapgs
22461 CFI_ENDPROC
22462 -END(error_exit)
22463 +ENDPROC(error_exit)
22464
22465 /*
22466 * Test if a given stack is an NMI stack or not.
22467 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22468 * If %cs was not the kernel segment, then the NMI triggered in user
22469 * space, which means it is definitely not nested.
22470 */
22471 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22472 + je 1f
22473 cmpl $__KERNEL_CS, 16(%rsp)
22474 jne first_nmi
22475 -
22476 +1:
22477 /*
22478 * Check the special variable on the stack to see if NMIs are
22479 * executing.
22480 @@ -1736,8 +2284,7 @@ nested_nmi:
22481
22482 1:
22483 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22484 - leaq -1*8(%rsp), %rdx
22485 - movq %rdx, %rsp
22486 + subq $8, %rsp
22487 CFI_ADJUST_CFA_OFFSET 1*8
22488 leaq -10*8(%rsp), %rdx
22489 pushq_cfi $__KERNEL_DS
22490 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22491 CFI_RESTORE rdx
22492
22493 /* No need to check faults here */
22494 +# pax_force_retaddr_bts
22495 INTERRUPT_RETURN
22496
22497 CFI_RESTORE_STATE
22498 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22499 */
22500 movq %cr2, %r12
22501
22502 + pax_enter_kernel_nmi
22503 +
22504 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22505 movq %rsp,%rdi
22506 movq $-1,%rsi
22507 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22508 movq %r12, %cr2
22509 1:
22510
22511 - testl %ebx,%ebx /* swapgs needed? */
22512 + testl $1,%ebx /* swapgs needed? */
22513 jnz nmi_restore
22514 nmi_swapgs:
22515 SWAPGS_UNSAFE_STACK
22516 nmi_restore:
22517 + pax_exit_kernel_nmi
22518 /* Pop the extra iret frame at once */
22519 RESTORE_ALL 6*8
22520 + testb $3, 8(%rsp)
22521 + jnz 1f
22522 + pax_force_retaddr_bts
22523 +1:
22524
22525 /* Clear the NMI executing stack variable */
22526 movq $0, 5*8(%rsp)
22527 jmp irq_return
22528 CFI_ENDPROC
22529 -END(nmi)
22530 +ENDPROC(nmi)
22531
22532 ENTRY(ignore_sysret)
22533 CFI_STARTPROC
22534 mov $-ENOSYS,%eax
22535 sysret
22536 CFI_ENDPROC
22537 -END(ignore_sysret)
22538 +ENDPROC(ignore_sysret)
22539
22540 /*
22541 * End of kprobes section
22542 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22543 index 42a392a..fbbd930 100644
22544 --- a/arch/x86/kernel/ftrace.c
22545 +++ b/arch/x86/kernel/ftrace.c
22546 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22547 {
22548 unsigned char replaced[MCOUNT_INSN_SIZE];
22549
22550 + ip = ktla_ktva(ip);
22551 +
22552 /*
22553 * Note: Due to modules and __init, code can
22554 * disappear and change, we need to protect against faulting
22555 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22556 unsigned char old[MCOUNT_INSN_SIZE], *new;
22557 int ret;
22558
22559 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22560 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22561 new = ftrace_call_replace(ip, (unsigned long)func);
22562
22563 /* See comment above by declaration of modifying_ftrace_code */
22564 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22565 /* Also update the regs callback function */
22566 if (!ret) {
22567 ip = (unsigned long)(&ftrace_regs_call);
22568 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22569 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22570 new = ftrace_call_replace(ip, (unsigned long)func);
22571 ret = ftrace_modify_code(ip, old, new);
22572 }
22573 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22574 * kernel identity mapping to modify code.
22575 */
22576 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22577 - ip = (unsigned long)__va(__pa_symbol(ip));
22578 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22579
22580 return probe_kernel_write((void *)ip, val, size);
22581 }
22582 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22583 unsigned char replaced[MCOUNT_INSN_SIZE];
22584 unsigned char brk = BREAKPOINT_INSTRUCTION;
22585
22586 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22587 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22588 return -EFAULT;
22589
22590 /* Make sure it is what we expect it to be */
22591 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22592 return ret;
22593
22594 fail_update:
22595 - probe_kernel_write((void *)ip, &old_code[0], 1);
22596 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22597 goto out;
22598 }
22599
22600 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22601 {
22602 unsigned char code[MCOUNT_INSN_SIZE];
22603
22604 + ip = ktla_ktva(ip);
22605 +
22606 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22607 return -EFAULT;
22608
22609 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22610 index 55b6761..a6456fc 100644
22611 --- a/arch/x86/kernel/head64.c
22612 +++ b/arch/x86/kernel/head64.c
22613 @@ -67,12 +67,12 @@ again:
22614 pgd = *pgd_p;
22615
22616 /*
22617 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22618 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22619 + * The use of __early_va rather than __va here is critical:
22620 + * __va would point us back into the dynamic
22621 * range and we might end up looping forever...
22622 */
22623 if (pgd)
22624 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22625 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22626 else {
22627 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22628 reset_early_page_tables();
22629 @@ -82,13 +82,13 @@ again:
22630 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22631 for (i = 0; i < PTRS_PER_PUD; i++)
22632 pud_p[i] = 0;
22633 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22634 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22635 }
22636 pud_p += pud_index(address);
22637 pud = *pud_p;
22638
22639 if (pud)
22640 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22641 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22642 else {
22643 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22644 reset_early_page_tables();
22645 @@ -98,7 +98,7 @@ again:
22646 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22647 for (i = 0; i < PTRS_PER_PMD; i++)
22648 pmd_p[i] = 0;
22649 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22650 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22651 }
22652 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22653 pmd_p[pmd_index(address)] = pmd;
22654 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22655 if (console_loglevel == 10)
22656 early_printk("Kernel alive\n");
22657
22658 - clear_page(init_level4_pgt);
22659 /* set init_level4_pgt kernel high mapping*/
22660 init_level4_pgt[511] = early_level4_pgt[511];
22661
22662 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22663 index 5dd87a8..d68b3f4 100644
22664 --- a/arch/x86/kernel/head_32.S
22665 +++ b/arch/x86/kernel/head_32.S
22666 @@ -26,6 +26,12 @@
22667 /* Physical address */
22668 #define pa(X) ((X) - __PAGE_OFFSET)
22669
22670 +#ifdef CONFIG_PAX_KERNEXEC
22671 +#define ta(X) (X)
22672 +#else
22673 +#define ta(X) ((X) - __PAGE_OFFSET)
22674 +#endif
22675 +
22676 /*
22677 * References to members of the new_cpu_data structure.
22678 */
22679 @@ -55,11 +61,7 @@
22680 * and small than max_low_pfn, otherwise will waste some page table entries
22681 */
22682
22683 -#if PTRS_PER_PMD > 1
22684 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22685 -#else
22686 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22687 -#endif
22688 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22689
22690 /* Number of possible pages in the lowmem region */
22691 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22692 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22693 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22694
22695 /*
22696 + * Real beginning of normal "text" segment
22697 + */
22698 +ENTRY(stext)
22699 +ENTRY(_stext)
22700 +
22701 +/*
22702 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22703 * %esi points to the real-mode code as a 32-bit pointer.
22704 * CS and DS must be 4 GB flat segments, but we don't depend on
22705 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22706 * can.
22707 */
22708 __HEAD
22709 +
22710 +#ifdef CONFIG_PAX_KERNEXEC
22711 + jmp startup_32
22712 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22713 +.fill PAGE_SIZE-5,1,0xcc
22714 +#endif
22715 +
22716 ENTRY(startup_32)
22717 movl pa(stack_start),%ecx
22718
22719 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22720 2:
22721 leal -__PAGE_OFFSET(%ecx),%esp
22722
22723 +#ifdef CONFIG_SMP
22724 + movl $pa(cpu_gdt_table),%edi
22725 + movl $__per_cpu_load,%eax
22726 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22727 + rorl $16,%eax
22728 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22729 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22730 + movl $__per_cpu_end - 1,%eax
22731 + subl $__per_cpu_start,%eax
22732 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22733 +#endif
22734 +
22735 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22736 + movl $NR_CPUS,%ecx
22737 + movl $pa(cpu_gdt_table),%edi
22738 +1:
22739 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22740 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22741 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22742 + addl $PAGE_SIZE_asm,%edi
22743 + loop 1b
22744 +#endif
22745 +
22746 +#ifdef CONFIG_PAX_KERNEXEC
22747 + movl $pa(boot_gdt),%edi
22748 + movl $__LOAD_PHYSICAL_ADDR,%eax
22749 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22750 + rorl $16,%eax
22751 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22752 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22753 + rorl $16,%eax
22754 +
22755 + ljmp $(__BOOT_CS),$1f
22756 +1:
22757 +
22758 + movl $NR_CPUS,%ecx
22759 + movl $pa(cpu_gdt_table),%edi
22760 + addl $__PAGE_OFFSET,%eax
22761 +1:
22762 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22763 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22764 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22765 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22766 + rorl $16,%eax
22767 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22768 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22769 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22770 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22771 + rorl $16,%eax
22772 + addl $PAGE_SIZE_asm,%edi
22773 + loop 1b
22774 +#endif
22775 +
22776 /*
22777 * Clear BSS first so that there are no surprises...
22778 */
22779 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22780 movl %eax, pa(max_pfn_mapped)
22781
22782 /* Do early initialization of the fixmap area */
22783 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22784 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22785 +#ifdef CONFIG_COMPAT_VDSO
22786 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22787 +#else
22788 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22789 +#endif
22790 #else /* Not PAE */
22791
22792 page_pde_offset = (__PAGE_OFFSET >> 20);
22793 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22794 movl %eax, pa(max_pfn_mapped)
22795
22796 /* Do early initialization of the fixmap area */
22797 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22798 - movl %eax,pa(initial_page_table+0xffc)
22799 +#ifdef CONFIG_COMPAT_VDSO
22800 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22801 +#else
22802 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22803 +#endif
22804 #endif
22805
22806 #ifdef CONFIG_PARAVIRT
22807 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22808 cmpl $num_subarch_entries, %eax
22809 jae bad_subarch
22810
22811 - movl pa(subarch_entries)(,%eax,4), %eax
22812 - subl $__PAGE_OFFSET, %eax
22813 - jmp *%eax
22814 + jmp *pa(subarch_entries)(,%eax,4)
22815
22816 bad_subarch:
22817 WEAK(lguest_entry)
22818 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22819 __INITDATA
22820
22821 subarch_entries:
22822 - .long default_entry /* normal x86/PC */
22823 - .long lguest_entry /* lguest hypervisor */
22824 - .long xen_entry /* Xen hypervisor */
22825 - .long default_entry /* Moorestown MID */
22826 + .long ta(default_entry) /* normal x86/PC */
22827 + .long ta(lguest_entry) /* lguest hypervisor */
22828 + .long ta(xen_entry) /* Xen hypervisor */
22829 + .long ta(default_entry) /* Moorestown MID */
22830 num_subarch_entries = (. - subarch_entries) / 4
22831 .previous
22832 #else
22833 @@ -354,6 +426,7 @@ default_entry:
22834 movl pa(mmu_cr4_features),%eax
22835 movl %eax,%cr4
22836
22837 +#ifdef CONFIG_X86_PAE
22838 testb $X86_CR4_PAE, %al # check if PAE is enabled
22839 jz enable_paging
22840
22841 @@ -382,6 +455,9 @@ default_entry:
22842 /* Make changes effective */
22843 wrmsr
22844
22845 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22846 +#endif
22847 +
22848 enable_paging:
22849
22850 /*
22851 @@ -449,14 +525,20 @@ is486:
22852 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22853 movl %eax,%ss # after changing gdt.
22854
22855 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22856 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22857 movl %eax,%ds
22858 movl %eax,%es
22859
22860 movl $(__KERNEL_PERCPU), %eax
22861 movl %eax,%fs # set this cpu's percpu
22862
22863 +#ifdef CONFIG_CC_STACKPROTECTOR
22864 movl $(__KERNEL_STACK_CANARY),%eax
22865 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22866 + movl $(__USER_DS),%eax
22867 +#else
22868 + xorl %eax,%eax
22869 +#endif
22870 movl %eax,%gs
22871
22872 xorl %eax,%eax # Clear LDT
22873 @@ -512,8 +594,11 @@ setup_once:
22874 * relocation. Manually set base address in stack canary
22875 * segment descriptor.
22876 */
22877 - movl $gdt_page,%eax
22878 + movl $cpu_gdt_table,%eax
22879 movl $stack_canary,%ecx
22880 +#ifdef CONFIG_SMP
22881 + addl $__per_cpu_load,%ecx
22882 +#endif
22883 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22884 shrl $16, %ecx
22885 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22886 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22887 /* This is global to keep gas from relaxing the jumps */
22888 ENTRY(early_idt_handler)
22889 cld
22890 - cmpl $2,%ss:early_recursion_flag
22891 + cmpl $1,%ss:early_recursion_flag
22892 je hlt_loop
22893 incl %ss:early_recursion_flag
22894
22895 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22896 pushl (20+6*4)(%esp) /* trapno */
22897 pushl $fault_msg
22898 call printk
22899 -#endif
22900 call dump_stack
22901 +#endif
22902 hlt_loop:
22903 hlt
22904 jmp hlt_loop
22905 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22906 /* This is the default interrupt "handler" :-) */
22907 ALIGN
22908 ignore_int:
22909 - cld
22910 #ifdef CONFIG_PRINTK
22911 + cmpl $2,%ss:early_recursion_flag
22912 + je hlt_loop
22913 + incl %ss:early_recursion_flag
22914 + cld
22915 pushl %eax
22916 pushl %ecx
22917 pushl %edx
22918 @@ -612,9 +700,6 @@ ignore_int:
22919 movl $(__KERNEL_DS),%eax
22920 movl %eax,%ds
22921 movl %eax,%es
22922 - cmpl $2,early_recursion_flag
22923 - je hlt_loop
22924 - incl early_recursion_flag
22925 pushl 16(%esp)
22926 pushl 24(%esp)
22927 pushl 32(%esp)
22928 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22929 /*
22930 * BSS section
22931 */
22932 -__PAGE_ALIGNED_BSS
22933 - .align PAGE_SIZE
22934 #ifdef CONFIG_X86_PAE
22935 +.section .initial_pg_pmd,"a",@progbits
22936 initial_pg_pmd:
22937 .fill 1024*KPMDS,4,0
22938 #else
22939 +.section .initial_page_table,"a",@progbits
22940 ENTRY(initial_page_table)
22941 .fill 1024,4,0
22942 #endif
22943 +.section .initial_pg_fixmap,"a",@progbits
22944 initial_pg_fixmap:
22945 .fill 1024,4,0
22946 +.section .empty_zero_page,"a",@progbits
22947 ENTRY(empty_zero_page)
22948 .fill 4096,1,0
22949 +.section .swapper_pg_dir,"a",@progbits
22950 ENTRY(swapper_pg_dir)
22951 +#ifdef CONFIG_X86_PAE
22952 + .fill 4,8,0
22953 +#else
22954 .fill 1024,4,0
22955 +#endif
22956
22957 /*
22958 * This starts the data section.
22959 */
22960 #ifdef CONFIG_X86_PAE
22961 -__PAGE_ALIGNED_DATA
22962 - /* Page-aligned for the benefit of paravirt? */
22963 - .align PAGE_SIZE
22964 +.section .initial_page_table,"a",@progbits
22965 ENTRY(initial_page_table)
22966 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22967 # if KPMDS == 3
22968 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22969 # error "Kernel PMDs should be 1, 2 or 3"
22970 # endif
22971 .align PAGE_SIZE /* needs to be page-sized too */
22972 +
22973 +#ifdef CONFIG_PAX_PER_CPU_PGD
22974 +ENTRY(cpu_pgd)
22975 + .rept 2*NR_CPUS
22976 + .fill 4,8,0
22977 + .endr
22978 +#endif
22979 +
22980 #endif
22981
22982 .data
22983 .balign 4
22984 ENTRY(stack_start)
22985 - .long init_thread_union+THREAD_SIZE
22986 + .long init_thread_union+THREAD_SIZE-8
22987
22988 __INITRODATA
22989 int_msg:
22990 @@ -722,7 +820,7 @@ fault_msg:
22991 * segment size, and 32-bit linear address value:
22992 */
22993
22994 - .data
22995 +.section .rodata,"a",@progbits
22996 .globl boot_gdt_descr
22997 .globl idt_descr
22998
22999 @@ -731,7 +829,7 @@ fault_msg:
23000 .word 0 # 32 bit align gdt_desc.address
23001 boot_gdt_descr:
23002 .word __BOOT_DS+7
23003 - .long boot_gdt - __PAGE_OFFSET
23004 + .long pa(boot_gdt)
23005
23006 .word 0 # 32-bit align idt_desc.address
23007 idt_descr:
23008 @@ -742,7 +840,7 @@ idt_descr:
23009 .word 0 # 32 bit align gdt_desc.address
23010 ENTRY(early_gdt_descr)
23011 .word GDT_ENTRIES*8-1
23012 - .long gdt_page /* Overwritten for secondary CPUs */
23013 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
23014
23015 /*
23016 * The boot_gdt must mirror the equivalent in setup.S and is
23017 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
23018 .align L1_CACHE_BYTES
23019 ENTRY(boot_gdt)
23020 .fill GDT_ENTRY_BOOT_CS,8,0
23021 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
23022 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
23023 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
23024 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
23025 +
23026 + .align PAGE_SIZE_asm
23027 +ENTRY(cpu_gdt_table)
23028 + .rept NR_CPUS
23029 + .quad 0x0000000000000000 /* NULL descriptor */
23030 + .quad 0x0000000000000000 /* 0x0b reserved */
23031 + .quad 0x0000000000000000 /* 0x13 reserved */
23032 + .quad 0x0000000000000000 /* 0x1b reserved */
23033 +
23034 +#ifdef CONFIG_PAX_KERNEXEC
23035 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
23036 +#else
23037 + .quad 0x0000000000000000 /* 0x20 unused */
23038 +#endif
23039 +
23040 + .quad 0x0000000000000000 /* 0x28 unused */
23041 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23042 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23043 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23044 + .quad 0x0000000000000000 /* 0x4b reserved */
23045 + .quad 0x0000000000000000 /* 0x53 reserved */
23046 + .quad 0x0000000000000000 /* 0x5b reserved */
23047 +
23048 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23049 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23050 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23051 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23052 +
23053 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23054 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23055 +
23056 + /*
23057 + * Segments used for calling PnP BIOS have byte granularity.
23058 + * The code segments and data segments have fixed 64k limits,
23059 + * the transfer segment sizes are set at run time.
23060 + */
23061 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23062 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23063 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23064 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23065 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23066 +
23067 + /*
23068 + * The APM segments have byte granularity and their bases
23069 + * are set at run time. All have 64k limits.
23070 + */
23071 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23072 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23073 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23074 +
23075 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23076 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23077 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23078 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23079 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23080 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23081 +
23082 + /* Be sure this is zeroed to avoid false validations in Xen */
23083 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23084 + .endr
23085 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23086 index e1aabdb..73dcad8 100644
23087 --- a/arch/x86/kernel/head_64.S
23088 +++ b/arch/x86/kernel/head_64.S
23089 @@ -20,6 +20,8 @@
23090 #include <asm/processor-flags.h>
23091 #include <asm/percpu.h>
23092 #include <asm/nops.h>
23093 +#include <asm/cpufeature.h>
23094 +#include <asm/alternative-asm.h>
23095
23096 #ifdef CONFIG_PARAVIRT
23097 #include <asm/asm-offsets.h>
23098 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23099 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23100 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23101 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23102 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23103 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23104 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23105 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23106 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23107 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23108
23109 .text
23110 __HEAD
23111 @@ -89,11 +97,23 @@ startup_64:
23112 * Fixup the physical addresses in the page table
23113 */
23114 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23115 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23116 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23117 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23118 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23119 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23120
23121 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23122 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23123 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23124 +#ifndef CONFIG_XEN
23125 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23126 +#endif
23127
23128 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23129 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23130 +
23131 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23132 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23133 +
23134 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23135
23136 /*
23137 * Set up the identity mapping for the switchover. These
23138 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23139 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23140 1:
23141
23142 - /* Enable PAE mode and PGE */
23143 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23144 + /* Enable PAE mode and PSE/PGE */
23145 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23146 movq %rcx, %cr4
23147
23148 /* Setup early boot stage 4 level pagetables. */
23149 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23150 movl $MSR_EFER, %ecx
23151 rdmsr
23152 btsl $_EFER_SCE, %eax /* Enable System Call */
23153 - btl $20,%edi /* No Execute supported? */
23154 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23155 jnc 1f
23156 btsl $_EFER_NX, %eax
23157 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23158 + leaq init_level4_pgt(%rip), %rdi
23159 +#ifndef CONFIG_EFI
23160 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23161 +#endif
23162 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23163 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23164 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23165 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23166 1: wrmsr /* Make changes effective */
23167
23168 /* Setup cr0 */
23169 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23170 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23171 * address given in m16:64.
23172 */
23173 + pax_set_fptr_mask
23174 movq initial_code(%rip),%rax
23175 pushq $0 # fake return address to stop unwinder
23176 pushq $__KERNEL_CS # set correct cs
23177 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23178 call dump_stack
23179 #ifdef CONFIG_KALLSYMS
23180 leaq early_idt_ripmsg(%rip),%rdi
23181 - movq 40(%rsp),%rsi # %rip again
23182 + movq 88(%rsp),%rsi # %rip again
23183 call __print_symbol
23184 #endif
23185 #endif /* EARLY_PRINTK */
23186 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23187 early_recursion_flag:
23188 .long 0
23189
23190 + .section .rodata,"a",@progbits
23191 #ifdef CONFIG_EARLY_PRINTK
23192 early_idt_msg:
23193 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23194 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23195 NEXT_PAGE(early_dynamic_pgts)
23196 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23197
23198 - .data
23199 + .section .rodata,"a",@progbits
23200
23201 -#ifndef CONFIG_XEN
23202 NEXT_PAGE(init_level4_pgt)
23203 - .fill 512,8,0
23204 -#else
23205 -NEXT_PAGE(init_level4_pgt)
23206 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23207 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23208 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23209 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23210 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23211 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23212 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23213 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23214 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23215 .org init_level4_pgt + L4_START_KERNEL*8, 0
23216 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23217 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23218
23219 +#ifdef CONFIG_PAX_PER_CPU_PGD
23220 +NEXT_PAGE(cpu_pgd)
23221 + .rept 2*NR_CPUS
23222 + .fill 512,8,0
23223 + .endr
23224 +#endif
23225 +
23226 NEXT_PAGE(level3_ident_pgt)
23227 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23228 +#ifdef CONFIG_XEN
23229 .fill 511, 8, 0
23230 +#else
23231 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23232 + .fill 510,8,0
23233 +#endif
23234 +
23235 +NEXT_PAGE(level3_vmalloc_start_pgt)
23236 + .fill 512,8,0
23237 +
23238 +NEXT_PAGE(level3_vmalloc_end_pgt)
23239 + .fill 512,8,0
23240 +
23241 +NEXT_PAGE(level3_vmemmap_pgt)
23242 + .fill L3_VMEMMAP_START,8,0
23243 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23244 +
23245 NEXT_PAGE(level2_ident_pgt)
23246 - /* Since I easily can, map the first 1G.
23247 + /* Since I easily can, map the first 2G.
23248 * Don't set NX because code runs from these pages.
23249 */
23250 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23251 -#endif
23252 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23253
23254 NEXT_PAGE(level3_kernel_pgt)
23255 .fill L3_START_KERNEL,8,0
23256 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23257 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23258 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23259
23260 +NEXT_PAGE(level2_vmemmap_pgt)
23261 + .fill 512,8,0
23262 +
23263 NEXT_PAGE(level2_kernel_pgt)
23264 /*
23265 * 512 MB kernel mapping. We spend a full page on this pagetable
23266 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23267 KERNEL_IMAGE_SIZE/PMD_SIZE)
23268
23269 NEXT_PAGE(level2_fixmap_pgt)
23270 - .fill 506,8,0
23271 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23272 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23273 - .fill 5,8,0
23274 + .fill 507,8,0
23275 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23276 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23277 + .fill 4,8,0
23278
23279 -NEXT_PAGE(level1_fixmap_pgt)
23280 +NEXT_PAGE(level1_vsyscall_pgt)
23281 .fill 512,8,0
23282
23283 #undef PMDS
23284
23285 - .data
23286 + .align PAGE_SIZE
23287 +ENTRY(cpu_gdt_table)
23288 + .rept NR_CPUS
23289 + .quad 0x0000000000000000 /* NULL descriptor */
23290 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23291 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23292 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23293 + .quad 0x00cffb000000ffff /* __USER32_CS */
23294 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23295 + .quad 0x00affb000000ffff /* __USER_CS */
23296 +
23297 +#ifdef CONFIG_PAX_KERNEXEC
23298 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23299 +#else
23300 + .quad 0x0 /* unused */
23301 +#endif
23302 +
23303 + .quad 0,0 /* TSS */
23304 + .quad 0,0 /* LDT */
23305 + .quad 0,0,0 /* three TLS descriptors */
23306 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23307 + /* asm/segment.h:GDT_ENTRIES must match this */
23308 +
23309 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23310 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23311 +#else
23312 + .quad 0x0 /* unused */
23313 +#endif
23314 +
23315 + /* zero the remaining page */
23316 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23317 + .endr
23318 +
23319 .align 16
23320 .globl early_gdt_descr
23321 early_gdt_descr:
23322 .word GDT_ENTRIES*8-1
23323 early_gdt_descr_base:
23324 - .quad INIT_PER_CPU_VAR(gdt_page)
23325 + .quad cpu_gdt_table
23326
23327 ENTRY(phys_base)
23328 /* This must match the first entry in level2_kernel_pgt */
23329 .quad 0x0000000000000000
23330
23331 #include "../../x86/xen/xen-head.S"
23332 -
23333 - __PAGE_ALIGNED_BSS
23334 +
23335 + .section .rodata,"a",@progbits
23336 NEXT_PAGE(empty_zero_page)
23337 .skip PAGE_SIZE
23338 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23339 index 0fa6912..b37438b 100644
23340 --- a/arch/x86/kernel/i386_ksyms_32.c
23341 +++ b/arch/x86/kernel/i386_ksyms_32.c
23342 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23343 EXPORT_SYMBOL(cmpxchg8b_emu);
23344 #endif
23345
23346 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23347 +
23348 /* Networking helper routines. */
23349 EXPORT_SYMBOL(csum_partial_copy_generic);
23350 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23351 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23352
23353 EXPORT_SYMBOL(__get_user_1);
23354 EXPORT_SYMBOL(__get_user_2);
23355 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23356
23357 EXPORT_SYMBOL(csum_partial);
23358 EXPORT_SYMBOL(empty_zero_page);
23359 +
23360 +#ifdef CONFIG_PAX_KERNEXEC
23361 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23362 +#endif
23363 +
23364 +#ifdef CONFIG_PAX_PER_CPU_PGD
23365 +EXPORT_SYMBOL(cpu_pgd);
23366 +#endif
23367 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23368 index 5d576ab..1403a03 100644
23369 --- a/arch/x86/kernel/i387.c
23370 +++ b/arch/x86/kernel/i387.c
23371 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23372 static inline bool interrupted_user_mode(void)
23373 {
23374 struct pt_regs *regs = get_irq_regs();
23375 - return regs && user_mode_vm(regs);
23376 + return regs && user_mode(regs);
23377 }
23378
23379 /*
23380 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23381 index 9a5c460..84868423 100644
23382 --- a/arch/x86/kernel/i8259.c
23383 +++ b/arch/x86/kernel/i8259.c
23384 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23385 static void make_8259A_irq(unsigned int irq)
23386 {
23387 disable_irq_nosync(irq);
23388 - io_apic_irqs &= ~(1<<irq);
23389 + io_apic_irqs &= ~(1UL<<irq);
23390 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23391 i8259A_chip.name);
23392 enable_irq(irq);
23393 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23394 "spurious 8259A interrupt: IRQ%d.\n", irq);
23395 spurious_irq_mask |= irqmask;
23396 }
23397 - atomic_inc(&irq_err_count);
23398 + atomic_inc_unchecked(&irq_err_count);
23399 /*
23400 * Theoretically we do not have to handle this IRQ,
23401 * but in Linux this does not cause problems and is
23402 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23403 /* (slave's support for AEOI in flat mode is to be investigated) */
23404 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23405
23406 + pax_open_kernel();
23407 if (auto_eoi)
23408 /*
23409 * In AEOI mode we just have to mask the interrupt
23410 * when acking.
23411 */
23412 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23413 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23414 else
23415 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23416 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23417 + pax_close_kernel();
23418
23419 udelay(100); /* wait for 8259A to initialize */
23420
23421 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23422 index a979b5b..1d6db75 100644
23423 --- a/arch/x86/kernel/io_delay.c
23424 +++ b/arch/x86/kernel/io_delay.c
23425 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23426 * Quirk table for systems that misbehave (lock up, etc.) if port
23427 * 0x80 is used:
23428 */
23429 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23430 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23431 {
23432 .callback = dmi_io_delay_0xed_port,
23433 .ident = "Compaq Presario V6000",
23434 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23435 index 4ddaf66..6292f4e 100644
23436 --- a/arch/x86/kernel/ioport.c
23437 +++ b/arch/x86/kernel/ioport.c
23438 @@ -6,6 +6,7 @@
23439 #include <linux/sched.h>
23440 #include <linux/kernel.h>
23441 #include <linux/capability.h>
23442 +#include <linux/security.h>
23443 #include <linux/errno.h>
23444 #include <linux/types.h>
23445 #include <linux/ioport.h>
23446 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23447
23448 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23449 return -EINVAL;
23450 +#ifdef CONFIG_GRKERNSEC_IO
23451 + if (turn_on && grsec_disable_privio) {
23452 + gr_handle_ioperm();
23453 + return -EPERM;
23454 + }
23455 +#endif
23456 if (turn_on && !capable(CAP_SYS_RAWIO))
23457 return -EPERM;
23458
23459 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23460 * because the ->io_bitmap_max value must match the bitmap
23461 * contents:
23462 */
23463 - tss = &per_cpu(init_tss, get_cpu());
23464 + tss = init_tss + get_cpu();
23465
23466 if (turn_on)
23467 bitmap_clear(t->io_bitmap_ptr, from, num);
23468 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23469 return -EINVAL;
23470 /* Trying to gain more privileges? */
23471 if (level > old) {
23472 +#ifdef CONFIG_GRKERNSEC_IO
23473 + if (grsec_disable_privio) {
23474 + gr_handle_iopl();
23475 + return -EPERM;
23476 + }
23477 +#endif
23478 if (!capable(CAP_SYS_RAWIO))
23479 return -EPERM;
23480 }
23481 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23482 index 3a8185c..3c042ee 100644
23483 --- a/arch/x86/kernel/irq.c
23484 +++ b/arch/x86/kernel/irq.c
23485 @@ -21,7 +21,7 @@
23486 #define CREATE_TRACE_POINTS
23487 #include <asm/trace/irq_vectors.h>
23488
23489 -atomic_t irq_err_count;
23490 +atomic_unchecked_t irq_err_count;
23491
23492 /* Function pointer for generic interrupt vector handling */
23493 void (*x86_platform_ipi_callback)(void) = NULL;
23494 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23495 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23496 seq_printf(p, " Machine check polls\n");
23497 #endif
23498 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23499 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23500 #if defined(CONFIG_X86_IO_APIC)
23501 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23502 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23503 #endif
23504 return 0;
23505 }
23506 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23507
23508 u64 arch_irq_stat(void)
23509 {
23510 - u64 sum = atomic_read(&irq_err_count);
23511 + u64 sum = atomic_read_unchecked(&irq_err_count);
23512 return sum;
23513 }
23514
23515 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23516 index 4186755..784efa0 100644
23517 --- a/arch/x86/kernel/irq_32.c
23518 +++ b/arch/x86/kernel/irq_32.c
23519 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23520 __asm__ __volatile__("andl %%esp,%0" :
23521 "=r" (sp) : "0" (THREAD_SIZE - 1));
23522
23523 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23524 + return sp < STACK_WARN;
23525 }
23526
23527 static void print_stack_overflow(void)
23528 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23529 * per-CPU IRQ handling contexts (thread information and stack)
23530 */
23531 union irq_ctx {
23532 - struct thread_info tinfo;
23533 - u32 stack[THREAD_SIZE/sizeof(u32)];
23534 + unsigned long previous_esp;
23535 + u32 stack[THREAD_SIZE/sizeof(u32)];
23536 } __attribute__((aligned(THREAD_SIZE)));
23537
23538 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23539 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23540 static inline int
23541 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23542 {
23543 - union irq_ctx *curctx, *irqctx;
23544 + union irq_ctx *irqctx;
23545 u32 *isp, arg1, arg2;
23546
23547 - curctx = (union irq_ctx *) current_thread_info();
23548 irqctx = __this_cpu_read(hardirq_ctx);
23549
23550 /*
23551 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23552 * handler) we can't do that and just have to keep using the
23553 * current stack (which is the irq stack already after all)
23554 */
23555 - if (unlikely(curctx == irqctx))
23556 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23557 return 0;
23558
23559 /* build the stack frame on the IRQ stack */
23560 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23561 - irqctx->tinfo.task = curctx->tinfo.task;
23562 - irqctx->tinfo.previous_esp = current_stack_pointer;
23563 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23564 + irqctx->previous_esp = current_stack_pointer;
23565
23566 - /* Copy the preempt_count so that the [soft]irq checks work. */
23567 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23568 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23569 + __set_fs(MAKE_MM_SEG(0));
23570 +#endif
23571
23572 if (unlikely(overflow))
23573 call_on_stack(print_stack_overflow, isp);
23574 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23575 : "0" (irq), "1" (desc), "2" (isp),
23576 "D" (desc->handle_irq)
23577 : "memory", "cc", "ecx");
23578 +
23579 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23580 + __set_fs(current_thread_info()->addr_limit);
23581 +#endif
23582 +
23583 return 1;
23584 }
23585
23586 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23587 */
23588 void irq_ctx_init(int cpu)
23589 {
23590 - union irq_ctx *irqctx;
23591 -
23592 if (per_cpu(hardirq_ctx, cpu))
23593 return;
23594
23595 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23596 - THREADINFO_GFP,
23597 - THREAD_SIZE_ORDER));
23598 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23599 - irqctx->tinfo.cpu = cpu;
23600 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23601 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23602 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23603 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23604
23605 - per_cpu(hardirq_ctx, cpu) = irqctx;
23606 -
23607 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23608 - THREADINFO_GFP,
23609 - THREAD_SIZE_ORDER));
23610 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23611 - irqctx->tinfo.cpu = cpu;
23612 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23613 -
23614 - per_cpu(softirq_ctx, cpu) = irqctx;
23615 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23616 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23617
23618 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23619 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23620 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23621 asmlinkage void do_softirq(void)
23622 {
23623 unsigned long flags;
23624 - struct thread_info *curctx;
23625 union irq_ctx *irqctx;
23626 u32 *isp;
23627
23628 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23629 local_irq_save(flags);
23630
23631 if (local_softirq_pending()) {
23632 - curctx = current_thread_info();
23633 irqctx = __this_cpu_read(softirq_ctx);
23634 - irqctx->tinfo.task = curctx->task;
23635 - irqctx->tinfo.previous_esp = current_stack_pointer;
23636 + irqctx->previous_esp = current_stack_pointer;
23637
23638 /* build the stack frame on the softirq stack */
23639 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23640 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23641 +
23642 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23643 + __set_fs(MAKE_MM_SEG(0));
23644 +#endif
23645
23646 call_on_stack(__do_softirq, isp);
23647 +
23648 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23649 + __set_fs(current_thread_info()->addr_limit);
23650 +#endif
23651 +
23652 /*
23653 * Shouldn't happen, we returned above if in_interrupt():
23654 */
23655 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23656 if (unlikely(!desc))
23657 return false;
23658
23659 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23660 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23661 if (unlikely(overflow))
23662 print_stack_overflow();
23663 desc->handle_irq(irq, desc);
23664 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23665 index d04d3ec..ea4b374 100644
23666 --- a/arch/x86/kernel/irq_64.c
23667 +++ b/arch/x86/kernel/irq_64.c
23668 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23669 u64 estack_top, estack_bottom;
23670 u64 curbase = (u64)task_stack_page(current);
23671
23672 - if (user_mode_vm(regs))
23673 + if (user_mode(regs))
23674 return;
23675
23676 if (regs->sp >= curbase + sizeof(struct thread_info) +
23677 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23678 index dc1404b..bbc43e7 100644
23679 --- a/arch/x86/kernel/kdebugfs.c
23680 +++ b/arch/x86/kernel/kdebugfs.c
23681 @@ -27,7 +27,7 @@ struct setup_data_node {
23682 u32 len;
23683 };
23684
23685 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23686 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23687 size_t count, loff_t *ppos)
23688 {
23689 struct setup_data_node *node = file->private_data;
23690 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23691 index 836f832..a8bda67 100644
23692 --- a/arch/x86/kernel/kgdb.c
23693 +++ b/arch/x86/kernel/kgdb.c
23694 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23695 #ifdef CONFIG_X86_32
23696 switch (regno) {
23697 case GDB_SS:
23698 - if (!user_mode_vm(regs))
23699 + if (!user_mode(regs))
23700 *(unsigned long *)mem = __KERNEL_DS;
23701 break;
23702 case GDB_SP:
23703 - if (!user_mode_vm(regs))
23704 + if (!user_mode(regs))
23705 *(unsigned long *)mem = kernel_stack_pointer(regs);
23706 break;
23707 case GDB_GS:
23708 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23709 bp->attr.bp_addr = breakinfo[breakno].addr;
23710 bp->attr.bp_len = breakinfo[breakno].len;
23711 bp->attr.bp_type = breakinfo[breakno].type;
23712 - info->address = breakinfo[breakno].addr;
23713 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23714 + info->address = ktla_ktva(breakinfo[breakno].addr);
23715 + else
23716 + info->address = breakinfo[breakno].addr;
23717 info->len = breakinfo[breakno].len;
23718 info->type = breakinfo[breakno].type;
23719 val = arch_install_hw_breakpoint(bp);
23720 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23721 case 'k':
23722 /* clear the trace bit */
23723 linux_regs->flags &= ~X86_EFLAGS_TF;
23724 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23725 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23726
23727 /* set the trace bit if we're stepping */
23728 if (remcomInBuffer[0] == 's') {
23729 linux_regs->flags |= X86_EFLAGS_TF;
23730 - atomic_set(&kgdb_cpu_doing_single_step,
23731 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23732 raw_smp_processor_id());
23733 }
23734
23735 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23736
23737 switch (cmd) {
23738 case DIE_DEBUG:
23739 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23740 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23741 if (user_mode(regs))
23742 return single_step_cont(regs, args);
23743 break;
23744 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23745 #endif /* CONFIG_DEBUG_RODATA */
23746
23747 bpt->type = BP_BREAKPOINT;
23748 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23749 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23750 BREAK_INSTR_SIZE);
23751 if (err)
23752 return err;
23753 - err = probe_kernel_write((char *)bpt->bpt_addr,
23754 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23755 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23756 #ifdef CONFIG_DEBUG_RODATA
23757 if (!err)
23758 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23759 return -EBUSY;
23760 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23761 BREAK_INSTR_SIZE);
23762 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23763 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23764 if (err)
23765 return err;
23766 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23767 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23768 if (mutex_is_locked(&text_mutex))
23769 goto knl_write;
23770 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23771 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23772 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23773 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23774 goto knl_write;
23775 return err;
23776 knl_write:
23777 #endif /* CONFIG_DEBUG_RODATA */
23778 - return probe_kernel_write((char *)bpt->bpt_addr,
23779 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23780 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23781 }
23782
23783 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23784 index 211bce4..6e2580a 100644
23785 --- a/arch/x86/kernel/kprobes/core.c
23786 +++ b/arch/x86/kernel/kprobes/core.c
23787 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23788 s32 raddr;
23789 } __packed *insn;
23790
23791 - insn = (struct __arch_relative_insn *)from;
23792 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23793 +
23794 + pax_open_kernel();
23795 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23796 insn->op = op;
23797 + pax_close_kernel();
23798 }
23799
23800 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23801 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23802 kprobe_opcode_t opcode;
23803 kprobe_opcode_t *orig_opcodes = opcodes;
23804
23805 - if (search_exception_tables((unsigned long)opcodes))
23806 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23807 return 0; /* Page fault may occur on this address. */
23808
23809 retry:
23810 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23811 * for the first byte, we can recover the original instruction
23812 * from it and kp->opcode.
23813 */
23814 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23815 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23816 buf[0] = kp->opcode;
23817 - return (unsigned long)buf;
23818 + return ktva_ktla((unsigned long)buf);
23819 }
23820
23821 /*
23822 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23823 /* Another subsystem puts a breakpoint, failed to recover */
23824 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23825 return 0;
23826 + pax_open_kernel();
23827 memcpy(dest, insn.kaddr, insn.length);
23828 + pax_close_kernel();
23829
23830 #ifdef CONFIG_X86_64
23831 if (insn_rip_relative(&insn)) {
23832 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23833 return 0;
23834 }
23835 disp = (u8 *) dest + insn_offset_displacement(&insn);
23836 + pax_open_kernel();
23837 *(s32 *) disp = (s32) newdisp;
23838 + pax_close_kernel();
23839 }
23840 #endif
23841 return insn.length;
23842 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23843 * nor set current_kprobe, because it doesn't use single
23844 * stepping.
23845 */
23846 - regs->ip = (unsigned long)p->ainsn.insn;
23847 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23848 preempt_enable_no_resched();
23849 return;
23850 }
23851 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23852 regs->flags &= ~X86_EFLAGS_IF;
23853 /* single step inline if the instruction is an int3 */
23854 if (p->opcode == BREAKPOINT_INSTRUCTION)
23855 - regs->ip = (unsigned long)p->addr;
23856 + regs->ip = ktla_ktva((unsigned long)p->addr);
23857 else
23858 - regs->ip = (unsigned long)p->ainsn.insn;
23859 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23860 }
23861
23862 /*
23863 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23864 setup_singlestep(p, regs, kcb, 0);
23865 return 1;
23866 }
23867 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23868 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23869 /*
23870 * The breakpoint instruction was removed right
23871 * after we hit it. Another cpu has removed
23872 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23873 " movq %rax, 152(%rsp)\n"
23874 RESTORE_REGS_STRING
23875 " popfq\n"
23876 +#ifdef KERNEXEC_PLUGIN
23877 + " btsq $63,(%rsp)\n"
23878 +#endif
23879 #else
23880 " pushf\n"
23881 SAVE_REGS_STRING
23882 @@ -779,7 +789,7 @@ static void __kprobes
23883 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23884 {
23885 unsigned long *tos = stack_addr(regs);
23886 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23887 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23888 unsigned long orig_ip = (unsigned long)p->addr;
23889 kprobe_opcode_t *insn = p->ainsn.insn;
23890
23891 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23892 struct die_args *args = data;
23893 int ret = NOTIFY_DONE;
23894
23895 - if (args->regs && user_mode_vm(args->regs))
23896 + if (args->regs && user_mode(args->regs))
23897 return ret;
23898
23899 switch (val) {
23900 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23901 index 76dc6f0..66bdfc3 100644
23902 --- a/arch/x86/kernel/kprobes/opt.c
23903 +++ b/arch/x86/kernel/kprobes/opt.c
23904 @@ -79,6 +79,7 @@ found:
23905 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23906 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23907 {
23908 + pax_open_kernel();
23909 #ifdef CONFIG_X86_64
23910 *addr++ = 0x48;
23911 *addr++ = 0xbf;
23912 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23913 *addr++ = 0xb8;
23914 #endif
23915 *(unsigned long *)addr = val;
23916 + pax_close_kernel();
23917 }
23918
23919 static void __used __kprobes kprobes_optinsn_template_holder(void)
23920 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23921 * Verify if the address gap is in 2GB range, because this uses
23922 * a relative jump.
23923 */
23924 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23925 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23926 if (abs(rel) > 0x7fffffff)
23927 return -ERANGE;
23928
23929 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23930 op->optinsn.size = ret;
23931
23932 /* Copy arch-dep-instance from template */
23933 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23934 + pax_open_kernel();
23935 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23936 + pax_close_kernel();
23937
23938 /* Set probe information */
23939 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23940
23941 /* Set probe function call */
23942 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23943 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23944
23945 /* Set returning jmp instruction at the tail of out-of-line buffer */
23946 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23947 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23948 (u8 *)op->kp.addr + op->optinsn.size);
23949
23950 flush_icache_range((unsigned long) buf,
23951 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23952 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23953
23954 /* Backup instructions which will be replaced by jump address */
23955 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23956 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23957 RELATIVE_ADDR_SIZE);
23958
23959 insn_buf[0] = RELATIVEJUMP_OPCODE;
23960 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23961 /* This kprobe is really able to run optimized path. */
23962 op = container_of(p, struct optimized_kprobe, kp);
23963 /* Detour through copied instructions */
23964 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23965 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23966 if (!reenter)
23967 reset_current_kprobe();
23968 preempt_enable_no_resched();
23969 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23970 index ebc9873..1b9724b 100644
23971 --- a/arch/x86/kernel/ldt.c
23972 +++ b/arch/x86/kernel/ldt.c
23973 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23974 if (reload) {
23975 #ifdef CONFIG_SMP
23976 preempt_disable();
23977 - load_LDT(pc);
23978 + load_LDT_nolock(pc);
23979 if (!cpumask_equal(mm_cpumask(current->mm),
23980 cpumask_of(smp_processor_id())))
23981 smp_call_function(flush_ldt, current->mm, 1);
23982 preempt_enable();
23983 #else
23984 - load_LDT(pc);
23985 + load_LDT_nolock(pc);
23986 #endif
23987 }
23988 if (oldsize) {
23989 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23990 return err;
23991
23992 for (i = 0; i < old->size; i++)
23993 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23994 + write_ldt_entry(new->ldt, i, old->ldt + i);
23995 return 0;
23996 }
23997
23998 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23999 retval = copy_ldt(&mm->context, &old_mm->context);
24000 mutex_unlock(&old_mm->context.lock);
24001 }
24002 +
24003 + if (tsk == current) {
24004 + mm->context.vdso = 0;
24005 +
24006 +#ifdef CONFIG_X86_32
24007 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24008 + mm->context.user_cs_base = 0UL;
24009 + mm->context.user_cs_limit = ~0UL;
24010 +
24011 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
24012 + cpus_clear(mm->context.cpu_user_cs_mask);
24013 +#endif
24014 +
24015 +#endif
24016 +#endif
24017 +
24018 + }
24019 +
24020 return retval;
24021 }
24022
24023 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
24024 }
24025 }
24026
24027 +#ifdef CONFIG_PAX_SEGMEXEC
24028 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
24029 + error = -EINVAL;
24030 + goto out_unlock;
24031 + }
24032 +#endif
24033 +
24034 fill_ldt(&ldt, &ldt_info);
24035 if (oldmode)
24036 ldt.avl = 0;
24037 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24038 index 5b19e4d..6476a76 100644
24039 --- a/arch/x86/kernel/machine_kexec_32.c
24040 +++ b/arch/x86/kernel/machine_kexec_32.c
24041 @@ -26,7 +26,7 @@
24042 #include <asm/cacheflush.h>
24043 #include <asm/debugreg.h>
24044
24045 -static void set_idt(void *newidt, __u16 limit)
24046 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24047 {
24048 struct desc_ptr curidt;
24049
24050 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24051 }
24052
24053
24054 -static void set_gdt(void *newgdt, __u16 limit)
24055 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24056 {
24057 struct desc_ptr curgdt;
24058
24059 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24060 }
24061
24062 control_page = page_address(image->control_code_page);
24063 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24064 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24065
24066 relocate_kernel_ptr = control_page;
24067 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24068 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24069 index 15c9876..0a43909 100644
24070 --- a/arch/x86/kernel/microcode_core.c
24071 +++ b/arch/x86/kernel/microcode_core.c
24072 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24073 return NOTIFY_OK;
24074 }
24075
24076 -static struct notifier_block __refdata mc_cpu_notifier = {
24077 +static struct notifier_block mc_cpu_notifier = {
24078 .notifier_call = mc_cpu_callback,
24079 };
24080
24081 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24082 index 5fb2ceb..3ae90bb 100644
24083 --- a/arch/x86/kernel/microcode_intel.c
24084 +++ b/arch/x86/kernel/microcode_intel.c
24085 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24086
24087 static int get_ucode_user(void *to, const void *from, size_t n)
24088 {
24089 - return copy_from_user(to, from, n);
24090 + return copy_from_user(to, (const void __force_user *)from, n);
24091 }
24092
24093 static enum ucode_state
24094 request_microcode_user(int cpu, const void __user *buf, size_t size)
24095 {
24096 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24097 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24098 }
24099
24100 static void microcode_fini_cpu(int cpu)
24101 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24102 index 216a4d7..228255a 100644
24103 --- a/arch/x86/kernel/module.c
24104 +++ b/arch/x86/kernel/module.c
24105 @@ -43,15 +43,60 @@ do { \
24106 } while (0)
24107 #endif
24108
24109 -void *module_alloc(unsigned long size)
24110 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24111 {
24112 - if (PAGE_ALIGN(size) > MODULES_LEN)
24113 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24114 return NULL;
24115 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24116 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24117 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24118 -1, __builtin_return_address(0));
24119 }
24120
24121 +void *module_alloc(unsigned long size)
24122 +{
24123 +
24124 +#ifdef CONFIG_PAX_KERNEXEC
24125 + return __module_alloc(size, PAGE_KERNEL);
24126 +#else
24127 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24128 +#endif
24129 +
24130 +}
24131 +
24132 +#ifdef CONFIG_PAX_KERNEXEC
24133 +#ifdef CONFIG_X86_32
24134 +void *module_alloc_exec(unsigned long size)
24135 +{
24136 + struct vm_struct *area;
24137 +
24138 + if (size == 0)
24139 + return NULL;
24140 +
24141 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24142 + return area ? area->addr : NULL;
24143 +}
24144 +EXPORT_SYMBOL(module_alloc_exec);
24145 +
24146 +void module_free_exec(struct module *mod, void *module_region)
24147 +{
24148 + vunmap(module_region);
24149 +}
24150 +EXPORT_SYMBOL(module_free_exec);
24151 +#else
24152 +void module_free_exec(struct module *mod, void *module_region)
24153 +{
24154 + module_free(mod, module_region);
24155 +}
24156 +EXPORT_SYMBOL(module_free_exec);
24157 +
24158 +void *module_alloc_exec(unsigned long size)
24159 +{
24160 + return __module_alloc(size, PAGE_KERNEL_RX);
24161 +}
24162 +EXPORT_SYMBOL(module_alloc_exec);
24163 +#endif
24164 +#endif
24165 +
24166 #ifdef CONFIG_X86_32
24167 int apply_relocate(Elf32_Shdr *sechdrs,
24168 const char *strtab,
24169 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24170 unsigned int i;
24171 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24172 Elf32_Sym *sym;
24173 - uint32_t *location;
24174 + uint32_t *plocation, location;
24175
24176 DEBUGP("Applying relocate section %u to %u\n",
24177 relsec, sechdrs[relsec].sh_info);
24178 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24179 /* This is where to make the change */
24180 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24181 - + rel[i].r_offset;
24182 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24183 + location = (uint32_t)plocation;
24184 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24185 + plocation = ktla_ktva((void *)plocation);
24186 /* This is the symbol it is referring to. Note that all
24187 undefined symbols have been resolved. */
24188 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24189 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24190 switch (ELF32_R_TYPE(rel[i].r_info)) {
24191 case R_386_32:
24192 /* We add the value into the location given */
24193 - *location += sym->st_value;
24194 + pax_open_kernel();
24195 + *plocation += sym->st_value;
24196 + pax_close_kernel();
24197 break;
24198 case R_386_PC32:
24199 /* Add the value, subtract its position */
24200 - *location += sym->st_value - (uint32_t)location;
24201 + pax_open_kernel();
24202 + *plocation += sym->st_value - location;
24203 + pax_close_kernel();
24204 break;
24205 default:
24206 pr_err("%s: Unknown relocation: %u\n",
24207 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24208 case R_X86_64_NONE:
24209 break;
24210 case R_X86_64_64:
24211 + pax_open_kernel();
24212 *(u64 *)loc = val;
24213 + pax_close_kernel();
24214 break;
24215 case R_X86_64_32:
24216 + pax_open_kernel();
24217 *(u32 *)loc = val;
24218 + pax_close_kernel();
24219 if (val != *(u32 *)loc)
24220 goto overflow;
24221 break;
24222 case R_X86_64_32S:
24223 + pax_open_kernel();
24224 *(s32 *)loc = val;
24225 + pax_close_kernel();
24226 if ((s64)val != *(s32 *)loc)
24227 goto overflow;
24228 break;
24229 case R_X86_64_PC32:
24230 val -= (u64)loc;
24231 + pax_open_kernel();
24232 *(u32 *)loc = val;
24233 + pax_close_kernel();
24234 +
24235 #if 0
24236 if ((s64)val != *(s32 *)loc)
24237 goto overflow;
24238 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24239 index 88458fa..349f7a4 100644
24240 --- a/arch/x86/kernel/msr.c
24241 +++ b/arch/x86/kernel/msr.c
24242 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24243 return notifier_from_errno(err);
24244 }
24245
24246 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24247 +static struct notifier_block msr_class_cpu_notifier = {
24248 .notifier_call = msr_class_cpu_callback,
24249 };
24250
24251 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24252 index ba77ebc..65da999 100644
24253 --- a/arch/x86/kernel/nmi.c
24254 +++ b/arch/x86/kernel/nmi.c
24255 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24256 return handled;
24257 }
24258
24259 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24260 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24261 {
24262 struct nmi_desc *desc = nmi_to_desc(type);
24263 unsigned long flags;
24264 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24265 * event confuses some handlers (kdump uses this flag)
24266 */
24267 if (action->flags & NMI_FLAG_FIRST)
24268 - list_add_rcu(&action->list, &desc->head);
24269 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24270 else
24271 - list_add_tail_rcu(&action->list, &desc->head);
24272 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24273
24274 spin_unlock_irqrestore(&desc->lock, flags);
24275 return 0;
24276 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24277 if (!strcmp(n->name, name)) {
24278 WARN(in_nmi(),
24279 "Trying to free NMI (%s) from NMI context!\n", n->name);
24280 - list_del_rcu(&n->list);
24281 + pax_list_del_rcu((struct list_head *)&n->list);
24282 break;
24283 }
24284 }
24285 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24286 dotraplinkage notrace __kprobes void
24287 do_nmi(struct pt_regs *regs, long error_code)
24288 {
24289 +
24290 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24291 + if (!user_mode(regs)) {
24292 + unsigned long cs = regs->cs & 0xFFFF;
24293 + unsigned long ip = ktva_ktla(regs->ip);
24294 +
24295 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24296 + regs->ip = ip;
24297 + }
24298 +#endif
24299 +
24300 nmi_nesting_preprocess(regs);
24301
24302 nmi_enter();
24303 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24304 index 6d9582e..f746287 100644
24305 --- a/arch/x86/kernel/nmi_selftest.c
24306 +++ b/arch/x86/kernel/nmi_selftest.c
24307 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24308 {
24309 /* trap all the unknown NMIs we may generate */
24310 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24311 - __initdata);
24312 + __initconst);
24313 }
24314
24315 static void __init cleanup_nmi_testsuite(void)
24316 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24317 unsigned long timeout;
24318
24319 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24320 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24321 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24322 nmi_fail = FAILURE;
24323 return;
24324 }
24325 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24326 index 676b8c7..870ba04 100644
24327 --- a/arch/x86/kernel/paravirt-spinlocks.c
24328 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24329 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24330 arch_spin_lock(lock);
24331 }
24332
24333 -struct pv_lock_ops pv_lock_ops = {
24334 +struct pv_lock_ops pv_lock_ops __read_only = {
24335 #ifdef CONFIG_SMP
24336 .spin_is_locked = __ticket_spin_is_locked,
24337 .spin_is_contended = __ticket_spin_is_contended,
24338 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24339 index cd6de64..27c6af0 100644
24340 --- a/arch/x86/kernel/paravirt.c
24341 +++ b/arch/x86/kernel/paravirt.c
24342 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24343 {
24344 return x;
24345 }
24346 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24347 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24348 +#endif
24349
24350 void __init default_banner(void)
24351 {
24352 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24353 if (opfunc == NULL)
24354 /* If there's no function, patch it with a ud2a (BUG) */
24355 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24356 - else if (opfunc == _paravirt_nop)
24357 + else if (opfunc == (void *)_paravirt_nop)
24358 /* If the operation is a nop, then nop the callsite */
24359 ret = paravirt_patch_nop();
24360
24361 /* identity functions just return their single argument */
24362 - else if (opfunc == _paravirt_ident_32)
24363 + else if (opfunc == (void *)_paravirt_ident_32)
24364 ret = paravirt_patch_ident_32(insnbuf, len);
24365 - else if (opfunc == _paravirt_ident_64)
24366 + else if (opfunc == (void *)_paravirt_ident_64)
24367 ret = paravirt_patch_ident_64(insnbuf, len);
24368 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24369 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24370 + ret = paravirt_patch_ident_64(insnbuf, len);
24371 +#endif
24372
24373 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24374 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24375 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24376 if (insn_len > len || start == NULL)
24377 insn_len = len;
24378 else
24379 - memcpy(insnbuf, start, insn_len);
24380 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24381
24382 return insn_len;
24383 }
24384 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24385 return this_cpu_read(paravirt_lazy_mode);
24386 }
24387
24388 -struct pv_info pv_info = {
24389 +struct pv_info pv_info __read_only = {
24390 .name = "bare hardware",
24391 .paravirt_enabled = 0,
24392 .kernel_rpl = 0,
24393 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24394 #endif
24395 };
24396
24397 -struct pv_init_ops pv_init_ops = {
24398 +struct pv_init_ops pv_init_ops __read_only = {
24399 .patch = native_patch,
24400 };
24401
24402 -struct pv_time_ops pv_time_ops = {
24403 +struct pv_time_ops pv_time_ops __read_only = {
24404 .sched_clock = native_sched_clock,
24405 .steal_clock = native_steal_clock,
24406 };
24407
24408 -struct pv_irq_ops pv_irq_ops = {
24409 +struct pv_irq_ops pv_irq_ops __read_only = {
24410 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24411 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24412 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24413 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24414 #endif
24415 };
24416
24417 -struct pv_cpu_ops pv_cpu_ops = {
24418 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24419 .cpuid = native_cpuid,
24420 .get_debugreg = native_get_debugreg,
24421 .set_debugreg = native_set_debugreg,
24422 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24423 .end_context_switch = paravirt_nop,
24424 };
24425
24426 -struct pv_apic_ops pv_apic_ops = {
24427 +struct pv_apic_ops pv_apic_ops __read_only= {
24428 #ifdef CONFIG_X86_LOCAL_APIC
24429 .startup_ipi_hook = paravirt_nop,
24430 #endif
24431 };
24432
24433 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24434 +#ifdef CONFIG_X86_32
24435 +#ifdef CONFIG_X86_PAE
24436 +/* 64-bit pagetable entries */
24437 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24438 +#else
24439 /* 32-bit pagetable entries */
24440 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24441 +#endif
24442 #else
24443 /* 64-bit pagetable entries */
24444 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24445 #endif
24446
24447 -struct pv_mmu_ops pv_mmu_ops = {
24448 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24449
24450 .read_cr2 = native_read_cr2,
24451 .write_cr2 = native_write_cr2,
24452 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24453 .make_pud = PTE_IDENT,
24454
24455 .set_pgd = native_set_pgd,
24456 + .set_pgd_batched = native_set_pgd_batched,
24457 #endif
24458 #endif /* PAGETABLE_LEVELS >= 3 */
24459
24460 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24461 },
24462
24463 .set_fixmap = native_set_fixmap,
24464 +
24465 +#ifdef CONFIG_PAX_KERNEXEC
24466 + .pax_open_kernel = native_pax_open_kernel,
24467 + .pax_close_kernel = native_pax_close_kernel,
24468 +#endif
24469 +
24470 };
24471
24472 EXPORT_SYMBOL_GPL(pv_time_ops);
24473 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24474 index 299d493..2ccb0ee 100644
24475 --- a/arch/x86/kernel/pci-calgary_64.c
24476 +++ b/arch/x86/kernel/pci-calgary_64.c
24477 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24478 tce_space = be64_to_cpu(readq(target));
24479 tce_space = tce_space & TAR_SW_BITS;
24480
24481 - tce_space = tce_space & (~specified_table_size);
24482 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24483 info->tce_space = (u64 *)__va(tce_space);
24484 }
24485 }
24486 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24487 index 35ccf75..7a15747 100644
24488 --- a/arch/x86/kernel/pci-iommu_table.c
24489 +++ b/arch/x86/kernel/pci-iommu_table.c
24490 @@ -2,7 +2,7 @@
24491 #include <asm/iommu_table.h>
24492 #include <linux/string.h>
24493 #include <linux/kallsyms.h>
24494 -
24495 +#include <linux/sched.h>
24496
24497 #define DEBUG 1
24498
24499 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24500 index 6c483ba..d10ce2f 100644
24501 --- a/arch/x86/kernel/pci-swiotlb.c
24502 +++ b/arch/x86/kernel/pci-swiotlb.c
24503 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24504 void *vaddr, dma_addr_t dma_addr,
24505 struct dma_attrs *attrs)
24506 {
24507 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24508 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24509 }
24510
24511 static struct dma_map_ops swiotlb_dma_ops = {
24512 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24513 index 83369e5..52b93f0 100644
24514 --- a/arch/x86/kernel/process.c
24515 +++ b/arch/x86/kernel/process.c
24516 @@ -36,7 +36,8 @@
24517 * section. Since TSS's are completely CPU-local, we want them
24518 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24519 */
24520 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24521 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24522 +EXPORT_SYMBOL(init_tss);
24523
24524 #ifdef CONFIG_X86_64
24525 static DEFINE_PER_CPU(unsigned char, is_idle);
24526 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24527 task_xstate_cachep =
24528 kmem_cache_create("task_xstate", xstate_size,
24529 __alignof__(union thread_xstate),
24530 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24531 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24532 }
24533
24534 /*
24535 @@ -105,7 +106,7 @@ void exit_thread(void)
24536 unsigned long *bp = t->io_bitmap_ptr;
24537
24538 if (bp) {
24539 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24540 + struct tss_struct *tss = init_tss + get_cpu();
24541
24542 t->io_bitmap_ptr = NULL;
24543 clear_thread_flag(TIF_IO_BITMAP);
24544 @@ -125,6 +126,9 @@ void flush_thread(void)
24545 {
24546 struct task_struct *tsk = current;
24547
24548 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24549 + loadsegment(gs, 0);
24550 +#endif
24551 flush_ptrace_hw_breakpoint(tsk);
24552 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24553 drop_init_fpu(tsk);
24554 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24555 void exit_idle(void)
24556 {
24557 /* idle loop has pid 0 */
24558 - if (current->pid)
24559 + if (task_pid_nr(current))
24560 return;
24561 __exit_idle();
24562 }
24563 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24564 return ret;
24565 }
24566 #endif
24567 -void stop_this_cpu(void *dummy)
24568 +__noreturn void stop_this_cpu(void *dummy)
24569 {
24570 local_irq_disable();
24571 /*
24572 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24573 }
24574 early_param("idle", idle_setup);
24575
24576 -unsigned long arch_align_stack(unsigned long sp)
24577 +#ifdef CONFIG_PAX_RANDKSTACK
24578 +void pax_randomize_kstack(struct pt_regs *regs)
24579 {
24580 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24581 - sp -= get_random_int() % 8192;
24582 - return sp & ~0xf;
24583 -}
24584 + struct thread_struct *thread = &current->thread;
24585 + unsigned long time;
24586
24587 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24588 -{
24589 - unsigned long range_end = mm->brk + 0x02000000;
24590 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24591 -}
24592 + if (!randomize_va_space)
24593 + return;
24594 +
24595 + if (v8086_mode(regs))
24596 + return;
24597
24598 + rdtscl(time);
24599 +
24600 + /* P4 seems to return a 0 LSB, ignore it */
24601 +#ifdef CONFIG_MPENTIUM4
24602 + time &= 0x3EUL;
24603 + time <<= 2;
24604 +#elif defined(CONFIG_X86_64)
24605 + time &= 0xFUL;
24606 + time <<= 4;
24607 +#else
24608 + time &= 0x1FUL;
24609 + time <<= 3;
24610 +#endif
24611 +
24612 + thread->sp0 ^= time;
24613 + load_sp0(init_tss + smp_processor_id(), thread);
24614 +
24615 +#ifdef CONFIG_X86_64
24616 + this_cpu_write(kernel_stack, thread->sp0);
24617 +#endif
24618 +}
24619 +#endif
24620 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24621 index f8adefc..4bce3d6 100644
24622 --- a/arch/x86/kernel/process_32.c
24623 +++ b/arch/x86/kernel/process_32.c
24624 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24625 unsigned long thread_saved_pc(struct task_struct *tsk)
24626 {
24627 return ((unsigned long *)tsk->thread.sp)[3];
24628 +//XXX return tsk->thread.eip;
24629 }
24630
24631 void __show_regs(struct pt_regs *regs, int all)
24632 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24633 unsigned long sp;
24634 unsigned short ss, gs;
24635
24636 - if (user_mode_vm(regs)) {
24637 + if (user_mode(regs)) {
24638 sp = regs->sp;
24639 ss = regs->ss & 0xffff;
24640 - gs = get_user_gs(regs);
24641 } else {
24642 sp = kernel_stack_pointer(regs);
24643 savesegment(ss, ss);
24644 - savesegment(gs, gs);
24645 }
24646 + gs = get_user_gs(regs);
24647
24648 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24649 (u16)regs->cs, regs->ip, regs->flags,
24650 - smp_processor_id());
24651 + raw_smp_processor_id());
24652 print_symbol("EIP is at %s\n", regs->ip);
24653
24654 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24655 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24656 int copy_thread(unsigned long clone_flags, unsigned long sp,
24657 unsigned long arg, struct task_struct *p)
24658 {
24659 - struct pt_regs *childregs = task_pt_regs(p);
24660 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24661 struct task_struct *tsk;
24662 int err;
24663
24664 p->thread.sp = (unsigned long) childregs;
24665 p->thread.sp0 = (unsigned long) (childregs+1);
24666 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24667
24668 if (unlikely(p->flags & PF_KTHREAD)) {
24669 /* kernel thread */
24670 memset(childregs, 0, sizeof(struct pt_regs));
24671 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24672 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24673 - childregs->ds = __USER_DS;
24674 - childregs->es = __USER_DS;
24675 + savesegment(gs, childregs->gs);
24676 + childregs->ds = __KERNEL_DS;
24677 + childregs->es = __KERNEL_DS;
24678 childregs->fs = __KERNEL_PERCPU;
24679 childregs->bx = sp; /* function */
24680 childregs->bp = arg;
24681 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24682 struct thread_struct *prev = &prev_p->thread,
24683 *next = &next_p->thread;
24684 int cpu = smp_processor_id();
24685 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24686 + struct tss_struct *tss = init_tss + cpu;
24687 fpu_switch_t fpu;
24688
24689 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24690 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24691 */
24692 lazy_save_gs(prev->gs);
24693
24694 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24695 + __set_fs(task_thread_info(next_p)->addr_limit);
24696 +#endif
24697 +
24698 /*
24699 * Load the per-thread Thread-Local Storage descriptor.
24700 */
24701 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24702 */
24703 arch_end_context_switch(next_p);
24704
24705 + this_cpu_write(current_task, next_p);
24706 + this_cpu_write(current_tinfo, &next_p->tinfo);
24707 +
24708 /*
24709 * Restore %gs if needed (which is common)
24710 */
24711 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24712
24713 switch_fpu_finish(next_p, fpu);
24714
24715 - this_cpu_write(current_task, next_p);
24716 -
24717 return prev_p;
24718 }
24719
24720 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24721 } while (count++ < 16);
24722 return 0;
24723 }
24724 -
24725 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24726 index 05646ba..0c2906d 100644
24727 --- a/arch/x86/kernel/process_64.c
24728 +++ b/arch/x86/kernel/process_64.c
24729 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24730 struct pt_regs *childregs;
24731 struct task_struct *me = current;
24732
24733 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24734 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24735 childregs = task_pt_regs(p);
24736 p->thread.sp = (unsigned long) childregs;
24737 p->thread.usersp = me->thread.usersp;
24738 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24739 set_tsk_thread_flag(p, TIF_FORK);
24740 p->fpu_counter = 0;
24741 p->thread.io_bitmap_ptr = NULL;
24742 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24743 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24744 savesegment(es, p->thread.es);
24745 savesegment(ds, p->thread.ds);
24746 + savesegment(ss, p->thread.ss);
24747 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24748 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24749
24750 if (unlikely(p->flags & PF_KTHREAD)) {
24751 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24752 struct thread_struct *prev = &prev_p->thread;
24753 struct thread_struct *next = &next_p->thread;
24754 int cpu = smp_processor_id();
24755 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24756 + struct tss_struct *tss = init_tss + cpu;
24757 unsigned fsindex, gsindex;
24758 fpu_switch_t fpu;
24759
24760 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24761 if (unlikely(next->ds | prev->ds))
24762 loadsegment(ds, next->ds);
24763
24764 + savesegment(ss, prev->ss);
24765 + if (unlikely(next->ss != prev->ss))
24766 + loadsegment(ss, next->ss);
24767
24768 /* We must save %fs and %gs before load_TLS() because
24769 * %fs and %gs may be cleared by load_TLS().
24770 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24771 prev->usersp = this_cpu_read(old_rsp);
24772 this_cpu_write(old_rsp, next->usersp);
24773 this_cpu_write(current_task, next_p);
24774 + this_cpu_write(current_tinfo, &next_p->tinfo);
24775
24776 - this_cpu_write(kernel_stack,
24777 - (unsigned long)task_stack_page(next_p) +
24778 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24779 + this_cpu_write(kernel_stack, next->sp0);
24780
24781 /*
24782 * Now maybe reload the debug registers and handle I/O bitmaps
24783 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24784 if (!p || p == current || p->state == TASK_RUNNING)
24785 return 0;
24786 stack = (unsigned long)task_stack_page(p);
24787 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24788 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24789 return 0;
24790 fp = *(u64 *)(p->thread.sp);
24791 do {
24792 - if (fp < (unsigned long)stack ||
24793 - fp >= (unsigned long)stack+THREAD_SIZE)
24794 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24795 return 0;
24796 ip = *(u64 *)(fp+8);
24797 if (!in_sched_functions(ip))
24798 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24799 index 7461f50..1334029 100644
24800 --- a/arch/x86/kernel/ptrace.c
24801 +++ b/arch/x86/kernel/ptrace.c
24802 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24803 {
24804 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24805 unsigned long sp = (unsigned long)&regs->sp;
24806 - struct thread_info *tinfo;
24807
24808 - if (context == (sp & ~(THREAD_SIZE - 1)))
24809 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24810 return sp;
24811
24812 - tinfo = (struct thread_info *)context;
24813 - if (tinfo->previous_esp)
24814 - return tinfo->previous_esp;
24815 + sp = *(unsigned long *)context;
24816 + if (sp)
24817 + return sp;
24818
24819 return (unsigned long)regs;
24820 }
24821 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24822 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24823 {
24824 int i;
24825 - int dr7 = 0;
24826 + unsigned long dr7 = 0;
24827 struct arch_hw_breakpoint *info;
24828
24829 for (i = 0; i < HBP_NUM; i++) {
24830 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24831 unsigned long addr, unsigned long data)
24832 {
24833 int ret;
24834 - unsigned long __user *datap = (unsigned long __user *)data;
24835 + unsigned long __user *datap = (__force unsigned long __user *)data;
24836
24837 switch (request) {
24838 /* read the word at location addr in the USER area. */
24839 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24840 if ((int) addr < 0)
24841 return -EIO;
24842 ret = do_get_thread_area(child, addr,
24843 - (struct user_desc __user *)data);
24844 + (__force struct user_desc __user *) data);
24845 break;
24846
24847 case PTRACE_SET_THREAD_AREA:
24848 if ((int) addr < 0)
24849 return -EIO;
24850 ret = do_set_thread_area(child, addr,
24851 - (struct user_desc __user *)data, 0);
24852 + (__force struct user_desc __user *) data, 0);
24853 break;
24854 #endif
24855
24856 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24857
24858 #ifdef CONFIG_X86_64
24859
24860 -static struct user_regset x86_64_regsets[] __read_mostly = {
24861 +static user_regset_no_const x86_64_regsets[] __read_only = {
24862 [REGSET_GENERAL] = {
24863 .core_note_type = NT_PRSTATUS,
24864 .n = sizeof(struct user_regs_struct) / sizeof(long),
24865 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24866 #endif /* CONFIG_X86_64 */
24867
24868 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24869 -static struct user_regset x86_32_regsets[] __read_mostly = {
24870 +static user_regset_no_const x86_32_regsets[] __read_only = {
24871 [REGSET_GENERAL] = {
24872 .core_note_type = NT_PRSTATUS,
24873 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24874 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24875 */
24876 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24877
24878 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24879 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24880 {
24881 #ifdef CONFIG_X86_64
24882 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24883 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24884 memset(info, 0, sizeof(*info));
24885 info->si_signo = SIGTRAP;
24886 info->si_code = si_code;
24887 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24888 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24889 }
24890
24891 void user_single_step_siginfo(struct task_struct *tsk,
24892 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24893 # define IS_IA32 0
24894 #endif
24895
24896 +#ifdef CONFIG_GRKERNSEC_SETXID
24897 +extern void gr_delayed_cred_worker(void);
24898 +#endif
24899 +
24900 /*
24901 * We must return the syscall number to actually look up in the table.
24902 * This can be -1L to skip running any syscall at all.
24903 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24904
24905 user_exit();
24906
24907 +#ifdef CONFIG_GRKERNSEC_SETXID
24908 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24909 + gr_delayed_cred_worker();
24910 +#endif
24911 +
24912 /*
24913 * If we stepped into a sysenter/syscall insn, it trapped in
24914 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24915 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24916 */
24917 user_exit();
24918
24919 +#ifdef CONFIG_GRKERNSEC_SETXID
24920 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24921 + gr_delayed_cred_worker();
24922 +#endif
24923 +
24924 audit_syscall_exit(regs);
24925
24926 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24927 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24928 index 2cb9470..ff1fd80 100644
24929 --- a/arch/x86/kernel/pvclock.c
24930 +++ b/arch/x86/kernel/pvclock.c
24931 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24932 return pv_tsc_khz;
24933 }
24934
24935 -static atomic64_t last_value = ATOMIC64_INIT(0);
24936 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24937
24938 void pvclock_resume(void)
24939 {
24940 - atomic64_set(&last_value, 0);
24941 + atomic64_set_unchecked(&last_value, 0);
24942 }
24943
24944 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24945 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24946 * updating at the same time, and one of them could be slightly behind,
24947 * making the assumption that last_value always go forward fail to hold.
24948 */
24949 - last = atomic64_read(&last_value);
24950 + last = atomic64_read_unchecked(&last_value);
24951 do {
24952 if (ret < last)
24953 return last;
24954 - last = atomic64_cmpxchg(&last_value, last, ret);
24955 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24956 } while (unlikely(last != ret));
24957
24958 return ret;
24959 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24960 index 5f4ad27..9d96c99 100644
24961 --- a/arch/x86/kernel/reboot.c
24962 +++ b/arch/x86/kernel/reboot.c
24963 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24964
24965 void __noreturn machine_real_restart(unsigned int type)
24966 {
24967 +
24968 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24969 + struct desc_struct *gdt;
24970 +#endif
24971 +
24972 local_irq_disable();
24973
24974 /*
24975 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24976
24977 /* Jump to the identity-mapped low memory code */
24978 #ifdef CONFIG_X86_32
24979 - asm volatile("jmpl *%0" : :
24980 +
24981 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24982 + gdt = get_cpu_gdt_table(smp_processor_id());
24983 + pax_open_kernel();
24984 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24985 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24986 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24987 + loadsegment(ds, __KERNEL_DS);
24988 + loadsegment(es, __KERNEL_DS);
24989 + loadsegment(ss, __KERNEL_DS);
24990 +#endif
24991 +#ifdef CONFIG_PAX_KERNEXEC
24992 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24993 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24994 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24995 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24996 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24997 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24998 +#endif
24999 + pax_close_kernel();
25000 +#endif
25001 +
25002 + asm volatile("ljmpl *%0" : :
25003 "rm" (real_mode_header->machine_real_restart_asm),
25004 "a" (type));
25005 #else
25006 @@ -458,7 +485,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
25007 * try to force a triple fault and then cycle between hitting the keyboard
25008 * controller and doing that
25009 */
25010 -static void native_machine_emergency_restart(void)
25011 +static void __noreturn native_machine_emergency_restart(void)
25012 {
25013 int i;
25014 int attempt = 0;
25015 @@ -567,13 +594,13 @@ void native_machine_shutdown(void)
25016 #endif
25017 }
25018
25019 -static void __machine_emergency_restart(int emergency)
25020 +static void __noreturn __machine_emergency_restart(int emergency)
25021 {
25022 reboot_emergency = emergency;
25023 machine_ops.emergency_restart();
25024 }
25025
25026 -static void native_machine_restart(char *__unused)
25027 +static void __noreturn native_machine_restart(char *__unused)
25028 {
25029 pr_notice("machine restart\n");
25030
25031 @@ -582,7 +609,7 @@ static void native_machine_restart(char *__unused)
25032 __machine_emergency_restart(0);
25033 }
25034
25035 -static void native_machine_halt(void)
25036 +static void __noreturn native_machine_halt(void)
25037 {
25038 /* Stop other cpus and apics */
25039 machine_shutdown();
25040 @@ -592,7 +619,7 @@ static void native_machine_halt(void)
25041 stop_this_cpu(NULL);
25042 }
25043
25044 -static void native_machine_power_off(void)
25045 +static void __noreturn native_machine_power_off(void)
25046 {
25047 if (pm_power_off) {
25048 if (!reboot_force)
25049 @@ -601,9 +628,10 @@ static void native_machine_power_off(void)
25050 }
25051 /* A fallback in case there is no PM info available */
25052 tboot_shutdown(TB_SHUTDOWN_HALT);
25053 + unreachable();
25054 }
25055
25056 -struct machine_ops machine_ops = {
25057 +struct machine_ops machine_ops __read_only = {
25058 .power_off = native_machine_power_off,
25059 .shutdown = native_machine_shutdown,
25060 .emergency_restart = native_machine_emergency_restart,
25061 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25062 index c8e41e9..64049ef 100644
25063 --- a/arch/x86/kernel/reboot_fixups_32.c
25064 +++ b/arch/x86/kernel/reboot_fixups_32.c
25065 @@ -57,7 +57,7 @@ struct device_fixup {
25066 unsigned int vendor;
25067 unsigned int device;
25068 void (*reboot_fixup)(struct pci_dev *);
25069 -};
25070 +} __do_const;
25071
25072 /*
25073 * PCI ids solely used for fixups_table go here
25074 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25075 index 3fd2c69..16ef367 100644
25076 --- a/arch/x86/kernel/relocate_kernel_64.S
25077 +++ b/arch/x86/kernel/relocate_kernel_64.S
25078 @@ -11,6 +11,7 @@
25079 #include <asm/kexec.h>
25080 #include <asm/processor-flags.h>
25081 #include <asm/pgtable_types.h>
25082 +#include <asm/alternative-asm.h>
25083
25084 /*
25085 * Must be relocatable PIC code callable as a C function
25086 @@ -96,8 +97,7 @@ relocate_kernel:
25087
25088 /* jump to identity mapped page */
25089 addq $(identity_mapped - relocate_kernel), %r8
25090 - pushq %r8
25091 - ret
25092 + jmp *%r8
25093
25094 identity_mapped:
25095 /* set return address to 0 if not preserving context */
25096 @@ -167,6 +167,7 @@ identity_mapped:
25097 xorl %r14d, %r14d
25098 xorl %r15d, %r15d
25099
25100 + pax_force_retaddr 0, 1
25101 ret
25102
25103 1:
25104 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25105 index f8ec578..0cc110a 100644
25106 --- a/arch/x86/kernel/setup.c
25107 +++ b/arch/x86/kernel/setup.c
25108 @@ -110,6 +110,7 @@
25109 #include <asm/mce.h>
25110 #include <asm/alternative.h>
25111 #include <asm/prom.h>
25112 +#include <asm/boot.h>
25113
25114 /*
25115 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25116 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25117 #endif
25118
25119
25120 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25121 -unsigned long mmu_cr4_features;
25122 +#ifdef CONFIG_X86_64
25123 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25124 +#elif defined(CONFIG_X86_PAE)
25125 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25126 #else
25127 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25128 +unsigned long mmu_cr4_features __read_only;
25129 #endif
25130
25131 +void set_in_cr4(unsigned long mask)
25132 +{
25133 + unsigned long cr4 = read_cr4();
25134 +
25135 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25136 + return;
25137 +
25138 + pax_open_kernel();
25139 + mmu_cr4_features |= mask;
25140 + pax_close_kernel();
25141 +
25142 + if (trampoline_cr4_features)
25143 + *trampoline_cr4_features = mmu_cr4_features;
25144 + cr4 |= mask;
25145 + write_cr4(cr4);
25146 +}
25147 +EXPORT_SYMBOL(set_in_cr4);
25148 +
25149 +void clear_in_cr4(unsigned long mask)
25150 +{
25151 + unsigned long cr4 = read_cr4();
25152 +
25153 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25154 + return;
25155 +
25156 + pax_open_kernel();
25157 + mmu_cr4_features &= ~mask;
25158 + pax_close_kernel();
25159 +
25160 + if (trampoline_cr4_features)
25161 + *trampoline_cr4_features = mmu_cr4_features;
25162 + cr4 &= ~mask;
25163 + write_cr4(cr4);
25164 +}
25165 +EXPORT_SYMBOL(clear_in_cr4);
25166 +
25167 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25168 int bootloader_type, bootloader_version;
25169
25170 @@ -444,7 +483,7 @@ static void __init parse_setup_data(void)
25171
25172 switch (data->type) {
25173 case SETUP_E820_EXT:
25174 - parse_e820_ext(data);
25175 + parse_e820_ext((struct setup_data __force_kernel *)data);
25176 break;
25177 case SETUP_DTB:
25178 add_dtb(pa_data);
25179 @@ -771,7 +810,7 @@ static void __init trim_bios_range(void)
25180 * area (640->1Mb) as ram even though it is not.
25181 * take them out.
25182 */
25183 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25184 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25185
25186 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25187 }
25188 @@ -779,7 +818,7 @@ static void __init trim_bios_range(void)
25189 /* called before trim_bios_range() to spare extra sanitize */
25190 static void __init e820_add_kernel_range(void)
25191 {
25192 - u64 start = __pa_symbol(_text);
25193 + u64 start = __pa_symbol(ktla_ktva(_text));
25194 u64 size = __pa_symbol(_end) - start;
25195
25196 /*
25197 @@ -841,8 +880,12 @@ static void __init trim_low_memory_range(void)
25198
25199 void __init setup_arch(char **cmdline_p)
25200 {
25201 +#ifdef CONFIG_X86_32
25202 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25203 +#else
25204 memblock_reserve(__pa_symbol(_text),
25205 (unsigned long)__bss_stop - (unsigned long)_text);
25206 +#endif
25207
25208 early_reserve_initrd();
25209
25210 @@ -934,14 +977,14 @@ void __init setup_arch(char **cmdline_p)
25211
25212 if (!boot_params.hdr.root_flags)
25213 root_mountflags &= ~MS_RDONLY;
25214 - init_mm.start_code = (unsigned long) _text;
25215 - init_mm.end_code = (unsigned long) _etext;
25216 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25217 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25218 init_mm.end_data = (unsigned long) _edata;
25219 init_mm.brk = _brk_end;
25220
25221 - code_resource.start = __pa_symbol(_text);
25222 - code_resource.end = __pa_symbol(_etext)-1;
25223 - data_resource.start = __pa_symbol(_etext);
25224 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25225 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25226 + data_resource.start = __pa_symbol(_sdata);
25227 data_resource.end = __pa_symbol(_edata)-1;
25228 bss_resource.start = __pa_symbol(__bss_start);
25229 bss_resource.end = __pa_symbol(__bss_stop)-1;
25230 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25231 index 5cdff03..80fa283 100644
25232 --- a/arch/x86/kernel/setup_percpu.c
25233 +++ b/arch/x86/kernel/setup_percpu.c
25234 @@ -21,19 +21,17 @@
25235 #include <asm/cpu.h>
25236 #include <asm/stackprotector.h>
25237
25238 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25239 +#ifdef CONFIG_SMP
25240 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25241 EXPORT_PER_CPU_SYMBOL(cpu_number);
25242 +#endif
25243
25244 -#ifdef CONFIG_X86_64
25245 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25246 -#else
25247 -#define BOOT_PERCPU_OFFSET 0
25248 -#endif
25249
25250 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25251 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25252
25253 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25254 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25255 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25256 };
25257 EXPORT_SYMBOL(__per_cpu_offset);
25258 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25259 {
25260 #ifdef CONFIG_NEED_MULTIPLE_NODES
25261 pg_data_t *last = NULL;
25262 - unsigned int cpu;
25263 + int cpu;
25264
25265 for_each_possible_cpu(cpu) {
25266 int node = early_cpu_to_node(cpu);
25267 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25268 {
25269 #ifdef CONFIG_X86_32
25270 struct desc_struct gdt;
25271 + unsigned long base = per_cpu_offset(cpu);
25272
25273 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25274 - 0x2 | DESCTYPE_S, 0x8);
25275 - gdt.s = 1;
25276 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25277 + 0x83 | DESCTYPE_S, 0xC);
25278 write_gdt_entry(get_cpu_gdt_table(cpu),
25279 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25280 #endif
25281 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25282 /* alrighty, percpu areas up and running */
25283 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25284 for_each_possible_cpu(cpu) {
25285 +#ifdef CONFIG_CC_STACKPROTECTOR
25286 +#ifdef CONFIG_X86_32
25287 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25288 +#endif
25289 +#endif
25290 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25291 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25292 per_cpu(cpu_number, cpu) = cpu;
25293 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25294 */
25295 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25296 #endif
25297 +#ifdef CONFIG_CC_STACKPROTECTOR
25298 +#ifdef CONFIG_X86_32
25299 + if (!cpu)
25300 + per_cpu(stack_canary.canary, cpu) = canary;
25301 +#endif
25302 +#endif
25303 /*
25304 * Up to this point, the boot CPU has been using .init.data
25305 * area. Reload any changed state for the boot CPU.
25306 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25307 index d859eea..44e17c4 100644
25308 --- a/arch/x86/kernel/signal.c
25309 +++ b/arch/x86/kernel/signal.c
25310 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25311 * Align the stack pointer according to the i386 ABI,
25312 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25313 */
25314 - sp = ((sp + 4) & -16ul) - 4;
25315 + sp = ((sp - 12) & -16ul) - 4;
25316 #else /* !CONFIG_X86_32 */
25317 sp = round_down(sp, 16) - 8;
25318 #endif
25319 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25320 }
25321
25322 if (current->mm->context.vdso)
25323 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25324 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25325 else
25326 - restorer = &frame->retcode;
25327 + restorer = (void __user *)&frame->retcode;
25328 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25329 restorer = ksig->ka.sa.sa_restorer;
25330
25331 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25332 * reasons and because gdb uses it as a signature to notice
25333 * signal handler stack frames.
25334 */
25335 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25336 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25337
25338 if (err)
25339 return -EFAULT;
25340 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25341 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25342
25343 /* Set up to return from userspace. */
25344 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25345 + if (current->mm->context.vdso)
25346 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25347 + else
25348 + restorer = (void __user *)&frame->retcode;
25349 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25350 restorer = ksig->ka.sa.sa_restorer;
25351 put_user_ex(restorer, &frame->pretcode);
25352 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25353 * reasons and because gdb uses it as a signature to notice
25354 * signal handler stack frames.
25355 */
25356 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25357 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25358 } put_user_catch(err);
25359
25360 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25361 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25362 {
25363 int usig = signr_convert(ksig->sig);
25364 sigset_t *set = sigmask_to_save();
25365 - compat_sigset_t *cset = (compat_sigset_t *) set;
25366 + sigset_t sigcopy;
25367 + compat_sigset_t *cset;
25368 +
25369 + sigcopy = *set;
25370 +
25371 + cset = (compat_sigset_t *) &sigcopy;
25372
25373 /* Set up the stack frame */
25374 if (is_ia32_frame()) {
25375 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25376 } else if (is_x32_frame()) {
25377 return x32_setup_rt_frame(ksig, cset, regs);
25378 } else {
25379 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25380 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25381 }
25382 }
25383
25384 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25385 index cdaa347..f5af55d 100644
25386 --- a/arch/x86/kernel/smp.c
25387 +++ b/arch/x86/kernel/smp.c
25388 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25389
25390 __setup("nonmi_ipi", nonmi_ipi_setup);
25391
25392 -struct smp_ops smp_ops = {
25393 +struct smp_ops smp_ops __read_only = {
25394 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25395 .smp_prepare_cpus = native_smp_prepare_cpus,
25396 .smp_cpus_done = native_smp_cpus_done,
25397 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25398 index aecc98a..0244a53 100644
25399 --- a/arch/x86/kernel/smpboot.c
25400 +++ b/arch/x86/kernel/smpboot.c
25401 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25402
25403 enable_start_cpu0 = 0;
25404
25405 -#ifdef CONFIG_X86_32
25406 - /* switch away from the initial page table */
25407 - load_cr3(swapper_pg_dir);
25408 - __flush_tlb_all();
25409 -#endif
25410 -
25411 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25412 barrier();
25413 +
25414 + /* switch away from the initial page table */
25415 +#ifdef CONFIG_PAX_PER_CPU_PGD
25416 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25417 + __flush_tlb_all();
25418 +#elif defined(CONFIG_X86_32)
25419 + load_cr3(swapper_pg_dir);
25420 + __flush_tlb_all();
25421 +#endif
25422 +
25423 /*
25424 * Check TSC synchronization with the BP:
25425 */
25426 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25427 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25428 (THREAD_SIZE + task_stack_page(idle))) - 1);
25429 per_cpu(current_task, cpu) = idle;
25430 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25431
25432 #ifdef CONFIG_X86_32
25433 /* Stack for startup_32 can be just as for start_secondary onwards */
25434 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25435 #else
25436 clear_tsk_thread_flag(idle, TIF_FORK);
25437 initial_gs = per_cpu_offset(cpu);
25438 - per_cpu(kernel_stack, cpu) =
25439 - (unsigned long)task_stack_page(idle) -
25440 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25441 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25442 #endif
25443 +
25444 + pax_open_kernel();
25445 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25446 + pax_close_kernel();
25447 +
25448 initial_code = (unsigned long)start_secondary;
25449 stack_start = idle->thread.sp;
25450
25451 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25452 /* the FPU context is blank, nobody can own it */
25453 __cpu_disable_lazy_restore(cpu);
25454
25455 +#ifdef CONFIG_PAX_PER_CPU_PGD
25456 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25457 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25458 + KERNEL_PGD_PTRS);
25459 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25460 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25461 + KERNEL_PGD_PTRS);
25462 +#endif
25463 +
25464 err = do_boot_cpu(apicid, cpu, tidle);
25465 if (err) {
25466 pr_debug("do_boot_cpu failed %d\n", err);
25467 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25468 index 9b4d51d..5d28b58 100644
25469 --- a/arch/x86/kernel/step.c
25470 +++ b/arch/x86/kernel/step.c
25471 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25472 struct desc_struct *desc;
25473 unsigned long base;
25474
25475 - seg &= ~7UL;
25476 + seg >>= 3;
25477
25478 mutex_lock(&child->mm->context.lock);
25479 - if (unlikely((seg >> 3) >= child->mm->context.size))
25480 + if (unlikely(seg >= child->mm->context.size))
25481 addr = -1L; /* bogus selector, access would fault */
25482 else {
25483 desc = child->mm->context.ldt + seg;
25484 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25485 addr += base;
25486 }
25487 mutex_unlock(&child->mm->context.lock);
25488 - }
25489 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25490 + addr = ktla_ktva(addr);
25491
25492 return addr;
25493 }
25494 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25495 unsigned char opcode[15];
25496 unsigned long addr = convert_ip_to_linear(child, regs);
25497
25498 + if (addr == -EINVAL)
25499 + return 0;
25500 +
25501 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25502 for (i = 0; i < copied; i++) {
25503 switch (opcode[i]) {
25504 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25505 new file mode 100644
25506 index 0000000..5877189
25507 --- /dev/null
25508 +++ b/arch/x86/kernel/sys_i386_32.c
25509 @@ -0,0 +1,189 @@
25510 +/*
25511 + * This file contains various random system calls that
25512 + * have a non-standard calling sequence on the Linux/i386
25513 + * platform.
25514 + */
25515 +
25516 +#include <linux/errno.h>
25517 +#include <linux/sched.h>
25518 +#include <linux/mm.h>
25519 +#include <linux/fs.h>
25520 +#include <linux/smp.h>
25521 +#include <linux/sem.h>
25522 +#include <linux/msg.h>
25523 +#include <linux/shm.h>
25524 +#include <linux/stat.h>
25525 +#include <linux/syscalls.h>
25526 +#include <linux/mman.h>
25527 +#include <linux/file.h>
25528 +#include <linux/utsname.h>
25529 +#include <linux/ipc.h>
25530 +#include <linux/elf.h>
25531 +
25532 +#include <linux/uaccess.h>
25533 +#include <linux/unistd.h>
25534 +
25535 +#include <asm/syscalls.h>
25536 +
25537 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25538 +{
25539 + unsigned long pax_task_size = TASK_SIZE;
25540 +
25541 +#ifdef CONFIG_PAX_SEGMEXEC
25542 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25543 + pax_task_size = SEGMEXEC_TASK_SIZE;
25544 +#endif
25545 +
25546 + if (flags & MAP_FIXED)
25547 + if (len > pax_task_size || addr > pax_task_size - len)
25548 + return -EINVAL;
25549 +
25550 + return 0;
25551 +}
25552 +
25553 +/*
25554 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25555 + */
25556 +static unsigned long get_align_mask(void)
25557 +{
25558 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25559 + return 0;
25560 +
25561 + if (!(current->flags & PF_RANDOMIZE))
25562 + return 0;
25563 +
25564 + return va_align.mask;
25565 +}
25566 +
25567 +unsigned long
25568 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25569 + unsigned long len, unsigned long pgoff, unsigned long flags)
25570 +{
25571 + struct mm_struct *mm = current->mm;
25572 + struct vm_area_struct *vma;
25573 + unsigned long pax_task_size = TASK_SIZE;
25574 + struct vm_unmapped_area_info info;
25575 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25576 +
25577 +#ifdef CONFIG_PAX_SEGMEXEC
25578 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25579 + pax_task_size = SEGMEXEC_TASK_SIZE;
25580 +#endif
25581 +
25582 + pax_task_size -= PAGE_SIZE;
25583 +
25584 + if (len > pax_task_size)
25585 + return -ENOMEM;
25586 +
25587 + if (flags & MAP_FIXED)
25588 + return addr;
25589 +
25590 +#ifdef CONFIG_PAX_RANDMMAP
25591 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25592 +#endif
25593 +
25594 + if (addr) {
25595 + addr = PAGE_ALIGN(addr);
25596 + if (pax_task_size - len >= addr) {
25597 + vma = find_vma(mm, addr);
25598 + if (check_heap_stack_gap(vma, addr, len, offset))
25599 + return addr;
25600 + }
25601 + }
25602 +
25603 + info.flags = 0;
25604 + info.length = len;
25605 + info.align_mask = filp ? get_align_mask() : 0;
25606 + info.align_offset = pgoff << PAGE_SHIFT;
25607 + info.threadstack_offset = offset;
25608 +
25609 +#ifdef CONFIG_PAX_PAGEEXEC
25610 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25611 + info.low_limit = 0x00110000UL;
25612 + info.high_limit = mm->start_code;
25613 +
25614 +#ifdef CONFIG_PAX_RANDMMAP
25615 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25616 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25617 +#endif
25618 +
25619 + if (info.low_limit < info.high_limit) {
25620 + addr = vm_unmapped_area(&info);
25621 + if (!IS_ERR_VALUE(addr))
25622 + return addr;
25623 + }
25624 + } else
25625 +#endif
25626 +
25627 + info.low_limit = mm->mmap_base;
25628 + info.high_limit = pax_task_size;
25629 +
25630 + return vm_unmapped_area(&info);
25631 +}
25632 +
25633 +unsigned long
25634 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25635 + const unsigned long len, const unsigned long pgoff,
25636 + const unsigned long flags)
25637 +{
25638 + struct vm_area_struct *vma;
25639 + struct mm_struct *mm = current->mm;
25640 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25641 + struct vm_unmapped_area_info info;
25642 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25643 +
25644 +#ifdef CONFIG_PAX_SEGMEXEC
25645 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25646 + pax_task_size = SEGMEXEC_TASK_SIZE;
25647 +#endif
25648 +
25649 + pax_task_size -= PAGE_SIZE;
25650 +
25651 + /* requested length too big for entire address space */
25652 + if (len > pax_task_size)
25653 + return -ENOMEM;
25654 +
25655 + if (flags & MAP_FIXED)
25656 + return addr;
25657 +
25658 +#ifdef CONFIG_PAX_PAGEEXEC
25659 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25660 + goto bottomup;
25661 +#endif
25662 +
25663 +#ifdef CONFIG_PAX_RANDMMAP
25664 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25665 +#endif
25666 +
25667 + /* requesting a specific address */
25668 + if (addr) {
25669 + addr = PAGE_ALIGN(addr);
25670 + if (pax_task_size - len >= addr) {
25671 + vma = find_vma(mm, addr);
25672 + if (check_heap_stack_gap(vma, addr, len, offset))
25673 + return addr;
25674 + }
25675 + }
25676 +
25677 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25678 + info.length = len;
25679 + info.low_limit = PAGE_SIZE;
25680 + info.high_limit = mm->mmap_base;
25681 + info.align_mask = filp ? get_align_mask() : 0;
25682 + info.align_offset = pgoff << PAGE_SHIFT;
25683 + info.threadstack_offset = offset;
25684 +
25685 + addr = vm_unmapped_area(&info);
25686 + if (!(addr & ~PAGE_MASK))
25687 + return addr;
25688 + VM_BUG_ON(addr != -ENOMEM);
25689 +
25690 +bottomup:
25691 + /*
25692 + * A failed mmap() very likely causes application failure,
25693 + * so fall back to the bottom-up function here. This scenario
25694 + * can happen with large stack limits and large mmap()
25695 + * allocations.
25696 + */
25697 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25698 +}
25699 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25700 index 30277e2..5664a29 100644
25701 --- a/arch/x86/kernel/sys_x86_64.c
25702 +++ b/arch/x86/kernel/sys_x86_64.c
25703 @@ -81,8 +81,8 @@ out:
25704 return error;
25705 }
25706
25707 -static void find_start_end(unsigned long flags, unsigned long *begin,
25708 - unsigned long *end)
25709 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25710 + unsigned long *begin, unsigned long *end)
25711 {
25712 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25713 unsigned long new_begin;
25714 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25715 *begin = new_begin;
25716 }
25717 } else {
25718 - *begin = current->mm->mmap_legacy_base;
25719 + *begin = mm->mmap_legacy_base;
25720 *end = TASK_SIZE;
25721 }
25722 }
25723 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25724 struct vm_area_struct *vma;
25725 struct vm_unmapped_area_info info;
25726 unsigned long begin, end;
25727 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25728
25729 if (flags & MAP_FIXED)
25730 return addr;
25731
25732 - find_start_end(flags, &begin, &end);
25733 + find_start_end(mm, flags, &begin, &end);
25734
25735 if (len > end)
25736 return -ENOMEM;
25737
25738 +#ifdef CONFIG_PAX_RANDMMAP
25739 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25740 +#endif
25741 +
25742 if (addr) {
25743 addr = PAGE_ALIGN(addr);
25744 vma = find_vma(mm, addr);
25745 - if (end - len >= addr &&
25746 - (!vma || addr + len <= vma->vm_start))
25747 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25748 return addr;
25749 }
25750
25751 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25752 info.high_limit = end;
25753 info.align_mask = filp ? get_align_mask() : 0;
25754 info.align_offset = pgoff << PAGE_SHIFT;
25755 + info.threadstack_offset = offset;
25756 return vm_unmapped_area(&info);
25757 }
25758
25759 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25760 struct mm_struct *mm = current->mm;
25761 unsigned long addr = addr0;
25762 struct vm_unmapped_area_info info;
25763 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25764
25765 /* requested length too big for entire address space */
25766 if (len > TASK_SIZE)
25767 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25768 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25769 goto bottomup;
25770
25771 +#ifdef CONFIG_PAX_RANDMMAP
25772 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25773 +#endif
25774 +
25775 /* requesting a specific address */
25776 if (addr) {
25777 addr = PAGE_ALIGN(addr);
25778 vma = find_vma(mm, addr);
25779 - if (TASK_SIZE - len >= addr &&
25780 - (!vma || addr + len <= vma->vm_start))
25781 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25782 return addr;
25783 }
25784
25785 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25786 info.high_limit = mm->mmap_base;
25787 info.align_mask = filp ? get_align_mask() : 0;
25788 info.align_offset = pgoff << PAGE_SHIFT;
25789 + info.threadstack_offset = offset;
25790 addr = vm_unmapped_area(&info);
25791 if (!(addr & ~PAGE_MASK))
25792 return addr;
25793 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25794 index addf7b5..f960685 100644
25795 --- a/arch/x86/kernel/tboot.c
25796 +++ b/arch/x86/kernel/tboot.c
25797 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25798
25799 void tboot_shutdown(u32 shutdown_type)
25800 {
25801 - void (*shutdown)(void);
25802 + void (* __noreturn shutdown)(void);
25803
25804 if (!tboot_enabled())
25805 return;
25806 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25807
25808 switch_to_tboot_pt();
25809
25810 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25811 + shutdown = (void *)tboot->shutdown_entry;
25812 shutdown();
25813
25814 /* should not reach here */
25815 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25816 return 0;
25817 }
25818
25819 -static atomic_t ap_wfs_count;
25820 +static atomic_unchecked_t ap_wfs_count;
25821
25822 static int tboot_wait_for_aps(int num_aps)
25823 {
25824 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25825 {
25826 switch (action) {
25827 case CPU_DYING:
25828 - atomic_inc(&ap_wfs_count);
25829 + atomic_inc_unchecked(&ap_wfs_count);
25830 if (num_online_cpus() == 1)
25831 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25832 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25833 return NOTIFY_BAD;
25834 break;
25835 }
25836 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25837
25838 tboot_create_trampoline();
25839
25840 - atomic_set(&ap_wfs_count, 0);
25841 + atomic_set_unchecked(&ap_wfs_count, 0);
25842 register_hotcpu_notifier(&tboot_cpu_notifier);
25843
25844 #ifdef CONFIG_DEBUG_FS
25845 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25846 index 24d3c91..d06b473 100644
25847 --- a/arch/x86/kernel/time.c
25848 +++ b/arch/x86/kernel/time.c
25849 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25850 {
25851 unsigned long pc = instruction_pointer(regs);
25852
25853 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25854 + if (!user_mode(regs) && in_lock_functions(pc)) {
25855 #ifdef CONFIG_FRAME_POINTER
25856 - return *(unsigned long *)(regs->bp + sizeof(long));
25857 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25858 #else
25859 unsigned long *sp =
25860 (unsigned long *)kernel_stack_pointer(regs);
25861 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25862 * or above a saved flags. Eflags has bits 22-31 zero,
25863 * kernel addresses don't.
25864 */
25865 +
25866 +#ifdef CONFIG_PAX_KERNEXEC
25867 + return ktla_ktva(sp[0]);
25868 +#else
25869 if (sp[0] >> 22)
25870 return sp[0];
25871 if (sp[1] >> 22)
25872 return sp[1];
25873 #endif
25874 +
25875 +#endif
25876 }
25877 return pc;
25878 }
25879 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25880 index f7fec09..9991981 100644
25881 --- a/arch/x86/kernel/tls.c
25882 +++ b/arch/x86/kernel/tls.c
25883 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25884 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25885 return -EINVAL;
25886
25887 +#ifdef CONFIG_PAX_SEGMEXEC
25888 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25889 + return -EINVAL;
25890 +#endif
25891 +
25892 set_tls_desc(p, idx, &info, 1);
25893
25894 return 0;
25895 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25896
25897 if (kbuf)
25898 info = kbuf;
25899 - else if (__copy_from_user(infobuf, ubuf, count))
25900 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25901 return -EFAULT;
25902 else
25903 info = infobuf;
25904 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25905 index 1c113db..287b42e 100644
25906 --- a/arch/x86/kernel/tracepoint.c
25907 +++ b/arch/x86/kernel/tracepoint.c
25908 @@ -9,11 +9,11 @@
25909 #include <linux/atomic.h>
25910
25911 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25912 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25913 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25914 (unsigned long) trace_idt_table };
25915
25916 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25917 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25918 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25919
25920 static int trace_irq_vector_refcount;
25921 static DEFINE_MUTEX(irq_vector_mutex);
25922 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25923 index 1b23a1c..910de0d 100644
25924 --- a/arch/x86/kernel/traps.c
25925 +++ b/arch/x86/kernel/traps.c
25926 @@ -65,7 +65,7 @@
25927 #include <asm/proto.h>
25928
25929 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25930 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25931 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25932 #else
25933 #include <asm/processor-flags.h>
25934 #include <asm/setup.h>
25935 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25936 #endif
25937
25938 /* Must be page-aligned because the real IDT is used in a fixmap. */
25939 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25940 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25941
25942 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25943 EXPORT_SYMBOL_GPL(used_vectors);
25944 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25945 }
25946
25947 static int __kprobes
25948 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25949 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25950 struct pt_regs *regs, long error_code)
25951 {
25952 #ifdef CONFIG_X86_32
25953 - if (regs->flags & X86_VM_MASK) {
25954 + if (v8086_mode(regs)) {
25955 /*
25956 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25957 * On nmi (interrupt 2), do_trap should not be called.
25958 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25959 return -1;
25960 }
25961 #endif
25962 - if (!user_mode(regs)) {
25963 + if (!user_mode_novm(regs)) {
25964 if (!fixup_exception(regs)) {
25965 tsk->thread.error_code = error_code;
25966 tsk->thread.trap_nr = trapnr;
25967 +
25968 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25969 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25970 + str = "PAX: suspicious stack segment fault";
25971 +#endif
25972 +
25973 die(str, regs, error_code);
25974 }
25975 +
25976 +#ifdef CONFIG_PAX_REFCOUNT
25977 + if (trapnr == 4)
25978 + pax_report_refcount_overflow(regs);
25979 +#endif
25980 +
25981 return 0;
25982 }
25983
25984 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25985 }
25986
25987 static void __kprobes
25988 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25989 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25990 long error_code, siginfo_t *info)
25991 {
25992 struct task_struct *tsk = current;
25993 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25994 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25995 printk_ratelimit()) {
25996 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25997 - tsk->comm, tsk->pid, str,
25998 + tsk->comm, task_pid_nr(tsk), str,
25999 regs->ip, regs->sp, error_code);
26000 print_vma_addr(" in ", regs->ip);
26001 pr_cont("\n");
26002 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
26003 conditional_sti(regs);
26004
26005 #ifdef CONFIG_X86_32
26006 - if (regs->flags & X86_VM_MASK) {
26007 + if (v8086_mode(regs)) {
26008 local_irq_enable();
26009 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
26010 goto exit;
26011 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
26012 #endif
26013
26014 tsk = current;
26015 - if (!user_mode(regs)) {
26016 + if (!user_mode_novm(regs)) {
26017 if (fixup_exception(regs))
26018 goto exit;
26019
26020 tsk->thread.error_code = error_code;
26021 tsk->thread.trap_nr = X86_TRAP_GP;
26022 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
26023 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
26024 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
26025 +
26026 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26027 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
26028 + die("PAX: suspicious general protection fault", regs, error_code);
26029 + else
26030 +#endif
26031 +
26032 die("general protection fault", regs, error_code);
26033 + }
26034 goto exit;
26035 }
26036
26037 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
26038 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
26039 + struct mm_struct *mm = tsk->mm;
26040 + unsigned long limit;
26041 +
26042 + down_write(&mm->mmap_sem);
26043 + limit = mm->context.user_cs_limit;
26044 + if (limit < TASK_SIZE) {
26045 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26046 + up_write(&mm->mmap_sem);
26047 + return;
26048 + }
26049 + up_write(&mm->mmap_sem);
26050 + }
26051 +#endif
26052 +
26053 tsk->thread.error_code = error_code;
26054 tsk->thread.trap_nr = X86_TRAP_GP;
26055
26056 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26057 /* It's safe to allow irq's after DR6 has been saved */
26058 preempt_conditional_sti(regs);
26059
26060 - if (regs->flags & X86_VM_MASK) {
26061 + if (v8086_mode(regs)) {
26062 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26063 X86_TRAP_DB);
26064 preempt_conditional_cli(regs);
26065 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26066 * We already checked v86 mode above, so we can check for kernel mode
26067 * by just checking the CPL of CS.
26068 */
26069 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26070 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26071 tsk->thread.debugreg6 &= ~DR_STEP;
26072 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26073 regs->flags &= ~X86_EFLAGS_TF;
26074 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26075 return;
26076 conditional_sti(regs);
26077
26078 - if (!user_mode_vm(regs))
26079 + if (!user_mode(regs))
26080 {
26081 if (!fixup_exception(regs)) {
26082 task->thread.error_code = error_code;
26083 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26084 index 2ed8459..7cf329f 100644
26085 --- a/arch/x86/kernel/uprobes.c
26086 +++ b/arch/x86/kernel/uprobes.c
26087 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26088 int ret = NOTIFY_DONE;
26089
26090 /* We are only interested in userspace traps */
26091 - if (regs && !user_mode_vm(regs))
26092 + if (regs && !user_mode(regs))
26093 return NOTIFY_DONE;
26094
26095 switch (val) {
26096 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26097
26098 if (ncopied != rasize) {
26099 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26100 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26101 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26102
26103 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26104 }
26105 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26106 index b9242ba..50c5edd 100644
26107 --- a/arch/x86/kernel/verify_cpu.S
26108 +++ b/arch/x86/kernel/verify_cpu.S
26109 @@ -20,6 +20,7 @@
26110 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26111 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26112 * arch/x86/kernel/head_32.S: processor startup
26113 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26114 *
26115 * verify_cpu, returns the status of longmode and SSE in register %eax.
26116 * 0: Success 1: Failure
26117 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26118 index e8edcf5..27f9344 100644
26119 --- a/arch/x86/kernel/vm86_32.c
26120 +++ b/arch/x86/kernel/vm86_32.c
26121 @@ -44,6 +44,7 @@
26122 #include <linux/ptrace.h>
26123 #include <linux/audit.h>
26124 #include <linux/stddef.h>
26125 +#include <linux/grsecurity.h>
26126
26127 #include <asm/uaccess.h>
26128 #include <asm/io.h>
26129 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26130 do_exit(SIGSEGV);
26131 }
26132
26133 - tss = &per_cpu(init_tss, get_cpu());
26134 + tss = init_tss + get_cpu();
26135 current->thread.sp0 = current->thread.saved_sp0;
26136 current->thread.sysenter_cs = __KERNEL_CS;
26137 load_sp0(tss, &current->thread);
26138 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26139
26140 if (tsk->thread.saved_sp0)
26141 return -EPERM;
26142 +
26143 +#ifdef CONFIG_GRKERNSEC_VM86
26144 + if (!capable(CAP_SYS_RAWIO)) {
26145 + gr_handle_vm86();
26146 + return -EPERM;
26147 + }
26148 +#endif
26149 +
26150 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26151 offsetof(struct kernel_vm86_struct, vm86plus) -
26152 sizeof(info.regs));
26153 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26154 int tmp;
26155 struct vm86plus_struct __user *v86;
26156
26157 +#ifdef CONFIG_GRKERNSEC_VM86
26158 + if (!capable(CAP_SYS_RAWIO)) {
26159 + gr_handle_vm86();
26160 + return -EPERM;
26161 + }
26162 +#endif
26163 +
26164 tsk = current;
26165 switch (cmd) {
26166 case VM86_REQUEST_IRQ:
26167 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26168 tsk->thread.saved_fs = info->regs32->fs;
26169 tsk->thread.saved_gs = get_user_gs(info->regs32);
26170
26171 - tss = &per_cpu(init_tss, get_cpu());
26172 + tss = init_tss + get_cpu();
26173 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26174 if (cpu_has_sep)
26175 tsk->thread.sysenter_cs = 0;
26176 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26177 goto cannot_handle;
26178 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26179 goto cannot_handle;
26180 - intr_ptr = (unsigned long __user *) (i << 2);
26181 + intr_ptr = (__force unsigned long __user *) (i << 2);
26182 if (get_user(segoffs, intr_ptr))
26183 goto cannot_handle;
26184 if ((segoffs >> 16) == BIOSSEG)
26185 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26186 index 10c4f30..65408b9 100644
26187 --- a/arch/x86/kernel/vmlinux.lds.S
26188 +++ b/arch/x86/kernel/vmlinux.lds.S
26189 @@ -26,6 +26,13 @@
26190 #include <asm/page_types.h>
26191 #include <asm/cache.h>
26192 #include <asm/boot.h>
26193 +#include <asm/segment.h>
26194 +
26195 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26196 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26197 +#else
26198 +#define __KERNEL_TEXT_OFFSET 0
26199 +#endif
26200
26201 #undef i386 /* in case the preprocessor is a 32bit one */
26202
26203 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26204
26205 PHDRS {
26206 text PT_LOAD FLAGS(5); /* R_E */
26207 +#ifdef CONFIG_X86_32
26208 + module PT_LOAD FLAGS(5); /* R_E */
26209 +#endif
26210 +#ifdef CONFIG_XEN
26211 + rodata PT_LOAD FLAGS(5); /* R_E */
26212 +#else
26213 + rodata PT_LOAD FLAGS(4); /* R__ */
26214 +#endif
26215 data PT_LOAD FLAGS(6); /* RW_ */
26216 -#ifdef CONFIG_X86_64
26217 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26218 #ifdef CONFIG_SMP
26219 percpu PT_LOAD FLAGS(6); /* RW_ */
26220 #endif
26221 + text.init PT_LOAD FLAGS(5); /* R_E */
26222 + text.exit PT_LOAD FLAGS(5); /* R_E */
26223 init PT_LOAD FLAGS(7); /* RWE */
26224 -#endif
26225 note PT_NOTE FLAGS(0); /* ___ */
26226 }
26227
26228 SECTIONS
26229 {
26230 #ifdef CONFIG_X86_32
26231 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26232 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26233 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26234 #else
26235 - . = __START_KERNEL;
26236 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26237 + . = __START_KERNEL;
26238 #endif
26239
26240 /* Text and read-only data */
26241 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26242 - _text = .;
26243 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26244 /* bootstrapping code */
26245 +#ifdef CONFIG_X86_32
26246 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26247 +#else
26248 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26249 +#endif
26250 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26251 + _text = .;
26252 HEAD_TEXT
26253 . = ALIGN(8);
26254 _stext = .;
26255 @@ -104,13 +124,47 @@ SECTIONS
26256 IRQENTRY_TEXT
26257 *(.fixup)
26258 *(.gnu.warning)
26259 - /* End of text section */
26260 - _etext = .;
26261 } :text = 0x9090
26262
26263 - NOTES :text :note
26264 + . += __KERNEL_TEXT_OFFSET;
26265
26266 - EXCEPTION_TABLE(16) :text = 0x9090
26267 +#ifdef CONFIG_X86_32
26268 + . = ALIGN(PAGE_SIZE);
26269 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26270 +
26271 +#ifdef CONFIG_PAX_KERNEXEC
26272 + MODULES_EXEC_VADDR = .;
26273 + BYTE(0)
26274 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26275 + . = ALIGN(HPAGE_SIZE) - 1;
26276 + MODULES_EXEC_END = .;
26277 +#endif
26278 +
26279 + } :module
26280 +#endif
26281 +
26282 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26283 + /* End of text section */
26284 + BYTE(0)
26285 + _etext = . - __KERNEL_TEXT_OFFSET;
26286 + }
26287 +
26288 +#ifdef CONFIG_X86_32
26289 + . = ALIGN(PAGE_SIZE);
26290 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26291 + . = ALIGN(PAGE_SIZE);
26292 + *(.empty_zero_page)
26293 + *(.initial_pg_fixmap)
26294 + *(.initial_pg_pmd)
26295 + *(.initial_page_table)
26296 + *(.swapper_pg_dir)
26297 + } :rodata
26298 +#endif
26299 +
26300 + . = ALIGN(PAGE_SIZE);
26301 + NOTES :rodata :note
26302 +
26303 + EXCEPTION_TABLE(16) :rodata
26304
26305 #if defined(CONFIG_DEBUG_RODATA)
26306 /* .text should occupy whole number of pages */
26307 @@ -122,16 +176,20 @@ SECTIONS
26308
26309 /* Data */
26310 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26311 +
26312 +#ifdef CONFIG_PAX_KERNEXEC
26313 + . = ALIGN(HPAGE_SIZE);
26314 +#else
26315 + . = ALIGN(PAGE_SIZE);
26316 +#endif
26317 +
26318 /* Start of data section */
26319 _sdata = .;
26320
26321 /* init_task */
26322 INIT_TASK_DATA(THREAD_SIZE)
26323
26324 -#ifdef CONFIG_X86_32
26325 - /* 32 bit has nosave before _edata */
26326 NOSAVE_DATA
26327 -#endif
26328
26329 PAGE_ALIGNED_DATA(PAGE_SIZE)
26330
26331 @@ -172,12 +230,19 @@ SECTIONS
26332 #endif /* CONFIG_X86_64 */
26333
26334 /* Init code and data - will be freed after init */
26335 - . = ALIGN(PAGE_SIZE);
26336 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26337 + BYTE(0)
26338 +
26339 +#ifdef CONFIG_PAX_KERNEXEC
26340 + . = ALIGN(HPAGE_SIZE);
26341 +#else
26342 + . = ALIGN(PAGE_SIZE);
26343 +#endif
26344 +
26345 __init_begin = .; /* paired with __init_end */
26346 - }
26347 + } :init.begin
26348
26349 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26350 +#ifdef CONFIG_SMP
26351 /*
26352 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26353 * output PHDR, so the next output section - .init.text - should
26354 @@ -186,12 +251,27 @@ SECTIONS
26355 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26356 #endif
26357
26358 - INIT_TEXT_SECTION(PAGE_SIZE)
26359 -#ifdef CONFIG_X86_64
26360 - :init
26361 -#endif
26362 + . = ALIGN(PAGE_SIZE);
26363 + init_begin = .;
26364 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26365 + VMLINUX_SYMBOL(_sinittext) = .;
26366 + INIT_TEXT
26367 + VMLINUX_SYMBOL(_einittext) = .;
26368 + . = ALIGN(PAGE_SIZE);
26369 + } :text.init
26370
26371 - INIT_DATA_SECTION(16)
26372 + /*
26373 + * .exit.text is discard at runtime, not link time, to deal with
26374 + * references from .altinstructions and .eh_frame
26375 + */
26376 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26377 + EXIT_TEXT
26378 + . = ALIGN(16);
26379 + } :text.exit
26380 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26381 +
26382 + . = ALIGN(PAGE_SIZE);
26383 + INIT_DATA_SECTION(16) :init
26384
26385 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26386 __x86_cpu_dev_start = .;
26387 @@ -253,19 +333,12 @@ SECTIONS
26388 }
26389
26390 . = ALIGN(8);
26391 - /*
26392 - * .exit.text is discard at runtime, not link time, to deal with
26393 - * references from .altinstructions and .eh_frame
26394 - */
26395 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26396 - EXIT_TEXT
26397 - }
26398
26399 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26400 EXIT_DATA
26401 }
26402
26403 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26404 +#ifndef CONFIG_SMP
26405 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26406 #endif
26407
26408 @@ -284,16 +357,10 @@ SECTIONS
26409 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26410 __smp_locks = .;
26411 *(.smp_locks)
26412 - . = ALIGN(PAGE_SIZE);
26413 __smp_locks_end = .;
26414 + . = ALIGN(PAGE_SIZE);
26415 }
26416
26417 -#ifdef CONFIG_X86_64
26418 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26419 - NOSAVE_DATA
26420 - }
26421 -#endif
26422 -
26423 /* BSS */
26424 . = ALIGN(PAGE_SIZE);
26425 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26426 @@ -309,6 +376,7 @@ SECTIONS
26427 __brk_base = .;
26428 . += 64 * 1024; /* 64k alignment slop space */
26429 *(.brk_reservation) /* areas brk users have reserved */
26430 + . = ALIGN(HPAGE_SIZE);
26431 __brk_limit = .;
26432 }
26433
26434 @@ -335,13 +403,12 @@ SECTIONS
26435 * for the boot processor.
26436 */
26437 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26438 -INIT_PER_CPU(gdt_page);
26439 INIT_PER_CPU(irq_stack_union);
26440
26441 /*
26442 * Build-time check on the image size:
26443 */
26444 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26445 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26446 "kernel image bigger than KERNEL_IMAGE_SIZE");
26447
26448 #ifdef CONFIG_SMP
26449 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26450 index 1f96f93..d5c8f7a 100644
26451 --- a/arch/x86/kernel/vsyscall_64.c
26452 +++ b/arch/x86/kernel/vsyscall_64.c
26453 @@ -56,15 +56,13 @@
26454 DEFINE_VVAR(int, vgetcpu_mode);
26455 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26456
26457 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26458 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26459
26460 static int __init vsyscall_setup(char *str)
26461 {
26462 if (str) {
26463 if (!strcmp("emulate", str))
26464 vsyscall_mode = EMULATE;
26465 - else if (!strcmp("native", str))
26466 - vsyscall_mode = NATIVE;
26467 else if (!strcmp("none", str))
26468 vsyscall_mode = NONE;
26469 else
26470 @@ -323,8 +321,7 @@ do_ret:
26471 return true;
26472
26473 sigsegv:
26474 - force_sig(SIGSEGV, current);
26475 - return true;
26476 + do_group_exit(SIGKILL);
26477 }
26478
26479 /*
26480 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26481 extern char __vvar_page;
26482 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26483
26484 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26485 - vsyscall_mode == NATIVE
26486 - ? PAGE_KERNEL_VSYSCALL
26487 - : PAGE_KERNEL_VVAR);
26488 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26489 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26490 (unsigned long)VSYSCALL_START);
26491
26492 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26493 index b014d94..e775258 100644
26494 --- a/arch/x86/kernel/x8664_ksyms_64.c
26495 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26496 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26497 EXPORT_SYMBOL(copy_user_generic_unrolled);
26498 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26499 EXPORT_SYMBOL(__copy_user_nocache);
26500 -EXPORT_SYMBOL(_copy_from_user);
26501 -EXPORT_SYMBOL(_copy_to_user);
26502
26503 EXPORT_SYMBOL(copy_page);
26504 EXPORT_SYMBOL(clear_page);
26505 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26506 #ifndef CONFIG_PARAVIRT
26507 EXPORT_SYMBOL(native_load_gs_index);
26508 #endif
26509 +
26510 +#ifdef CONFIG_PAX_PER_CPU_PGD
26511 +EXPORT_SYMBOL(cpu_pgd);
26512 +#endif
26513 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26514 index 5f24c71..1dadf09 100644
26515 --- a/arch/x86/kernel/x86_init.c
26516 +++ b/arch/x86/kernel/x86_init.c
26517 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26518 static void default_nmi_init(void) { };
26519 static int default_i8042_detect(void) { return 1; };
26520
26521 -struct x86_platform_ops x86_platform = {
26522 +struct x86_platform_ops x86_platform __read_only = {
26523 .calibrate_tsc = native_calibrate_tsc,
26524 .get_wallclock = mach_get_cmos_time,
26525 .set_wallclock = mach_set_rtc_mmss,
26526 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26527 };
26528
26529 EXPORT_SYMBOL_GPL(x86_platform);
26530 -struct x86_msi_ops x86_msi = {
26531 +struct x86_msi_ops x86_msi __read_only = {
26532 .setup_msi_irqs = native_setup_msi_irqs,
26533 .compose_msi_msg = native_compose_msi_msg,
26534 .teardown_msi_irq = native_teardown_msi_irq,
26535 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26536 .setup_hpet_msi = default_setup_hpet_msi,
26537 };
26538
26539 -struct x86_io_apic_ops x86_io_apic_ops = {
26540 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26541 .init = native_io_apic_init_mappings,
26542 .read = native_io_apic_read,
26543 .write = native_io_apic_write,
26544 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26545 index 422fd82..c3687ca 100644
26546 --- a/arch/x86/kernel/xsave.c
26547 +++ b/arch/x86/kernel/xsave.c
26548 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26549 {
26550 int err;
26551
26552 + buf = (struct xsave_struct __user *)____m(buf);
26553 if (use_xsave())
26554 err = xsave_user(buf);
26555 else if (use_fxsr())
26556 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26557 */
26558 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26559 {
26560 + buf = (void __user *)____m(buf);
26561 if (use_xsave()) {
26562 if ((unsigned long)buf % 64 || fx_only) {
26563 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26564 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26565 index a20ecb5..d0e2194 100644
26566 --- a/arch/x86/kvm/cpuid.c
26567 +++ b/arch/x86/kvm/cpuid.c
26568 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26569 struct kvm_cpuid2 *cpuid,
26570 struct kvm_cpuid_entry2 __user *entries)
26571 {
26572 - int r;
26573 + int r, i;
26574
26575 r = -E2BIG;
26576 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26577 goto out;
26578 r = -EFAULT;
26579 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26580 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26581 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26582 goto out;
26583 + for (i = 0; i < cpuid->nent; ++i) {
26584 + struct kvm_cpuid_entry2 cpuid_entry;
26585 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26586 + goto out;
26587 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26588 + }
26589 vcpu->arch.cpuid_nent = cpuid->nent;
26590 kvm_apic_set_version(vcpu);
26591 kvm_x86_ops->cpuid_update(vcpu);
26592 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26593 struct kvm_cpuid2 *cpuid,
26594 struct kvm_cpuid_entry2 __user *entries)
26595 {
26596 - int r;
26597 + int r, i;
26598
26599 r = -E2BIG;
26600 if (cpuid->nent < vcpu->arch.cpuid_nent)
26601 goto out;
26602 r = -EFAULT;
26603 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26604 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26605 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26606 goto out;
26607 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26608 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26609 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26610 + goto out;
26611 + }
26612 return 0;
26613
26614 out:
26615 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26616 index afc1124..3e431f2 100644
26617 --- a/arch/x86/kvm/lapic.c
26618 +++ b/arch/x86/kvm/lapic.c
26619 @@ -55,7 +55,7 @@
26620 #define APIC_BUS_CYCLE_NS 1
26621
26622 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26623 -#define apic_debug(fmt, arg...)
26624 +#define apic_debug(fmt, arg...) do {} while (0)
26625
26626 #define APIC_LVT_NUM 6
26627 /* 14 is the version for Xeon and Pentium 8.4.8*/
26628 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26629 index 7769699..c8aca4a7f 100644
26630 --- a/arch/x86/kvm/paging_tmpl.h
26631 +++ b/arch/x86/kvm/paging_tmpl.h
26632 @@ -208,7 +208,7 @@ retry_walk:
26633 if (unlikely(kvm_is_error_hva(host_addr)))
26634 goto error;
26635
26636 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26637 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26638 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26639 goto error;
26640 walker->ptep_user[walker->level - 1] = ptep_user;
26641 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26642 index c0bc803..6837a50 100644
26643 --- a/arch/x86/kvm/svm.c
26644 +++ b/arch/x86/kvm/svm.c
26645 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26646 int cpu = raw_smp_processor_id();
26647
26648 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26649 +
26650 + pax_open_kernel();
26651 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26652 + pax_close_kernel();
26653 +
26654 load_TR_desc();
26655 }
26656
26657 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26658 #endif
26659 #endif
26660
26661 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26662 + __set_fs(current_thread_info()->addr_limit);
26663 +#endif
26664 +
26665 reload_tss(vcpu);
26666
26667 local_irq_disable();
26668 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26669 index 064d0be..f5f758e 100644
26670 --- a/arch/x86/kvm/vmx.c
26671 +++ b/arch/x86/kvm/vmx.c
26672 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26673 #endif
26674 }
26675
26676 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26677 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26678 {
26679 vmcs_writel(field, vmcs_readl(field) & ~mask);
26680 }
26681
26682 -static void vmcs_set_bits(unsigned long field, u32 mask)
26683 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26684 {
26685 vmcs_writel(field, vmcs_readl(field) | mask);
26686 }
26687 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26688 struct desc_struct *descs;
26689
26690 descs = (void *)gdt->address;
26691 +
26692 + pax_open_kernel();
26693 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26694 + pax_close_kernel();
26695 +
26696 load_TR_desc();
26697 }
26698
26699 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26700 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26701 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26702
26703 +#ifdef CONFIG_PAX_PER_CPU_PGD
26704 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26705 +#endif
26706 +
26707 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26708 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26709 vmx->loaded_vmcs->cpu = cpu;
26710 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26711 if (!cpu_has_vmx_flexpriority())
26712 flexpriority_enabled = 0;
26713
26714 - if (!cpu_has_vmx_tpr_shadow())
26715 - kvm_x86_ops->update_cr8_intercept = NULL;
26716 + if (!cpu_has_vmx_tpr_shadow()) {
26717 + pax_open_kernel();
26718 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26719 + pax_close_kernel();
26720 + }
26721
26722 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26723 kvm_disable_largepages();
26724 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26725 if (!cpu_has_vmx_apicv())
26726 enable_apicv = 0;
26727
26728 + pax_open_kernel();
26729 if (enable_apicv)
26730 - kvm_x86_ops->update_cr8_intercept = NULL;
26731 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26732 else {
26733 - kvm_x86_ops->hwapic_irr_update = NULL;
26734 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26735 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26736 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26737 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26738 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26739 }
26740 + pax_close_kernel();
26741
26742 if (nested)
26743 nested_vmx_setup_ctls_msrs();
26744 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26745
26746 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26747 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26748 +
26749 +#ifndef CONFIG_PAX_PER_CPU_PGD
26750 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26751 +#endif
26752
26753 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26754 #ifdef CONFIG_X86_64
26755 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26756 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26757 vmx->host_idt_base = dt.address;
26758
26759 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26760 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26761
26762 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26763 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26764 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26765 "jmp 2f \n\t"
26766 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26767 "2: "
26768 +
26769 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26770 + "ljmp %[cs],$3f\n\t"
26771 + "3: "
26772 +#endif
26773 +
26774 /* Save guest registers, load host registers, keep flags */
26775 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26776 "pop %0 \n\t"
26777 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26778 #endif
26779 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26780 [wordsize]"i"(sizeof(ulong))
26781 +
26782 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26783 + ,[cs]"i"(__KERNEL_CS)
26784 +#endif
26785 +
26786 : "cc", "memory"
26787 #ifdef CONFIG_X86_64
26788 , "rax", "rbx", "rdi", "rsi"
26789 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26790 if (debugctlmsr)
26791 update_debugctlmsr(debugctlmsr);
26792
26793 -#ifndef CONFIG_X86_64
26794 +#ifdef CONFIG_X86_32
26795 /*
26796 * The sysexit path does not restore ds/es, so we must set them to
26797 * a reasonable value ourselves.
26798 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26799 * may be executed in interrupt context, which saves and restore segments
26800 * around it, nullifying its effect.
26801 */
26802 - loadsegment(ds, __USER_DS);
26803 - loadsegment(es, __USER_DS);
26804 + loadsegment(ds, __KERNEL_DS);
26805 + loadsegment(es, __KERNEL_DS);
26806 + loadsegment(ss, __KERNEL_DS);
26807 +
26808 +#ifdef CONFIG_PAX_KERNEXEC
26809 + loadsegment(fs, __KERNEL_PERCPU);
26810 +#endif
26811 +
26812 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26813 + __set_fs(current_thread_info()->addr_limit);
26814 +#endif
26815 +
26816 #endif
26817
26818 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26819 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26820 index d21bce5..fdae9f1 100644
26821 --- a/arch/x86/kvm/x86.c
26822 +++ b/arch/x86/kvm/x86.c
26823 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26824 {
26825 struct kvm *kvm = vcpu->kvm;
26826 int lm = is_long_mode(vcpu);
26827 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26828 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26829 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26830 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26831 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26832 : kvm->arch.xen_hvm_config.blob_size_32;
26833 u32 page_num = data & ~PAGE_MASK;
26834 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26835 if (n < msr_list.nmsrs)
26836 goto out;
26837 r = -EFAULT;
26838 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26839 + goto out;
26840 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26841 num_msrs_to_save * sizeof(u32)))
26842 goto out;
26843 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26844 };
26845 #endif
26846
26847 -int kvm_arch_init(void *opaque)
26848 +int kvm_arch_init(const void *opaque)
26849 {
26850 int r;
26851 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26852 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26853 index 6a22c19..1763f04 100644
26854 --- a/arch/x86/lguest/boot.c
26855 +++ b/arch/x86/lguest/boot.c
26856 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26857 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26858 * Launcher to reboot us.
26859 */
26860 -static void lguest_restart(char *reason)
26861 +static __noreturn void lguest_restart(char *reason)
26862 {
26863 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26864 + BUG();
26865 }
26866
26867 /*G:050
26868 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26869 index 00933d5..3a64af9 100644
26870 --- a/arch/x86/lib/atomic64_386_32.S
26871 +++ b/arch/x86/lib/atomic64_386_32.S
26872 @@ -48,6 +48,10 @@ BEGIN(read)
26873 movl (v), %eax
26874 movl 4(v), %edx
26875 RET_ENDP
26876 +BEGIN(read_unchecked)
26877 + movl (v), %eax
26878 + movl 4(v), %edx
26879 +RET_ENDP
26880 #undef v
26881
26882 #define v %esi
26883 @@ -55,6 +59,10 @@ BEGIN(set)
26884 movl %ebx, (v)
26885 movl %ecx, 4(v)
26886 RET_ENDP
26887 +BEGIN(set_unchecked)
26888 + movl %ebx, (v)
26889 + movl %ecx, 4(v)
26890 +RET_ENDP
26891 #undef v
26892
26893 #define v %esi
26894 @@ -70,6 +78,20 @@ RET_ENDP
26895 BEGIN(add)
26896 addl %eax, (v)
26897 adcl %edx, 4(v)
26898 +
26899 +#ifdef CONFIG_PAX_REFCOUNT
26900 + jno 0f
26901 + subl %eax, (v)
26902 + sbbl %edx, 4(v)
26903 + int $4
26904 +0:
26905 + _ASM_EXTABLE(0b, 0b)
26906 +#endif
26907 +
26908 +RET_ENDP
26909 +BEGIN(add_unchecked)
26910 + addl %eax, (v)
26911 + adcl %edx, 4(v)
26912 RET_ENDP
26913 #undef v
26914
26915 @@ -77,6 +99,24 @@ RET_ENDP
26916 BEGIN(add_return)
26917 addl (v), %eax
26918 adcl 4(v), %edx
26919 +
26920 +#ifdef CONFIG_PAX_REFCOUNT
26921 + into
26922 +1234:
26923 + _ASM_EXTABLE(1234b, 2f)
26924 +#endif
26925 +
26926 + movl %eax, (v)
26927 + movl %edx, 4(v)
26928 +
26929 +#ifdef CONFIG_PAX_REFCOUNT
26930 +2:
26931 +#endif
26932 +
26933 +RET_ENDP
26934 +BEGIN(add_return_unchecked)
26935 + addl (v), %eax
26936 + adcl 4(v), %edx
26937 movl %eax, (v)
26938 movl %edx, 4(v)
26939 RET_ENDP
26940 @@ -86,6 +126,20 @@ RET_ENDP
26941 BEGIN(sub)
26942 subl %eax, (v)
26943 sbbl %edx, 4(v)
26944 +
26945 +#ifdef CONFIG_PAX_REFCOUNT
26946 + jno 0f
26947 + addl %eax, (v)
26948 + adcl %edx, 4(v)
26949 + int $4
26950 +0:
26951 + _ASM_EXTABLE(0b, 0b)
26952 +#endif
26953 +
26954 +RET_ENDP
26955 +BEGIN(sub_unchecked)
26956 + subl %eax, (v)
26957 + sbbl %edx, 4(v)
26958 RET_ENDP
26959 #undef v
26960
26961 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26962 sbbl $0, %edx
26963 addl (v), %eax
26964 adcl 4(v), %edx
26965 +
26966 +#ifdef CONFIG_PAX_REFCOUNT
26967 + into
26968 +1234:
26969 + _ASM_EXTABLE(1234b, 2f)
26970 +#endif
26971 +
26972 + movl %eax, (v)
26973 + movl %edx, 4(v)
26974 +
26975 +#ifdef CONFIG_PAX_REFCOUNT
26976 +2:
26977 +#endif
26978 +
26979 +RET_ENDP
26980 +BEGIN(sub_return_unchecked)
26981 + negl %edx
26982 + negl %eax
26983 + sbbl $0, %edx
26984 + addl (v), %eax
26985 + adcl 4(v), %edx
26986 movl %eax, (v)
26987 movl %edx, 4(v)
26988 RET_ENDP
26989 @@ -105,6 +180,20 @@ RET_ENDP
26990 BEGIN(inc)
26991 addl $1, (v)
26992 adcl $0, 4(v)
26993 +
26994 +#ifdef CONFIG_PAX_REFCOUNT
26995 + jno 0f
26996 + subl $1, (v)
26997 + sbbl $0, 4(v)
26998 + int $4
26999 +0:
27000 + _ASM_EXTABLE(0b, 0b)
27001 +#endif
27002 +
27003 +RET_ENDP
27004 +BEGIN(inc_unchecked)
27005 + addl $1, (v)
27006 + adcl $0, 4(v)
27007 RET_ENDP
27008 #undef v
27009
27010 @@ -114,6 +203,26 @@ BEGIN(inc_return)
27011 movl 4(v), %edx
27012 addl $1, %eax
27013 adcl $0, %edx
27014 +
27015 +#ifdef CONFIG_PAX_REFCOUNT
27016 + into
27017 +1234:
27018 + _ASM_EXTABLE(1234b, 2f)
27019 +#endif
27020 +
27021 + movl %eax, (v)
27022 + movl %edx, 4(v)
27023 +
27024 +#ifdef CONFIG_PAX_REFCOUNT
27025 +2:
27026 +#endif
27027 +
27028 +RET_ENDP
27029 +BEGIN(inc_return_unchecked)
27030 + movl (v), %eax
27031 + movl 4(v), %edx
27032 + addl $1, %eax
27033 + adcl $0, %edx
27034 movl %eax, (v)
27035 movl %edx, 4(v)
27036 RET_ENDP
27037 @@ -123,6 +232,20 @@ RET_ENDP
27038 BEGIN(dec)
27039 subl $1, (v)
27040 sbbl $0, 4(v)
27041 +
27042 +#ifdef CONFIG_PAX_REFCOUNT
27043 + jno 0f
27044 + addl $1, (v)
27045 + adcl $0, 4(v)
27046 + int $4
27047 +0:
27048 + _ASM_EXTABLE(0b, 0b)
27049 +#endif
27050 +
27051 +RET_ENDP
27052 +BEGIN(dec_unchecked)
27053 + subl $1, (v)
27054 + sbbl $0, 4(v)
27055 RET_ENDP
27056 #undef v
27057
27058 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27059 movl 4(v), %edx
27060 subl $1, %eax
27061 sbbl $0, %edx
27062 +
27063 +#ifdef CONFIG_PAX_REFCOUNT
27064 + into
27065 +1234:
27066 + _ASM_EXTABLE(1234b, 2f)
27067 +#endif
27068 +
27069 + movl %eax, (v)
27070 + movl %edx, 4(v)
27071 +
27072 +#ifdef CONFIG_PAX_REFCOUNT
27073 +2:
27074 +#endif
27075 +
27076 +RET_ENDP
27077 +BEGIN(dec_return_unchecked)
27078 + movl (v), %eax
27079 + movl 4(v), %edx
27080 + subl $1, %eax
27081 + sbbl $0, %edx
27082 movl %eax, (v)
27083 movl %edx, 4(v)
27084 RET_ENDP
27085 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27086 adcl %edx, %edi
27087 addl (v), %eax
27088 adcl 4(v), %edx
27089 +
27090 +#ifdef CONFIG_PAX_REFCOUNT
27091 + into
27092 +1234:
27093 + _ASM_EXTABLE(1234b, 2f)
27094 +#endif
27095 +
27096 cmpl %eax, %ecx
27097 je 3f
27098 1:
27099 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27100 1:
27101 addl $1, %eax
27102 adcl $0, %edx
27103 +
27104 +#ifdef CONFIG_PAX_REFCOUNT
27105 + into
27106 +1234:
27107 + _ASM_EXTABLE(1234b, 2f)
27108 +#endif
27109 +
27110 movl %eax, (v)
27111 movl %edx, 4(v)
27112 movl $1, %eax
27113 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27114 movl 4(v), %edx
27115 subl $1, %eax
27116 sbbl $0, %edx
27117 +
27118 +#ifdef CONFIG_PAX_REFCOUNT
27119 + into
27120 +1234:
27121 + _ASM_EXTABLE(1234b, 1f)
27122 +#endif
27123 +
27124 js 1f
27125 movl %eax, (v)
27126 movl %edx, 4(v)
27127 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27128 index f5cc9eb..51fa319 100644
27129 --- a/arch/x86/lib/atomic64_cx8_32.S
27130 +++ b/arch/x86/lib/atomic64_cx8_32.S
27131 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27132 CFI_STARTPROC
27133
27134 read64 %ecx
27135 + pax_force_retaddr
27136 ret
27137 CFI_ENDPROC
27138 ENDPROC(atomic64_read_cx8)
27139
27140 +ENTRY(atomic64_read_unchecked_cx8)
27141 + CFI_STARTPROC
27142 +
27143 + read64 %ecx
27144 + pax_force_retaddr
27145 + ret
27146 + CFI_ENDPROC
27147 +ENDPROC(atomic64_read_unchecked_cx8)
27148 +
27149 ENTRY(atomic64_set_cx8)
27150 CFI_STARTPROC
27151
27152 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27153 cmpxchg8b (%esi)
27154 jne 1b
27155
27156 + pax_force_retaddr
27157 ret
27158 CFI_ENDPROC
27159 ENDPROC(atomic64_set_cx8)
27160
27161 +ENTRY(atomic64_set_unchecked_cx8)
27162 + CFI_STARTPROC
27163 +
27164 +1:
27165 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27166 + * are atomic on 586 and newer */
27167 + cmpxchg8b (%esi)
27168 + jne 1b
27169 +
27170 + pax_force_retaddr
27171 + ret
27172 + CFI_ENDPROC
27173 +ENDPROC(atomic64_set_unchecked_cx8)
27174 +
27175 ENTRY(atomic64_xchg_cx8)
27176 CFI_STARTPROC
27177
27178 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27179 cmpxchg8b (%esi)
27180 jne 1b
27181
27182 + pax_force_retaddr
27183 ret
27184 CFI_ENDPROC
27185 ENDPROC(atomic64_xchg_cx8)
27186
27187 -.macro addsub_return func ins insc
27188 -ENTRY(atomic64_\func\()_return_cx8)
27189 +.macro addsub_return func ins insc unchecked=""
27190 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27191 CFI_STARTPROC
27192 SAVE ebp
27193 SAVE ebx
27194 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27195 movl %edx, %ecx
27196 \ins\()l %esi, %ebx
27197 \insc\()l %edi, %ecx
27198 +
27199 +.ifb \unchecked
27200 +#ifdef CONFIG_PAX_REFCOUNT
27201 + into
27202 +2:
27203 + _ASM_EXTABLE(2b, 3f)
27204 +#endif
27205 +.endif
27206 +
27207 LOCK_PREFIX
27208 cmpxchg8b (%ebp)
27209 jne 1b
27210 -
27211 -10:
27212 movl %ebx, %eax
27213 movl %ecx, %edx
27214 +
27215 +.ifb \unchecked
27216 +#ifdef CONFIG_PAX_REFCOUNT
27217 +3:
27218 +#endif
27219 +.endif
27220 +
27221 RESTORE edi
27222 RESTORE esi
27223 RESTORE ebx
27224 RESTORE ebp
27225 + pax_force_retaddr
27226 ret
27227 CFI_ENDPROC
27228 -ENDPROC(atomic64_\func\()_return_cx8)
27229 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27230 .endm
27231
27232 addsub_return add add adc
27233 addsub_return sub sub sbb
27234 +addsub_return add add adc _unchecked
27235 +addsub_return sub sub sbb _unchecked
27236
27237 -.macro incdec_return func ins insc
27238 -ENTRY(atomic64_\func\()_return_cx8)
27239 +.macro incdec_return func ins insc unchecked=""
27240 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27241 CFI_STARTPROC
27242 SAVE ebx
27243
27244 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27245 movl %edx, %ecx
27246 \ins\()l $1, %ebx
27247 \insc\()l $0, %ecx
27248 +
27249 +.ifb \unchecked
27250 +#ifdef CONFIG_PAX_REFCOUNT
27251 + into
27252 +2:
27253 + _ASM_EXTABLE(2b, 3f)
27254 +#endif
27255 +.endif
27256 +
27257 LOCK_PREFIX
27258 cmpxchg8b (%esi)
27259 jne 1b
27260
27261 -10:
27262 movl %ebx, %eax
27263 movl %ecx, %edx
27264 +
27265 +.ifb \unchecked
27266 +#ifdef CONFIG_PAX_REFCOUNT
27267 +3:
27268 +#endif
27269 +.endif
27270 +
27271 RESTORE ebx
27272 + pax_force_retaddr
27273 ret
27274 CFI_ENDPROC
27275 -ENDPROC(atomic64_\func\()_return_cx8)
27276 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27277 .endm
27278
27279 incdec_return inc add adc
27280 incdec_return dec sub sbb
27281 +incdec_return inc add adc _unchecked
27282 +incdec_return dec sub sbb _unchecked
27283
27284 ENTRY(atomic64_dec_if_positive_cx8)
27285 CFI_STARTPROC
27286 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27287 movl %edx, %ecx
27288 subl $1, %ebx
27289 sbb $0, %ecx
27290 +
27291 +#ifdef CONFIG_PAX_REFCOUNT
27292 + into
27293 +1234:
27294 + _ASM_EXTABLE(1234b, 2f)
27295 +#endif
27296 +
27297 js 2f
27298 LOCK_PREFIX
27299 cmpxchg8b (%esi)
27300 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27301 movl %ebx, %eax
27302 movl %ecx, %edx
27303 RESTORE ebx
27304 + pax_force_retaddr
27305 ret
27306 CFI_ENDPROC
27307 ENDPROC(atomic64_dec_if_positive_cx8)
27308 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27309 movl %edx, %ecx
27310 addl %ebp, %ebx
27311 adcl %edi, %ecx
27312 +
27313 +#ifdef CONFIG_PAX_REFCOUNT
27314 + into
27315 +1234:
27316 + _ASM_EXTABLE(1234b, 3f)
27317 +#endif
27318 +
27319 LOCK_PREFIX
27320 cmpxchg8b (%esi)
27321 jne 1b
27322 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27323 CFI_ADJUST_CFA_OFFSET -8
27324 RESTORE ebx
27325 RESTORE ebp
27326 + pax_force_retaddr
27327 ret
27328 4:
27329 cmpl %edx, 4(%esp)
27330 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27331 xorl %ecx, %ecx
27332 addl $1, %ebx
27333 adcl %edx, %ecx
27334 +
27335 +#ifdef CONFIG_PAX_REFCOUNT
27336 + into
27337 +1234:
27338 + _ASM_EXTABLE(1234b, 3f)
27339 +#endif
27340 +
27341 LOCK_PREFIX
27342 cmpxchg8b (%esi)
27343 jne 1b
27344 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27345 movl $1, %eax
27346 3:
27347 RESTORE ebx
27348 + pax_force_retaddr
27349 ret
27350 CFI_ENDPROC
27351 ENDPROC(atomic64_inc_not_zero_cx8)
27352 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27353 index e78b8ee..7e173a8 100644
27354 --- a/arch/x86/lib/checksum_32.S
27355 +++ b/arch/x86/lib/checksum_32.S
27356 @@ -29,7 +29,8 @@
27357 #include <asm/dwarf2.h>
27358 #include <asm/errno.h>
27359 #include <asm/asm.h>
27360 -
27361 +#include <asm/segment.h>
27362 +
27363 /*
27364 * computes a partial checksum, e.g. for TCP/UDP fragments
27365 */
27366 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27367
27368 #define ARGBASE 16
27369 #define FP 12
27370 -
27371 -ENTRY(csum_partial_copy_generic)
27372 +
27373 +ENTRY(csum_partial_copy_generic_to_user)
27374 CFI_STARTPROC
27375 +
27376 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27377 + pushl_cfi %gs
27378 + popl_cfi %es
27379 + jmp csum_partial_copy_generic
27380 +#endif
27381 +
27382 +ENTRY(csum_partial_copy_generic_from_user)
27383 +
27384 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27385 + pushl_cfi %gs
27386 + popl_cfi %ds
27387 +#endif
27388 +
27389 +ENTRY(csum_partial_copy_generic)
27390 subl $4,%esp
27391 CFI_ADJUST_CFA_OFFSET 4
27392 pushl_cfi %edi
27393 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27394 jmp 4f
27395 SRC(1: movw (%esi), %bx )
27396 addl $2, %esi
27397 -DST( movw %bx, (%edi) )
27398 +DST( movw %bx, %es:(%edi) )
27399 addl $2, %edi
27400 addw %bx, %ax
27401 adcl $0, %eax
27402 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27403 SRC(1: movl (%esi), %ebx )
27404 SRC( movl 4(%esi), %edx )
27405 adcl %ebx, %eax
27406 -DST( movl %ebx, (%edi) )
27407 +DST( movl %ebx, %es:(%edi) )
27408 adcl %edx, %eax
27409 -DST( movl %edx, 4(%edi) )
27410 +DST( movl %edx, %es:4(%edi) )
27411
27412 SRC( movl 8(%esi), %ebx )
27413 SRC( movl 12(%esi), %edx )
27414 adcl %ebx, %eax
27415 -DST( movl %ebx, 8(%edi) )
27416 +DST( movl %ebx, %es:8(%edi) )
27417 adcl %edx, %eax
27418 -DST( movl %edx, 12(%edi) )
27419 +DST( movl %edx, %es:12(%edi) )
27420
27421 SRC( movl 16(%esi), %ebx )
27422 SRC( movl 20(%esi), %edx )
27423 adcl %ebx, %eax
27424 -DST( movl %ebx, 16(%edi) )
27425 +DST( movl %ebx, %es:16(%edi) )
27426 adcl %edx, %eax
27427 -DST( movl %edx, 20(%edi) )
27428 +DST( movl %edx, %es:20(%edi) )
27429
27430 SRC( movl 24(%esi), %ebx )
27431 SRC( movl 28(%esi), %edx )
27432 adcl %ebx, %eax
27433 -DST( movl %ebx, 24(%edi) )
27434 +DST( movl %ebx, %es:24(%edi) )
27435 adcl %edx, %eax
27436 -DST( movl %edx, 28(%edi) )
27437 +DST( movl %edx, %es:28(%edi) )
27438
27439 lea 32(%esi), %esi
27440 lea 32(%edi), %edi
27441 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27442 shrl $2, %edx # This clears CF
27443 SRC(3: movl (%esi), %ebx )
27444 adcl %ebx, %eax
27445 -DST( movl %ebx, (%edi) )
27446 +DST( movl %ebx, %es:(%edi) )
27447 lea 4(%esi), %esi
27448 lea 4(%edi), %edi
27449 dec %edx
27450 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27451 jb 5f
27452 SRC( movw (%esi), %cx )
27453 leal 2(%esi), %esi
27454 -DST( movw %cx, (%edi) )
27455 +DST( movw %cx, %es:(%edi) )
27456 leal 2(%edi), %edi
27457 je 6f
27458 shll $16,%ecx
27459 SRC(5: movb (%esi), %cl )
27460 -DST( movb %cl, (%edi) )
27461 +DST( movb %cl, %es:(%edi) )
27462 6: addl %ecx, %eax
27463 adcl $0, %eax
27464 7:
27465 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27466
27467 6001:
27468 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27469 - movl $-EFAULT, (%ebx)
27470 + movl $-EFAULT, %ss:(%ebx)
27471
27472 # zero the complete destination - computing the rest
27473 # is too much work
27474 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27475
27476 6002:
27477 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27478 - movl $-EFAULT,(%ebx)
27479 + movl $-EFAULT,%ss:(%ebx)
27480 jmp 5000b
27481
27482 .previous
27483
27484 + pushl_cfi %ss
27485 + popl_cfi %ds
27486 + pushl_cfi %ss
27487 + popl_cfi %es
27488 popl_cfi %ebx
27489 CFI_RESTORE ebx
27490 popl_cfi %esi
27491 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27492 popl_cfi %ecx # equivalent to addl $4,%esp
27493 ret
27494 CFI_ENDPROC
27495 -ENDPROC(csum_partial_copy_generic)
27496 +ENDPROC(csum_partial_copy_generic_to_user)
27497
27498 #else
27499
27500 /* Version for PentiumII/PPro */
27501
27502 #define ROUND1(x) \
27503 + nop; nop; nop; \
27504 SRC(movl x(%esi), %ebx ) ; \
27505 addl %ebx, %eax ; \
27506 - DST(movl %ebx, x(%edi) ) ;
27507 + DST(movl %ebx, %es:x(%edi)) ;
27508
27509 #define ROUND(x) \
27510 + nop; nop; nop; \
27511 SRC(movl x(%esi), %ebx ) ; \
27512 adcl %ebx, %eax ; \
27513 - DST(movl %ebx, x(%edi) ) ;
27514 + DST(movl %ebx, %es:x(%edi)) ;
27515
27516 #define ARGBASE 12
27517 -
27518 -ENTRY(csum_partial_copy_generic)
27519 +
27520 +ENTRY(csum_partial_copy_generic_to_user)
27521 CFI_STARTPROC
27522 +
27523 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27524 + pushl_cfi %gs
27525 + popl_cfi %es
27526 + jmp csum_partial_copy_generic
27527 +#endif
27528 +
27529 +ENTRY(csum_partial_copy_generic_from_user)
27530 +
27531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27532 + pushl_cfi %gs
27533 + popl_cfi %ds
27534 +#endif
27535 +
27536 +ENTRY(csum_partial_copy_generic)
27537 pushl_cfi %ebx
27538 CFI_REL_OFFSET ebx, 0
27539 pushl_cfi %edi
27540 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27541 subl %ebx, %edi
27542 lea -1(%esi),%edx
27543 andl $-32,%edx
27544 - lea 3f(%ebx,%ebx), %ebx
27545 + lea 3f(%ebx,%ebx,2), %ebx
27546 testl %esi, %esi
27547 jmp *%ebx
27548 1: addl $64,%esi
27549 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27550 jb 5f
27551 SRC( movw (%esi), %dx )
27552 leal 2(%esi), %esi
27553 -DST( movw %dx, (%edi) )
27554 +DST( movw %dx, %es:(%edi) )
27555 leal 2(%edi), %edi
27556 je 6f
27557 shll $16,%edx
27558 5:
27559 SRC( movb (%esi), %dl )
27560 -DST( movb %dl, (%edi) )
27561 +DST( movb %dl, %es:(%edi) )
27562 6: addl %edx, %eax
27563 adcl $0, %eax
27564 7:
27565 .section .fixup, "ax"
27566 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27567 - movl $-EFAULT, (%ebx)
27568 + movl $-EFAULT, %ss:(%ebx)
27569 # zero the complete destination (computing the rest is too much work)
27570 movl ARGBASE+8(%esp),%edi # dst
27571 movl ARGBASE+12(%esp),%ecx # len
27572 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27573 rep; stosb
27574 jmp 7b
27575 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27576 - movl $-EFAULT, (%ebx)
27577 + movl $-EFAULT, %ss:(%ebx)
27578 jmp 7b
27579 .previous
27580
27581 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27582 + pushl_cfi %ss
27583 + popl_cfi %ds
27584 + pushl_cfi %ss
27585 + popl_cfi %es
27586 +#endif
27587 +
27588 popl_cfi %esi
27589 CFI_RESTORE esi
27590 popl_cfi %edi
27591 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27592 CFI_RESTORE ebx
27593 ret
27594 CFI_ENDPROC
27595 -ENDPROC(csum_partial_copy_generic)
27596 +ENDPROC(csum_partial_copy_generic_to_user)
27597
27598 #undef ROUND
27599 #undef ROUND1
27600 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27601 index f2145cf..cea889d 100644
27602 --- a/arch/x86/lib/clear_page_64.S
27603 +++ b/arch/x86/lib/clear_page_64.S
27604 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27605 movl $4096/8,%ecx
27606 xorl %eax,%eax
27607 rep stosq
27608 + pax_force_retaddr
27609 ret
27610 CFI_ENDPROC
27611 ENDPROC(clear_page_c)
27612 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27613 movl $4096,%ecx
27614 xorl %eax,%eax
27615 rep stosb
27616 + pax_force_retaddr
27617 ret
27618 CFI_ENDPROC
27619 ENDPROC(clear_page_c_e)
27620 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27621 leaq 64(%rdi),%rdi
27622 jnz .Lloop
27623 nop
27624 + pax_force_retaddr
27625 ret
27626 CFI_ENDPROC
27627 .Lclear_page_end:
27628 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27629
27630 #include <asm/cpufeature.h>
27631
27632 - .section .altinstr_replacement,"ax"
27633 + .section .altinstr_replacement,"a"
27634 1: .byte 0xeb /* jmp <disp8> */
27635 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27636 2: .byte 0xeb /* jmp <disp8> */
27637 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27638 index 1e572c5..2a162cd 100644
27639 --- a/arch/x86/lib/cmpxchg16b_emu.S
27640 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27641 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27642
27643 popf
27644 mov $1, %al
27645 + pax_force_retaddr
27646 ret
27647
27648 not_same:
27649 popf
27650 xor %al,%al
27651 + pax_force_retaddr
27652 ret
27653
27654 CFI_ENDPROC
27655 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27656 index 176cca6..1166c50 100644
27657 --- a/arch/x86/lib/copy_page_64.S
27658 +++ b/arch/x86/lib/copy_page_64.S
27659 @@ -9,6 +9,7 @@ copy_page_rep:
27660 CFI_STARTPROC
27661 movl $4096/8, %ecx
27662 rep movsq
27663 + pax_force_retaddr
27664 ret
27665 CFI_ENDPROC
27666 ENDPROC(copy_page_rep)
27667 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27668
27669 ENTRY(copy_page)
27670 CFI_STARTPROC
27671 - subq $2*8, %rsp
27672 - CFI_ADJUST_CFA_OFFSET 2*8
27673 + subq $3*8, %rsp
27674 + CFI_ADJUST_CFA_OFFSET 3*8
27675 movq %rbx, (%rsp)
27676 CFI_REL_OFFSET rbx, 0
27677 movq %r12, 1*8(%rsp)
27678 CFI_REL_OFFSET r12, 1*8
27679 + movq %r13, 2*8(%rsp)
27680 + CFI_REL_OFFSET r13, 2*8
27681
27682 movl $(4096/64)-5, %ecx
27683 .p2align 4
27684 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27685 movq 0x8*2(%rsi), %rdx
27686 movq 0x8*3(%rsi), %r8
27687 movq 0x8*4(%rsi), %r9
27688 - movq 0x8*5(%rsi), %r10
27689 + movq 0x8*5(%rsi), %r13
27690 movq 0x8*6(%rsi), %r11
27691 movq 0x8*7(%rsi), %r12
27692
27693 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27694 movq %rdx, 0x8*2(%rdi)
27695 movq %r8, 0x8*3(%rdi)
27696 movq %r9, 0x8*4(%rdi)
27697 - movq %r10, 0x8*5(%rdi)
27698 + movq %r13, 0x8*5(%rdi)
27699 movq %r11, 0x8*6(%rdi)
27700 movq %r12, 0x8*7(%rdi)
27701
27702 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27703 movq 0x8*2(%rsi), %rdx
27704 movq 0x8*3(%rsi), %r8
27705 movq 0x8*4(%rsi), %r9
27706 - movq 0x8*5(%rsi), %r10
27707 + movq 0x8*5(%rsi), %r13
27708 movq 0x8*6(%rsi), %r11
27709 movq 0x8*7(%rsi), %r12
27710
27711 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27712 movq %rdx, 0x8*2(%rdi)
27713 movq %r8, 0x8*3(%rdi)
27714 movq %r9, 0x8*4(%rdi)
27715 - movq %r10, 0x8*5(%rdi)
27716 + movq %r13, 0x8*5(%rdi)
27717 movq %r11, 0x8*6(%rdi)
27718 movq %r12, 0x8*7(%rdi)
27719
27720 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27721 CFI_RESTORE rbx
27722 movq 1*8(%rsp), %r12
27723 CFI_RESTORE r12
27724 - addq $2*8, %rsp
27725 - CFI_ADJUST_CFA_OFFSET -2*8
27726 + movq 2*8(%rsp), %r13
27727 + CFI_RESTORE r13
27728 + addq $3*8, %rsp
27729 + CFI_ADJUST_CFA_OFFSET -3*8
27730 + pax_force_retaddr
27731 ret
27732 .Lcopy_page_end:
27733 CFI_ENDPROC
27734 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27735
27736 #include <asm/cpufeature.h>
27737
27738 - .section .altinstr_replacement,"ax"
27739 + .section .altinstr_replacement,"a"
27740 1: .byte 0xeb /* jmp <disp8> */
27741 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27742 2:
27743 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27744 index a30ca15..6b3f4e1 100644
27745 --- a/arch/x86/lib/copy_user_64.S
27746 +++ b/arch/x86/lib/copy_user_64.S
27747 @@ -18,31 +18,7 @@
27748 #include <asm/alternative-asm.h>
27749 #include <asm/asm.h>
27750 #include <asm/smap.h>
27751 -
27752 -/*
27753 - * By placing feature2 after feature1 in altinstructions section, we logically
27754 - * implement:
27755 - * If CPU has feature2, jmp to alt2 is used
27756 - * else if CPU has feature1, jmp to alt1 is used
27757 - * else jmp to orig is used.
27758 - */
27759 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27760 -0:
27761 - .byte 0xe9 /* 32bit jump */
27762 - .long \orig-1f /* by default jump to orig */
27763 -1:
27764 - .section .altinstr_replacement,"ax"
27765 -2: .byte 0xe9 /* near jump with 32bit immediate */
27766 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27767 -3: .byte 0xe9 /* near jump with 32bit immediate */
27768 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27769 - .previous
27770 -
27771 - .section .altinstructions,"a"
27772 - altinstruction_entry 0b,2b,\feature1,5,5
27773 - altinstruction_entry 0b,3b,\feature2,5,5
27774 - .previous
27775 - .endm
27776 +#include <asm/pgtable.h>
27777
27778 .macro ALIGN_DESTINATION
27779 #ifdef FIX_ALIGNMENT
27780 @@ -70,52 +46,6 @@
27781 #endif
27782 .endm
27783
27784 -/* Standard copy_to_user with segment limit checking */
27785 -ENTRY(_copy_to_user)
27786 - CFI_STARTPROC
27787 - GET_THREAD_INFO(%rax)
27788 - movq %rdi,%rcx
27789 - addq %rdx,%rcx
27790 - jc bad_to_user
27791 - cmpq TI_addr_limit(%rax),%rcx
27792 - ja bad_to_user
27793 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27794 - copy_user_generic_unrolled,copy_user_generic_string, \
27795 - copy_user_enhanced_fast_string
27796 - CFI_ENDPROC
27797 -ENDPROC(_copy_to_user)
27798 -
27799 -/* Standard copy_from_user with segment limit checking */
27800 -ENTRY(_copy_from_user)
27801 - CFI_STARTPROC
27802 - GET_THREAD_INFO(%rax)
27803 - movq %rsi,%rcx
27804 - addq %rdx,%rcx
27805 - jc bad_from_user
27806 - cmpq TI_addr_limit(%rax),%rcx
27807 - ja bad_from_user
27808 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27809 - copy_user_generic_unrolled,copy_user_generic_string, \
27810 - copy_user_enhanced_fast_string
27811 - CFI_ENDPROC
27812 -ENDPROC(_copy_from_user)
27813 -
27814 - .section .fixup,"ax"
27815 - /* must zero dest */
27816 -ENTRY(bad_from_user)
27817 -bad_from_user:
27818 - CFI_STARTPROC
27819 - movl %edx,%ecx
27820 - xorl %eax,%eax
27821 - rep
27822 - stosb
27823 -bad_to_user:
27824 - movl %edx,%eax
27825 - ret
27826 - CFI_ENDPROC
27827 -ENDPROC(bad_from_user)
27828 - .previous
27829 -
27830 /*
27831 * copy_user_generic_unrolled - memory copy with exception handling.
27832 * This version is for CPUs like P4 that don't have efficient micro
27833 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27834 */
27835 ENTRY(copy_user_generic_unrolled)
27836 CFI_STARTPROC
27837 + ASM_PAX_OPEN_USERLAND
27838 ASM_STAC
27839 cmpl $8,%edx
27840 jb 20f /* less then 8 bytes, go to byte copy loop */
27841 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27842 jz 17f
27843 1: movq (%rsi),%r8
27844 2: movq 1*8(%rsi),%r9
27845 -3: movq 2*8(%rsi),%r10
27846 +3: movq 2*8(%rsi),%rax
27847 4: movq 3*8(%rsi),%r11
27848 5: movq %r8,(%rdi)
27849 6: movq %r9,1*8(%rdi)
27850 -7: movq %r10,2*8(%rdi)
27851 +7: movq %rax,2*8(%rdi)
27852 8: movq %r11,3*8(%rdi)
27853 9: movq 4*8(%rsi),%r8
27854 10: movq 5*8(%rsi),%r9
27855 -11: movq 6*8(%rsi),%r10
27856 +11: movq 6*8(%rsi),%rax
27857 12: movq 7*8(%rsi),%r11
27858 13: movq %r8,4*8(%rdi)
27859 14: movq %r9,5*8(%rdi)
27860 -15: movq %r10,6*8(%rdi)
27861 +15: movq %rax,6*8(%rdi)
27862 16: movq %r11,7*8(%rdi)
27863 leaq 64(%rsi),%rsi
27864 leaq 64(%rdi),%rdi
27865 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27866 jnz 21b
27867 23: xor %eax,%eax
27868 ASM_CLAC
27869 + ASM_PAX_CLOSE_USERLAND
27870 + pax_force_retaddr
27871 ret
27872
27873 .section .fixup,"ax"
27874 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27875 */
27876 ENTRY(copy_user_generic_string)
27877 CFI_STARTPROC
27878 + ASM_PAX_OPEN_USERLAND
27879 ASM_STAC
27880 andl %edx,%edx
27881 jz 4f
27882 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27883 movsb
27884 4: xorl %eax,%eax
27885 ASM_CLAC
27886 + ASM_PAX_CLOSE_USERLAND
27887 + pax_force_retaddr
27888 ret
27889
27890 .section .fixup,"ax"
27891 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27892 */
27893 ENTRY(copy_user_enhanced_fast_string)
27894 CFI_STARTPROC
27895 + ASM_PAX_OPEN_USERLAND
27896 ASM_STAC
27897 andl %edx,%edx
27898 jz 2f
27899 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27900 movsb
27901 2: xorl %eax,%eax
27902 ASM_CLAC
27903 + ASM_PAX_CLOSE_USERLAND
27904 + pax_force_retaddr
27905 ret
27906
27907 .section .fixup,"ax"
27908 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27909 index 6a4f43c..55d26f2 100644
27910 --- a/arch/x86/lib/copy_user_nocache_64.S
27911 +++ b/arch/x86/lib/copy_user_nocache_64.S
27912 @@ -8,6 +8,7 @@
27913
27914 #include <linux/linkage.h>
27915 #include <asm/dwarf2.h>
27916 +#include <asm/alternative-asm.h>
27917
27918 #define FIX_ALIGNMENT 1
27919
27920 @@ -16,6 +17,7 @@
27921 #include <asm/thread_info.h>
27922 #include <asm/asm.h>
27923 #include <asm/smap.h>
27924 +#include <asm/pgtable.h>
27925
27926 .macro ALIGN_DESTINATION
27927 #ifdef FIX_ALIGNMENT
27928 @@ -49,6 +51,16 @@
27929 */
27930 ENTRY(__copy_user_nocache)
27931 CFI_STARTPROC
27932 +
27933 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27934 + mov pax_user_shadow_base,%rcx
27935 + cmp %rcx,%rsi
27936 + jae 1f
27937 + add %rcx,%rsi
27938 +1:
27939 +#endif
27940 +
27941 + ASM_PAX_OPEN_USERLAND
27942 ASM_STAC
27943 cmpl $8,%edx
27944 jb 20f /* less then 8 bytes, go to byte copy loop */
27945 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27946 jz 17f
27947 1: movq (%rsi),%r8
27948 2: movq 1*8(%rsi),%r9
27949 -3: movq 2*8(%rsi),%r10
27950 +3: movq 2*8(%rsi),%rax
27951 4: movq 3*8(%rsi),%r11
27952 5: movnti %r8,(%rdi)
27953 6: movnti %r9,1*8(%rdi)
27954 -7: movnti %r10,2*8(%rdi)
27955 +7: movnti %rax,2*8(%rdi)
27956 8: movnti %r11,3*8(%rdi)
27957 9: movq 4*8(%rsi),%r8
27958 10: movq 5*8(%rsi),%r9
27959 -11: movq 6*8(%rsi),%r10
27960 +11: movq 6*8(%rsi),%rax
27961 12: movq 7*8(%rsi),%r11
27962 13: movnti %r8,4*8(%rdi)
27963 14: movnti %r9,5*8(%rdi)
27964 -15: movnti %r10,6*8(%rdi)
27965 +15: movnti %rax,6*8(%rdi)
27966 16: movnti %r11,7*8(%rdi)
27967 leaq 64(%rsi),%rsi
27968 leaq 64(%rdi),%rdi
27969 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27970 jnz 21b
27971 23: xorl %eax,%eax
27972 ASM_CLAC
27973 + ASM_PAX_CLOSE_USERLAND
27974 sfence
27975 + pax_force_retaddr
27976 ret
27977
27978 .section .fixup,"ax"
27979 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27980 index 2419d5f..953ee51 100644
27981 --- a/arch/x86/lib/csum-copy_64.S
27982 +++ b/arch/x86/lib/csum-copy_64.S
27983 @@ -9,6 +9,7 @@
27984 #include <asm/dwarf2.h>
27985 #include <asm/errno.h>
27986 #include <asm/asm.h>
27987 +#include <asm/alternative-asm.h>
27988
27989 /*
27990 * Checksum copy with exception handling.
27991 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27992 CFI_RESTORE rbp
27993 addq $7*8, %rsp
27994 CFI_ADJUST_CFA_OFFSET -7*8
27995 + pax_force_retaddr 0, 1
27996 ret
27997 CFI_RESTORE_STATE
27998
27999 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
28000 index 7609e0e..b449b98 100644
28001 --- a/arch/x86/lib/csum-wrappers_64.c
28002 +++ b/arch/x86/lib/csum-wrappers_64.c
28003 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
28004 len -= 2;
28005 }
28006 }
28007 + pax_open_userland();
28008 stac();
28009 - isum = csum_partial_copy_generic((__force const void *)src,
28010 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
28011 dst, len, isum, errp, NULL);
28012 clac();
28013 + pax_close_userland();
28014 if (unlikely(*errp))
28015 goto out_err;
28016
28017 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
28018 }
28019
28020 *errp = 0;
28021 + pax_open_userland();
28022 stac();
28023 - ret = csum_partial_copy_generic(src, (void __force *)dst,
28024 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
28025 len, isum, NULL, errp);
28026 clac();
28027 + pax_close_userland();
28028 return ret;
28029 }
28030 EXPORT_SYMBOL(csum_partial_copy_to_user);
28031 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28032 index a451235..1daa956 100644
28033 --- a/arch/x86/lib/getuser.S
28034 +++ b/arch/x86/lib/getuser.S
28035 @@ -33,17 +33,40 @@
28036 #include <asm/thread_info.h>
28037 #include <asm/asm.h>
28038 #include <asm/smap.h>
28039 +#include <asm/segment.h>
28040 +#include <asm/pgtable.h>
28041 +#include <asm/alternative-asm.h>
28042 +
28043 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28044 +#define __copyuser_seg gs;
28045 +#else
28046 +#define __copyuser_seg
28047 +#endif
28048
28049 .text
28050 ENTRY(__get_user_1)
28051 CFI_STARTPROC
28052 +
28053 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28054 GET_THREAD_INFO(%_ASM_DX)
28055 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28056 jae bad_get_user
28057 ASM_STAC
28058 -1: movzbl (%_ASM_AX),%edx
28059 +
28060 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28061 + mov pax_user_shadow_base,%_ASM_DX
28062 + cmp %_ASM_DX,%_ASM_AX
28063 + jae 1234f
28064 + add %_ASM_DX,%_ASM_AX
28065 +1234:
28066 +#endif
28067 +
28068 +#endif
28069 +
28070 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28071 xor %eax,%eax
28072 ASM_CLAC
28073 + pax_force_retaddr
28074 ret
28075 CFI_ENDPROC
28076 ENDPROC(__get_user_1)
28077 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28078 ENTRY(__get_user_2)
28079 CFI_STARTPROC
28080 add $1,%_ASM_AX
28081 +
28082 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28083 jc bad_get_user
28084 GET_THREAD_INFO(%_ASM_DX)
28085 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28086 jae bad_get_user
28087 ASM_STAC
28088 -2: movzwl -1(%_ASM_AX),%edx
28089 +
28090 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28091 + mov pax_user_shadow_base,%_ASM_DX
28092 + cmp %_ASM_DX,%_ASM_AX
28093 + jae 1234f
28094 + add %_ASM_DX,%_ASM_AX
28095 +1234:
28096 +#endif
28097 +
28098 +#endif
28099 +
28100 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28101 xor %eax,%eax
28102 ASM_CLAC
28103 + pax_force_retaddr
28104 ret
28105 CFI_ENDPROC
28106 ENDPROC(__get_user_2)
28107 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28108 ENTRY(__get_user_4)
28109 CFI_STARTPROC
28110 add $3,%_ASM_AX
28111 +
28112 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28113 jc bad_get_user
28114 GET_THREAD_INFO(%_ASM_DX)
28115 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28116 jae bad_get_user
28117 ASM_STAC
28118 -3: movl -3(%_ASM_AX),%edx
28119 +
28120 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28121 + mov pax_user_shadow_base,%_ASM_DX
28122 + cmp %_ASM_DX,%_ASM_AX
28123 + jae 1234f
28124 + add %_ASM_DX,%_ASM_AX
28125 +1234:
28126 +#endif
28127 +
28128 +#endif
28129 +
28130 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28131 xor %eax,%eax
28132 ASM_CLAC
28133 + pax_force_retaddr
28134 ret
28135 CFI_ENDPROC
28136 ENDPROC(__get_user_4)
28137 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28138 GET_THREAD_INFO(%_ASM_DX)
28139 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28140 jae bad_get_user
28141 +
28142 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28143 + mov pax_user_shadow_base,%_ASM_DX
28144 + cmp %_ASM_DX,%_ASM_AX
28145 + jae 1234f
28146 + add %_ASM_DX,%_ASM_AX
28147 +1234:
28148 +#endif
28149 +
28150 ASM_STAC
28151 4: movq -7(%_ASM_AX),%rdx
28152 xor %eax,%eax
28153 ASM_CLAC
28154 + pax_force_retaddr
28155 ret
28156 #else
28157 add $7,%_ASM_AX
28158 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28159 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28160 jae bad_get_user_8
28161 ASM_STAC
28162 -4: movl -7(%_ASM_AX),%edx
28163 -5: movl -3(%_ASM_AX),%ecx
28164 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28165 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28166 xor %eax,%eax
28167 ASM_CLAC
28168 + pax_force_retaddr
28169 ret
28170 #endif
28171 CFI_ENDPROC
28172 @@ -113,6 +175,7 @@ bad_get_user:
28173 xor %edx,%edx
28174 mov $(-EFAULT),%_ASM_AX
28175 ASM_CLAC
28176 + pax_force_retaddr
28177 ret
28178 CFI_ENDPROC
28179 END(bad_get_user)
28180 @@ -124,6 +187,7 @@ bad_get_user_8:
28181 xor %ecx,%ecx
28182 mov $(-EFAULT),%_ASM_AX
28183 ASM_CLAC
28184 + pax_force_retaddr
28185 ret
28186 CFI_ENDPROC
28187 END(bad_get_user_8)
28188 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28189 index 54fcffe..7be149e 100644
28190 --- a/arch/x86/lib/insn.c
28191 +++ b/arch/x86/lib/insn.c
28192 @@ -20,8 +20,10 @@
28193
28194 #ifdef __KERNEL__
28195 #include <linux/string.h>
28196 +#include <asm/pgtable_types.h>
28197 #else
28198 #include <string.h>
28199 +#define ktla_ktva(addr) addr
28200 #endif
28201 #include <asm/inat.h>
28202 #include <asm/insn.h>
28203 @@ -53,8 +55,8 @@
28204 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28205 {
28206 memset(insn, 0, sizeof(*insn));
28207 - insn->kaddr = kaddr;
28208 - insn->next_byte = kaddr;
28209 + insn->kaddr = ktla_ktva(kaddr);
28210 + insn->next_byte = ktla_ktva(kaddr);
28211 insn->x86_64 = x86_64 ? 1 : 0;
28212 insn->opnd_bytes = 4;
28213 if (x86_64)
28214 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28215 index 05a95e7..326f2fa 100644
28216 --- a/arch/x86/lib/iomap_copy_64.S
28217 +++ b/arch/x86/lib/iomap_copy_64.S
28218 @@ -17,6 +17,7 @@
28219
28220 #include <linux/linkage.h>
28221 #include <asm/dwarf2.h>
28222 +#include <asm/alternative-asm.h>
28223
28224 /*
28225 * override generic version in lib/iomap_copy.c
28226 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28227 CFI_STARTPROC
28228 movl %edx,%ecx
28229 rep movsd
28230 + pax_force_retaddr
28231 ret
28232 CFI_ENDPROC
28233 ENDPROC(__iowrite32_copy)
28234 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28235 index 56313a3..9b59269 100644
28236 --- a/arch/x86/lib/memcpy_64.S
28237 +++ b/arch/x86/lib/memcpy_64.S
28238 @@ -24,7 +24,7 @@
28239 * This gets patched over the unrolled variant (below) via the
28240 * alternative instructions framework:
28241 */
28242 - .section .altinstr_replacement, "ax", @progbits
28243 + .section .altinstr_replacement, "a", @progbits
28244 .Lmemcpy_c:
28245 movq %rdi, %rax
28246 movq %rdx, %rcx
28247 @@ -33,6 +33,7 @@
28248 rep movsq
28249 movl %edx, %ecx
28250 rep movsb
28251 + pax_force_retaddr
28252 ret
28253 .Lmemcpy_e:
28254 .previous
28255 @@ -44,11 +45,12 @@
28256 * This gets patched over the unrolled variant (below) via the
28257 * alternative instructions framework:
28258 */
28259 - .section .altinstr_replacement, "ax", @progbits
28260 + .section .altinstr_replacement, "a", @progbits
28261 .Lmemcpy_c_e:
28262 movq %rdi, %rax
28263 movq %rdx, %rcx
28264 rep movsb
28265 + pax_force_retaddr
28266 ret
28267 .Lmemcpy_e_e:
28268 .previous
28269 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28270 */
28271 movq 0*8(%rsi), %r8
28272 movq 1*8(%rsi), %r9
28273 - movq 2*8(%rsi), %r10
28274 + movq 2*8(%rsi), %rcx
28275 movq 3*8(%rsi), %r11
28276 leaq 4*8(%rsi), %rsi
28277
28278 movq %r8, 0*8(%rdi)
28279 movq %r9, 1*8(%rdi)
28280 - movq %r10, 2*8(%rdi)
28281 + movq %rcx, 2*8(%rdi)
28282 movq %r11, 3*8(%rdi)
28283 leaq 4*8(%rdi), %rdi
28284 jae .Lcopy_forward_loop
28285 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28286 subq $0x20, %rdx
28287 movq -1*8(%rsi), %r8
28288 movq -2*8(%rsi), %r9
28289 - movq -3*8(%rsi), %r10
28290 + movq -3*8(%rsi), %rcx
28291 movq -4*8(%rsi), %r11
28292 leaq -4*8(%rsi), %rsi
28293 movq %r8, -1*8(%rdi)
28294 movq %r9, -2*8(%rdi)
28295 - movq %r10, -3*8(%rdi)
28296 + movq %rcx, -3*8(%rdi)
28297 movq %r11, -4*8(%rdi)
28298 leaq -4*8(%rdi), %rdi
28299 jae .Lcopy_backward_loop
28300 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28301 */
28302 movq 0*8(%rsi), %r8
28303 movq 1*8(%rsi), %r9
28304 - movq -2*8(%rsi, %rdx), %r10
28305 + movq -2*8(%rsi, %rdx), %rcx
28306 movq -1*8(%rsi, %rdx), %r11
28307 movq %r8, 0*8(%rdi)
28308 movq %r9, 1*8(%rdi)
28309 - movq %r10, -2*8(%rdi, %rdx)
28310 + movq %rcx, -2*8(%rdi, %rdx)
28311 movq %r11, -1*8(%rdi, %rdx)
28312 + pax_force_retaddr
28313 retq
28314 .p2align 4
28315 .Lless_16bytes:
28316 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28317 movq -1*8(%rsi, %rdx), %r9
28318 movq %r8, 0*8(%rdi)
28319 movq %r9, -1*8(%rdi, %rdx)
28320 + pax_force_retaddr
28321 retq
28322 .p2align 4
28323 .Lless_8bytes:
28324 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28325 movl -4(%rsi, %rdx), %r8d
28326 movl %ecx, (%rdi)
28327 movl %r8d, -4(%rdi, %rdx)
28328 + pax_force_retaddr
28329 retq
28330 .p2align 4
28331 .Lless_3bytes:
28332 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28333 movb %cl, (%rdi)
28334
28335 .Lend:
28336 + pax_force_retaddr
28337 retq
28338 CFI_ENDPROC
28339 ENDPROC(memcpy)
28340 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28341 index 65268a6..5aa7815 100644
28342 --- a/arch/x86/lib/memmove_64.S
28343 +++ b/arch/x86/lib/memmove_64.S
28344 @@ -61,13 +61,13 @@ ENTRY(memmove)
28345 5:
28346 sub $0x20, %rdx
28347 movq 0*8(%rsi), %r11
28348 - movq 1*8(%rsi), %r10
28349 + movq 1*8(%rsi), %rcx
28350 movq 2*8(%rsi), %r9
28351 movq 3*8(%rsi), %r8
28352 leaq 4*8(%rsi), %rsi
28353
28354 movq %r11, 0*8(%rdi)
28355 - movq %r10, 1*8(%rdi)
28356 + movq %rcx, 1*8(%rdi)
28357 movq %r9, 2*8(%rdi)
28358 movq %r8, 3*8(%rdi)
28359 leaq 4*8(%rdi), %rdi
28360 @@ -81,10 +81,10 @@ ENTRY(memmove)
28361 4:
28362 movq %rdx, %rcx
28363 movq -8(%rsi, %rdx), %r11
28364 - lea -8(%rdi, %rdx), %r10
28365 + lea -8(%rdi, %rdx), %r9
28366 shrq $3, %rcx
28367 rep movsq
28368 - movq %r11, (%r10)
28369 + movq %r11, (%r9)
28370 jmp 13f
28371 .Lmemmove_end_forward:
28372
28373 @@ -95,14 +95,14 @@ ENTRY(memmove)
28374 7:
28375 movq %rdx, %rcx
28376 movq (%rsi), %r11
28377 - movq %rdi, %r10
28378 + movq %rdi, %r9
28379 leaq -8(%rsi, %rdx), %rsi
28380 leaq -8(%rdi, %rdx), %rdi
28381 shrq $3, %rcx
28382 std
28383 rep movsq
28384 cld
28385 - movq %r11, (%r10)
28386 + movq %r11, (%r9)
28387 jmp 13f
28388
28389 /*
28390 @@ -127,13 +127,13 @@ ENTRY(memmove)
28391 8:
28392 subq $0x20, %rdx
28393 movq -1*8(%rsi), %r11
28394 - movq -2*8(%rsi), %r10
28395 + movq -2*8(%rsi), %rcx
28396 movq -3*8(%rsi), %r9
28397 movq -4*8(%rsi), %r8
28398 leaq -4*8(%rsi), %rsi
28399
28400 movq %r11, -1*8(%rdi)
28401 - movq %r10, -2*8(%rdi)
28402 + movq %rcx, -2*8(%rdi)
28403 movq %r9, -3*8(%rdi)
28404 movq %r8, -4*8(%rdi)
28405 leaq -4*8(%rdi), %rdi
28406 @@ -151,11 +151,11 @@ ENTRY(memmove)
28407 * Move data from 16 bytes to 31 bytes.
28408 */
28409 movq 0*8(%rsi), %r11
28410 - movq 1*8(%rsi), %r10
28411 + movq 1*8(%rsi), %rcx
28412 movq -2*8(%rsi, %rdx), %r9
28413 movq -1*8(%rsi, %rdx), %r8
28414 movq %r11, 0*8(%rdi)
28415 - movq %r10, 1*8(%rdi)
28416 + movq %rcx, 1*8(%rdi)
28417 movq %r9, -2*8(%rdi, %rdx)
28418 movq %r8, -1*8(%rdi, %rdx)
28419 jmp 13f
28420 @@ -167,9 +167,9 @@ ENTRY(memmove)
28421 * Move data from 8 bytes to 15 bytes.
28422 */
28423 movq 0*8(%rsi), %r11
28424 - movq -1*8(%rsi, %rdx), %r10
28425 + movq -1*8(%rsi, %rdx), %r9
28426 movq %r11, 0*8(%rdi)
28427 - movq %r10, -1*8(%rdi, %rdx)
28428 + movq %r9, -1*8(%rdi, %rdx)
28429 jmp 13f
28430 10:
28431 cmpq $4, %rdx
28432 @@ -178,9 +178,9 @@ ENTRY(memmove)
28433 * Move data from 4 bytes to 7 bytes.
28434 */
28435 movl (%rsi), %r11d
28436 - movl -4(%rsi, %rdx), %r10d
28437 + movl -4(%rsi, %rdx), %r9d
28438 movl %r11d, (%rdi)
28439 - movl %r10d, -4(%rdi, %rdx)
28440 + movl %r9d, -4(%rdi, %rdx)
28441 jmp 13f
28442 11:
28443 cmp $2, %rdx
28444 @@ -189,9 +189,9 @@ ENTRY(memmove)
28445 * Move data from 2 bytes to 3 bytes.
28446 */
28447 movw (%rsi), %r11w
28448 - movw -2(%rsi, %rdx), %r10w
28449 + movw -2(%rsi, %rdx), %r9w
28450 movw %r11w, (%rdi)
28451 - movw %r10w, -2(%rdi, %rdx)
28452 + movw %r9w, -2(%rdi, %rdx)
28453 jmp 13f
28454 12:
28455 cmp $1, %rdx
28456 @@ -202,14 +202,16 @@ ENTRY(memmove)
28457 movb (%rsi), %r11b
28458 movb %r11b, (%rdi)
28459 13:
28460 + pax_force_retaddr
28461 retq
28462 CFI_ENDPROC
28463
28464 - .section .altinstr_replacement,"ax"
28465 + .section .altinstr_replacement,"a"
28466 .Lmemmove_begin_forward_efs:
28467 /* Forward moving data. */
28468 movq %rdx, %rcx
28469 rep movsb
28470 + pax_force_retaddr
28471 retq
28472 .Lmemmove_end_forward_efs:
28473 .previous
28474 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28475 index 2dcb380..50a78bc 100644
28476 --- a/arch/x86/lib/memset_64.S
28477 +++ b/arch/x86/lib/memset_64.S
28478 @@ -16,7 +16,7 @@
28479 *
28480 * rax original destination
28481 */
28482 - .section .altinstr_replacement, "ax", @progbits
28483 + .section .altinstr_replacement, "a", @progbits
28484 .Lmemset_c:
28485 movq %rdi,%r9
28486 movq %rdx,%rcx
28487 @@ -30,6 +30,7 @@
28488 movl %edx,%ecx
28489 rep stosb
28490 movq %r9,%rax
28491 + pax_force_retaddr
28492 ret
28493 .Lmemset_e:
28494 .previous
28495 @@ -45,13 +46,14 @@
28496 *
28497 * rax original destination
28498 */
28499 - .section .altinstr_replacement, "ax", @progbits
28500 + .section .altinstr_replacement, "a", @progbits
28501 .Lmemset_c_e:
28502 movq %rdi,%r9
28503 movb %sil,%al
28504 movq %rdx,%rcx
28505 rep stosb
28506 movq %r9,%rax
28507 + pax_force_retaddr
28508 ret
28509 .Lmemset_e_e:
28510 .previous
28511 @@ -59,7 +61,7 @@
28512 ENTRY(memset)
28513 ENTRY(__memset)
28514 CFI_STARTPROC
28515 - movq %rdi,%r10
28516 + movq %rdi,%r11
28517
28518 /* expand byte value */
28519 movzbl %sil,%ecx
28520 @@ -117,7 +119,8 @@ ENTRY(__memset)
28521 jnz .Lloop_1
28522
28523 .Lende:
28524 - movq %r10,%rax
28525 + movq %r11,%rax
28526 + pax_force_retaddr
28527 ret
28528
28529 CFI_RESTORE_STATE
28530 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28531 index c9f2d9b..e7fd2c0 100644
28532 --- a/arch/x86/lib/mmx_32.c
28533 +++ b/arch/x86/lib/mmx_32.c
28534 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28535 {
28536 void *p;
28537 int i;
28538 + unsigned long cr0;
28539
28540 if (unlikely(in_interrupt()))
28541 return __memcpy(to, from, len);
28542 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28543 kernel_fpu_begin();
28544
28545 __asm__ __volatile__ (
28546 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28547 - " prefetch 64(%0)\n"
28548 - " prefetch 128(%0)\n"
28549 - " prefetch 192(%0)\n"
28550 - " prefetch 256(%0)\n"
28551 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28552 + " prefetch 64(%1)\n"
28553 + " prefetch 128(%1)\n"
28554 + " prefetch 192(%1)\n"
28555 + " prefetch 256(%1)\n"
28556 "2: \n"
28557 ".section .fixup, \"ax\"\n"
28558 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28559 + "3: \n"
28560 +
28561 +#ifdef CONFIG_PAX_KERNEXEC
28562 + " movl %%cr0, %0\n"
28563 + " movl %0, %%eax\n"
28564 + " andl $0xFFFEFFFF, %%eax\n"
28565 + " movl %%eax, %%cr0\n"
28566 +#endif
28567 +
28568 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28569 +
28570 +#ifdef CONFIG_PAX_KERNEXEC
28571 + " movl %0, %%cr0\n"
28572 +#endif
28573 +
28574 " jmp 2b\n"
28575 ".previous\n"
28576 _ASM_EXTABLE(1b, 3b)
28577 - : : "r" (from));
28578 + : "=&r" (cr0) : "r" (from) : "ax");
28579
28580 for ( ; i > 5; i--) {
28581 __asm__ __volatile__ (
28582 - "1: prefetch 320(%0)\n"
28583 - "2: movq (%0), %%mm0\n"
28584 - " movq 8(%0), %%mm1\n"
28585 - " movq 16(%0), %%mm2\n"
28586 - " movq 24(%0), %%mm3\n"
28587 - " movq %%mm0, (%1)\n"
28588 - " movq %%mm1, 8(%1)\n"
28589 - " movq %%mm2, 16(%1)\n"
28590 - " movq %%mm3, 24(%1)\n"
28591 - " movq 32(%0), %%mm0\n"
28592 - " movq 40(%0), %%mm1\n"
28593 - " movq 48(%0), %%mm2\n"
28594 - " movq 56(%0), %%mm3\n"
28595 - " movq %%mm0, 32(%1)\n"
28596 - " movq %%mm1, 40(%1)\n"
28597 - " movq %%mm2, 48(%1)\n"
28598 - " movq %%mm3, 56(%1)\n"
28599 + "1: prefetch 320(%1)\n"
28600 + "2: movq (%1), %%mm0\n"
28601 + " movq 8(%1), %%mm1\n"
28602 + " movq 16(%1), %%mm2\n"
28603 + " movq 24(%1), %%mm3\n"
28604 + " movq %%mm0, (%2)\n"
28605 + " movq %%mm1, 8(%2)\n"
28606 + " movq %%mm2, 16(%2)\n"
28607 + " movq %%mm3, 24(%2)\n"
28608 + " movq 32(%1), %%mm0\n"
28609 + " movq 40(%1), %%mm1\n"
28610 + " movq 48(%1), %%mm2\n"
28611 + " movq 56(%1), %%mm3\n"
28612 + " movq %%mm0, 32(%2)\n"
28613 + " movq %%mm1, 40(%2)\n"
28614 + " movq %%mm2, 48(%2)\n"
28615 + " movq %%mm3, 56(%2)\n"
28616 ".section .fixup, \"ax\"\n"
28617 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28618 + "3:\n"
28619 +
28620 +#ifdef CONFIG_PAX_KERNEXEC
28621 + " movl %%cr0, %0\n"
28622 + " movl %0, %%eax\n"
28623 + " andl $0xFFFEFFFF, %%eax\n"
28624 + " movl %%eax, %%cr0\n"
28625 +#endif
28626 +
28627 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28628 +
28629 +#ifdef CONFIG_PAX_KERNEXEC
28630 + " movl %0, %%cr0\n"
28631 +#endif
28632 +
28633 " jmp 2b\n"
28634 ".previous\n"
28635 _ASM_EXTABLE(1b, 3b)
28636 - : : "r" (from), "r" (to) : "memory");
28637 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28638
28639 from += 64;
28640 to += 64;
28641 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28642 static void fast_copy_page(void *to, void *from)
28643 {
28644 int i;
28645 + unsigned long cr0;
28646
28647 kernel_fpu_begin();
28648
28649 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28650 * but that is for later. -AV
28651 */
28652 __asm__ __volatile__(
28653 - "1: prefetch (%0)\n"
28654 - " prefetch 64(%0)\n"
28655 - " prefetch 128(%0)\n"
28656 - " prefetch 192(%0)\n"
28657 - " prefetch 256(%0)\n"
28658 + "1: prefetch (%1)\n"
28659 + " prefetch 64(%1)\n"
28660 + " prefetch 128(%1)\n"
28661 + " prefetch 192(%1)\n"
28662 + " prefetch 256(%1)\n"
28663 "2: \n"
28664 ".section .fixup, \"ax\"\n"
28665 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28666 + "3: \n"
28667 +
28668 +#ifdef CONFIG_PAX_KERNEXEC
28669 + " movl %%cr0, %0\n"
28670 + " movl %0, %%eax\n"
28671 + " andl $0xFFFEFFFF, %%eax\n"
28672 + " movl %%eax, %%cr0\n"
28673 +#endif
28674 +
28675 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28676 +
28677 +#ifdef CONFIG_PAX_KERNEXEC
28678 + " movl %0, %%cr0\n"
28679 +#endif
28680 +
28681 " jmp 2b\n"
28682 ".previous\n"
28683 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28684 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28685
28686 for (i = 0; i < (4096-320)/64; i++) {
28687 __asm__ __volatile__ (
28688 - "1: prefetch 320(%0)\n"
28689 - "2: movq (%0), %%mm0\n"
28690 - " movntq %%mm0, (%1)\n"
28691 - " movq 8(%0), %%mm1\n"
28692 - " movntq %%mm1, 8(%1)\n"
28693 - " movq 16(%0), %%mm2\n"
28694 - " movntq %%mm2, 16(%1)\n"
28695 - " movq 24(%0), %%mm3\n"
28696 - " movntq %%mm3, 24(%1)\n"
28697 - " movq 32(%0), %%mm4\n"
28698 - " movntq %%mm4, 32(%1)\n"
28699 - " movq 40(%0), %%mm5\n"
28700 - " movntq %%mm5, 40(%1)\n"
28701 - " movq 48(%0), %%mm6\n"
28702 - " movntq %%mm6, 48(%1)\n"
28703 - " movq 56(%0), %%mm7\n"
28704 - " movntq %%mm7, 56(%1)\n"
28705 + "1: prefetch 320(%1)\n"
28706 + "2: movq (%1), %%mm0\n"
28707 + " movntq %%mm0, (%2)\n"
28708 + " movq 8(%1), %%mm1\n"
28709 + " movntq %%mm1, 8(%2)\n"
28710 + " movq 16(%1), %%mm2\n"
28711 + " movntq %%mm2, 16(%2)\n"
28712 + " movq 24(%1), %%mm3\n"
28713 + " movntq %%mm3, 24(%2)\n"
28714 + " movq 32(%1), %%mm4\n"
28715 + " movntq %%mm4, 32(%2)\n"
28716 + " movq 40(%1), %%mm5\n"
28717 + " movntq %%mm5, 40(%2)\n"
28718 + " movq 48(%1), %%mm6\n"
28719 + " movntq %%mm6, 48(%2)\n"
28720 + " movq 56(%1), %%mm7\n"
28721 + " movntq %%mm7, 56(%2)\n"
28722 ".section .fixup, \"ax\"\n"
28723 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28724 + "3:\n"
28725 +
28726 +#ifdef CONFIG_PAX_KERNEXEC
28727 + " movl %%cr0, %0\n"
28728 + " movl %0, %%eax\n"
28729 + " andl $0xFFFEFFFF, %%eax\n"
28730 + " movl %%eax, %%cr0\n"
28731 +#endif
28732 +
28733 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28734 +
28735 +#ifdef CONFIG_PAX_KERNEXEC
28736 + " movl %0, %%cr0\n"
28737 +#endif
28738 +
28739 " jmp 2b\n"
28740 ".previous\n"
28741 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28742 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28743
28744 from += 64;
28745 to += 64;
28746 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28747 static void fast_copy_page(void *to, void *from)
28748 {
28749 int i;
28750 + unsigned long cr0;
28751
28752 kernel_fpu_begin();
28753
28754 __asm__ __volatile__ (
28755 - "1: prefetch (%0)\n"
28756 - " prefetch 64(%0)\n"
28757 - " prefetch 128(%0)\n"
28758 - " prefetch 192(%0)\n"
28759 - " prefetch 256(%0)\n"
28760 + "1: prefetch (%1)\n"
28761 + " prefetch 64(%1)\n"
28762 + " prefetch 128(%1)\n"
28763 + " prefetch 192(%1)\n"
28764 + " prefetch 256(%1)\n"
28765 "2: \n"
28766 ".section .fixup, \"ax\"\n"
28767 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28768 + "3: \n"
28769 +
28770 +#ifdef CONFIG_PAX_KERNEXEC
28771 + " movl %%cr0, %0\n"
28772 + " movl %0, %%eax\n"
28773 + " andl $0xFFFEFFFF, %%eax\n"
28774 + " movl %%eax, %%cr0\n"
28775 +#endif
28776 +
28777 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28778 +
28779 +#ifdef CONFIG_PAX_KERNEXEC
28780 + " movl %0, %%cr0\n"
28781 +#endif
28782 +
28783 " jmp 2b\n"
28784 ".previous\n"
28785 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28786 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28787
28788 for (i = 0; i < 4096/64; i++) {
28789 __asm__ __volatile__ (
28790 - "1: prefetch 320(%0)\n"
28791 - "2: movq (%0), %%mm0\n"
28792 - " movq 8(%0), %%mm1\n"
28793 - " movq 16(%0), %%mm2\n"
28794 - " movq 24(%0), %%mm3\n"
28795 - " movq %%mm0, (%1)\n"
28796 - " movq %%mm1, 8(%1)\n"
28797 - " movq %%mm2, 16(%1)\n"
28798 - " movq %%mm3, 24(%1)\n"
28799 - " movq 32(%0), %%mm0\n"
28800 - " movq 40(%0), %%mm1\n"
28801 - " movq 48(%0), %%mm2\n"
28802 - " movq 56(%0), %%mm3\n"
28803 - " movq %%mm0, 32(%1)\n"
28804 - " movq %%mm1, 40(%1)\n"
28805 - " movq %%mm2, 48(%1)\n"
28806 - " movq %%mm3, 56(%1)\n"
28807 + "1: prefetch 320(%1)\n"
28808 + "2: movq (%1), %%mm0\n"
28809 + " movq 8(%1), %%mm1\n"
28810 + " movq 16(%1), %%mm2\n"
28811 + " movq 24(%1), %%mm3\n"
28812 + " movq %%mm0, (%2)\n"
28813 + " movq %%mm1, 8(%2)\n"
28814 + " movq %%mm2, 16(%2)\n"
28815 + " movq %%mm3, 24(%2)\n"
28816 + " movq 32(%1), %%mm0\n"
28817 + " movq 40(%1), %%mm1\n"
28818 + " movq 48(%1), %%mm2\n"
28819 + " movq 56(%1), %%mm3\n"
28820 + " movq %%mm0, 32(%2)\n"
28821 + " movq %%mm1, 40(%2)\n"
28822 + " movq %%mm2, 48(%2)\n"
28823 + " movq %%mm3, 56(%2)\n"
28824 ".section .fixup, \"ax\"\n"
28825 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28826 + "3:\n"
28827 +
28828 +#ifdef CONFIG_PAX_KERNEXEC
28829 + " movl %%cr0, %0\n"
28830 + " movl %0, %%eax\n"
28831 + " andl $0xFFFEFFFF, %%eax\n"
28832 + " movl %%eax, %%cr0\n"
28833 +#endif
28834 +
28835 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28836 +
28837 +#ifdef CONFIG_PAX_KERNEXEC
28838 + " movl %0, %%cr0\n"
28839 +#endif
28840 +
28841 " jmp 2b\n"
28842 ".previous\n"
28843 _ASM_EXTABLE(1b, 3b)
28844 - : : "r" (from), "r" (to) : "memory");
28845 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28846
28847 from += 64;
28848 to += 64;
28849 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28850 index f6d13ee..aca5f0b 100644
28851 --- a/arch/x86/lib/msr-reg.S
28852 +++ b/arch/x86/lib/msr-reg.S
28853 @@ -3,6 +3,7 @@
28854 #include <asm/dwarf2.h>
28855 #include <asm/asm.h>
28856 #include <asm/msr.h>
28857 +#include <asm/alternative-asm.h>
28858
28859 #ifdef CONFIG_X86_64
28860 /*
28861 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28862 CFI_STARTPROC
28863 pushq_cfi %rbx
28864 pushq_cfi %rbp
28865 - movq %rdi, %r10 /* Save pointer */
28866 + movq %rdi, %r9 /* Save pointer */
28867 xorl %r11d, %r11d /* Return value */
28868 movl (%rdi), %eax
28869 movl 4(%rdi), %ecx
28870 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28871 movl 28(%rdi), %edi
28872 CFI_REMEMBER_STATE
28873 1: \op
28874 -2: movl %eax, (%r10)
28875 +2: movl %eax, (%r9)
28876 movl %r11d, %eax /* Return value */
28877 - movl %ecx, 4(%r10)
28878 - movl %edx, 8(%r10)
28879 - movl %ebx, 12(%r10)
28880 - movl %ebp, 20(%r10)
28881 - movl %esi, 24(%r10)
28882 - movl %edi, 28(%r10)
28883 + movl %ecx, 4(%r9)
28884 + movl %edx, 8(%r9)
28885 + movl %ebx, 12(%r9)
28886 + movl %ebp, 20(%r9)
28887 + movl %esi, 24(%r9)
28888 + movl %edi, 28(%r9)
28889 popq_cfi %rbp
28890 popq_cfi %rbx
28891 + pax_force_retaddr
28892 ret
28893 3:
28894 CFI_RESTORE_STATE
28895 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28896 index fc6ba17..d4d989d 100644
28897 --- a/arch/x86/lib/putuser.S
28898 +++ b/arch/x86/lib/putuser.S
28899 @@ -16,7 +16,9 @@
28900 #include <asm/errno.h>
28901 #include <asm/asm.h>
28902 #include <asm/smap.h>
28903 -
28904 +#include <asm/segment.h>
28905 +#include <asm/pgtable.h>
28906 +#include <asm/alternative-asm.h>
28907
28908 /*
28909 * __put_user_X
28910 @@ -30,57 +32,125 @@
28911 * as they get called from within inline assembly.
28912 */
28913
28914 -#define ENTER CFI_STARTPROC ; \
28915 - GET_THREAD_INFO(%_ASM_BX)
28916 -#define EXIT ASM_CLAC ; \
28917 - ret ; \
28918 +#define ENTER CFI_STARTPROC
28919 +#define EXIT ASM_CLAC ; \
28920 + pax_force_retaddr ; \
28921 + ret ; \
28922 CFI_ENDPROC
28923
28924 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28925 +#define _DEST %_ASM_CX,%_ASM_BX
28926 +#else
28927 +#define _DEST %_ASM_CX
28928 +#endif
28929 +
28930 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28931 +#define __copyuser_seg gs;
28932 +#else
28933 +#define __copyuser_seg
28934 +#endif
28935 +
28936 .text
28937 ENTRY(__put_user_1)
28938 ENTER
28939 +
28940 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28941 + GET_THREAD_INFO(%_ASM_BX)
28942 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28943 jae bad_put_user
28944 ASM_STAC
28945 -1: movb %al,(%_ASM_CX)
28946 +
28947 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28948 + mov pax_user_shadow_base,%_ASM_BX
28949 + cmp %_ASM_BX,%_ASM_CX
28950 + jb 1234f
28951 + xor %ebx,%ebx
28952 +1234:
28953 +#endif
28954 +
28955 +#endif
28956 +
28957 +1: __copyuser_seg movb %al,(_DEST)
28958 xor %eax,%eax
28959 EXIT
28960 ENDPROC(__put_user_1)
28961
28962 ENTRY(__put_user_2)
28963 ENTER
28964 +
28965 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28966 + GET_THREAD_INFO(%_ASM_BX)
28967 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28968 sub $1,%_ASM_BX
28969 cmp %_ASM_BX,%_ASM_CX
28970 jae bad_put_user
28971 ASM_STAC
28972 -2: movw %ax,(%_ASM_CX)
28973 +
28974 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28975 + mov pax_user_shadow_base,%_ASM_BX
28976 + cmp %_ASM_BX,%_ASM_CX
28977 + jb 1234f
28978 + xor %ebx,%ebx
28979 +1234:
28980 +#endif
28981 +
28982 +#endif
28983 +
28984 +2: __copyuser_seg movw %ax,(_DEST)
28985 xor %eax,%eax
28986 EXIT
28987 ENDPROC(__put_user_2)
28988
28989 ENTRY(__put_user_4)
28990 ENTER
28991 +
28992 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28993 + GET_THREAD_INFO(%_ASM_BX)
28994 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28995 sub $3,%_ASM_BX
28996 cmp %_ASM_BX,%_ASM_CX
28997 jae bad_put_user
28998 ASM_STAC
28999 -3: movl %eax,(%_ASM_CX)
29000 +
29001 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29002 + mov pax_user_shadow_base,%_ASM_BX
29003 + cmp %_ASM_BX,%_ASM_CX
29004 + jb 1234f
29005 + xor %ebx,%ebx
29006 +1234:
29007 +#endif
29008 +
29009 +#endif
29010 +
29011 +3: __copyuser_seg movl %eax,(_DEST)
29012 xor %eax,%eax
29013 EXIT
29014 ENDPROC(__put_user_4)
29015
29016 ENTRY(__put_user_8)
29017 ENTER
29018 +
29019 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29020 + GET_THREAD_INFO(%_ASM_BX)
29021 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29022 sub $7,%_ASM_BX
29023 cmp %_ASM_BX,%_ASM_CX
29024 jae bad_put_user
29025 ASM_STAC
29026 -4: mov %_ASM_AX,(%_ASM_CX)
29027 +
29028 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29029 + mov pax_user_shadow_base,%_ASM_BX
29030 + cmp %_ASM_BX,%_ASM_CX
29031 + jb 1234f
29032 + xor %ebx,%ebx
29033 +1234:
29034 +#endif
29035 +
29036 +#endif
29037 +
29038 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29039 #ifdef CONFIG_X86_32
29040 -5: movl %edx,4(%_ASM_CX)
29041 +5: __copyuser_seg movl %edx,4(_DEST)
29042 #endif
29043 xor %eax,%eax
29044 EXIT
29045 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29046 index 1cad221..de671ee 100644
29047 --- a/arch/x86/lib/rwlock.S
29048 +++ b/arch/x86/lib/rwlock.S
29049 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29050 FRAME
29051 0: LOCK_PREFIX
29052 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29053 +
29054 +#ifdef CONFIG_PAX_REFCOUNT
29055 + jno 1234f
29056 + LOCK_PREFIX
29057 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29058 + int $4
29059 +1234:
29060 + _ASM_EXTABLE(1234b, 1234b)
29061 +#endif
29062 +
29063 1: rep; nop
29064 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29065 jne 1b
29066 LOCK_PREFIX
29067 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29068 +
29069 +#ifdef CONFIG_PAX_REFCOUNT
29070 + jno 1234f
29071 + LOCK_PREFIX
29072 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29073 + int $4
29074 +1234:
29075 + _ASM_EXTABLE(1234b, 1234b)
29076 +#endif
29077 +
29078 jnz 0b
29079 ENDFRAME
29080 + pax_force_retaddr
29081 ret
29082 CFI_ENDPROC
29083 END(__write_lock_failed)
29084 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29085 FRAME
29086 0: LOCK_PREFIX
29087 READ_LOCK_SIZE(inc) (%__lock_ptr)
29088 +
29089 +#ifdef CONFIG_PAX_REFCOUNT
29090 + jno 1234f
29091 + LOCK_PREFIX
29092 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29093 + int $4
29094 +1234:
29095 + _ASM_EXTABLE(1234b, 1234b)
29096 +#endif
29097 +
29098 1: rep; nop
29099 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29100 js 1b
29101 LOCK_PREFIX
29102 READ_LOCK_SIZE(dec) (%__lock_ptr)
29103 +
29104 +#ifdef CONFIG_PAX_REFCOUNT
29105 + jno 1234f
29106 + LOCK_PREFIX
29107 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29108 + int $4
29109 +1234:
29110 + _ASM_EXTABLE(1234b, 1234b)
29111 +#endif
29112 +
29113 js 0b
29114 ENDFRAME
29115 + pax_force_retaddr
29116 ret
29117 CFI_ENDPROC
29118 END(__read_lock_failed)
29119 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29120 index 5dff5f0..cadebf4 100644
29121 --- a/arch/x86/lib/rwsem.S
29122 +++ b/arch/x86/lib/rwsem.S
29123 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29124 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29125 CFI_RESTORE __ASM_REG(dx)
29126 restore_common_regs
29127 + pax_force_retaddr
29128 ret
29129 CFI_ENDPROC
29130 ENDPROC(call_rwsem_down_read_failed)
29131 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29132 movq %rax,%rdi
29133 call rwsem_down_write_failed
29134 restore_common_regs
29135 + pax_force_retaddr
29136 ret
29137 CFI_ENDPROC
29138 ENDPROC(call_rwsem_down_write_failed)
29139 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29140 movq %rax,%rdi
29141 call rwsem_wake
29142 restore_common_regs
29143 -1: ret
29144 +1: pax_force_retaddr
29145 + ret
29146 CFI_ENDPROC
29147 ENDPROC(call_rwsem_wake)
29148
29149 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29150 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29151 CFI_RESTORE __ASM_REG(dx)
29152 restore_common_regs
29153 + pax_force_retaddr
29154 ret
29155 CFI_ENDPROC
29156 ENDPROC(call_rwsem_downgrade_wake)
29157 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29158 index a63efd6..ccecad8 100644
29159 --- a/arch/x86/lib/thunk_64.S
29160 +++ b/arch/x86/lib/thunk_64.S
29161 @@ -8,6 +8,7 @@
29162 #include <linux/linkage.h>
29163 #include <asm/dwarf2.h>
29164 #include <asm/calling.h>
29165 +#include <asm/alternative-asm.h>
29166
29167 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29168 .macro THUNK name, func, put_ret_addr_in_rdi=0
29169 @@ -41,5 +42,6 @@
29170 SAVE_ARGS
29171 restore:
29172 RESTORE_ARGS
29173 + pax_force_retaddr
29174 ret
29175 CFI_ENDPROC
29176 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29177 index 3eb18ac..6890bc3 100644
29178 --- a/arch/x86/lib/usercopy_32.c
29179 +++ b/arch/x86/lib/usercopy_32.c
29180 @@ -42,11 +42,13 @@ do { \
29181 int __d0; \
29182 might_fault(); \
29183 __asm__ __volatile__( \
29184 + __COPYUSER_SET_ES \
29185 ASM_STAC "\n" \
29186 "0: rep; stosl\n" \
29187 " movl %2,%0\n" \
29188 "1: rep; stosb\n" \
29189 "2: " ASM_CLAC "\n" \
29190 + __COPYUSER_RESTORE_ES \
29191 ".section .fixup,\"ax\"\n" \
29192 "3: lea 0(%2,%0,4),%0\n" \
29193 " jmp 2b\n" \
29194 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29195
29196 #ifdef CONFIG_X86_INTEL_USERCOPY
29197 static unsigned long
29198 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29199 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29200 {
29201 int d0, d1;
29202 __asm__ __volatile__(
29203 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29204 " .align 2,0x90\n"
29205 "3: movl 0(%4), %%eax\n"
29206 "4: movl 4(%4), %%edx\n"
29207 - "5: movl %%eax, 0(%3)\n"
29208 - "6: movl %%edx, 4(%3)\n"
29209 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29210 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29211 "7: movl 8(%4), %%eax\n"
29212 "8: movl 12(%4),%%edx\n"
29213 - "9: movl %%eax, 8(%3)\n"
29214 - "10: movl %%edx, 12(%3)\n"
29215 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29216 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29217 "11: movl 16(%4), %%eax\n"
29218 "12: movl 20(%4), %%edx\n"
29219 - "13: movl %%eax, 16(%3)\n"
29220 - "14: movl %%edx, 20(%3)\n"
29221 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29222 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29223 "15: movl 24(%4), %%eax\n"
29224 "16: movl 28(%4), %%edx\n"
29225 - "17: movl %%eax, 24(%3)\n"
29226 - "18: movl %%edx, 28(%3)\n"
29227 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29228 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29229 "19: movl 32(%4), %%eax\n"
29230 "20: movl 36(%4), %%edx\n"
29231 - "21: movl %%eax, 32(%3)\n"
29232 - "22: movl %%edx, 36(%3)\n"
29233 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29234 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29235 "23: movl 40(%4), %%eax\n"
29236 "24: movl 44(%4), %%edx\n"
29237 - "25: movl %%eax, 40(%3)\n"
29238 - "26: movl %%edx, 44(%3)\n"
29239 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29240 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29241 "27: movl 48(%4), %%eax\n"
29242 "28: movl 52(%4), %%edx\n"
29243 - "29: movl %%eax, 48(%3)\n"
29244 - "30: movl %%edx, 52(%3)\n"
29245 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29246 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29247 "31: movl 56(%4), %%eax\n"
29248 "32: movl 60(%4), %%edx\n"
29249 - "33: movl %%eax, 56(%3)\n"
29250 - "34: movl %%edx, 60(%3)\n"
29251 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29252 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29253 " addl $-64, %0\n"
29254 " addl $64, %4\n"
29255 " addl $64, %3\n"
29256 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29257 " shrl $2, %0\n"
29258 " andl $3, %%eax\n"
29259 " cld\n"
29260 + __COPYUSER_SET_ES
29261 "99: rep; movsl\n"
29262 "36: movl %%eax, %0\n"
29263 "37: rep; movsb\n"
29264 "100:\n"
29265 + __COPYUSER_RESTORE_ES
29266 ".section .fixup,\"ax\"\n"
29267 "101: lea 0(%%eax,%0,4),%0\n"
29268 " jmp 100b\n"
29269 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29270 }
29271
29272 static unsigned long
29273 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29274 +{
29275 + int d0, d1;
29276 + __asm__ __volatile__(
29277 + " .align 2,0x90\n"
29278 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29279 + " cmpl $67, %0\n"
29280 + " jbe 3f\n"
29281 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29282 + " .align 2,0x90\n"
29283 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29284 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29285 + "5: movl %%eax, 0(%3)\n"
29286 + "6: movl %%edx, 4(%3)\n"
29287 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29288 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29289 + "9: movl %%eax, 8(%3)\n"
29290 + "10: movl %%edx, 12(%3)\n"
29291 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29292 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29293 + "13: movl %%eax, 16(%3)\n"
29294 + "14: movl %%edx, 20(%3)\n"
29295 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29296 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29297 + "17: movl %%eax, 24(%3)\n"
29298 + "18: movl %%edx, 28(%3)\n"
29299 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29300 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29301 + "21: movl %%eax, 32(%3)\n"
29302 + "22: movl %%edx, 36(%3)\n"
29303 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29304 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29305 + "25: movl %%eax, 40(%3)\n"
29306 + "26: movl %%edx, 44(%3)\n"
29307 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29308 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29309 + "29: movl %%eax, 48(%3)\n"
29310 + "30: movl %%edx, 52(%3)\n"
29311 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29312 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29313 + "33: movl %%eax, 56(%3)\n"
29314 + "34: movl %%edx, 60(%3)\n"
29315 + " addl $-64, %0\n"
29316 + " addl $64, %4\n"
29317 + " addl $64, %3\n"
29318 + " cmpl $63, %0\n"
29319 + " ja 1b\n"
29320 + "35: movl %0, %%eax\n"
29321 + " shrl $2, %0\n"
29322 + " andl $3, %%eax\n"
29323 + " cld\n"
29324 + "99: rep; "__copyuser_seg" movsl\n"
29325 + "36: movl %%eax, %0\n"
29326 + "37: rep; "__copyuser_seg" movsb\n"
29327 + "100:\n"
29328 + ".section .fixup,\"ax\"\n"
29329 + "101: lea 0(%%eax,%0,4),%0\n"
29330 + " jmp 100b\n"
29331 + ".previous\n"
29332 + _ASM_EXTABLE(1b,100b)
29333 + _ASM_EXTABLE(2b,100b)
29334 + _ASM_EXTABLE(3b,100b)
29335 + _ASM_EXTABLE(4b,100b)
29336 + _ASM_EXTABLE(5b,100b)
29337 + _ASM_EXTABLE(6b,100b)
29338 + _ASM_EXTABLE(7b,100b)
29339 + _ASM_EXTABLE(8b,100b)
29340 + _ASM_EXTABLE(9b,100b)
29341 + _ASM_EXTABLE(10b,100b)
29342 + _ASM_EXTABLE(11b,100b)
29343 + _ASM_EXTABLE(12b,100b)
29344 + _ASM_EXTABLE(13b,100b)
29345 + _ASM_EXTABLE(14b,100b)
29346 + _ASM_EXTABLE(15b,100b)
29347 + _ASM_EXTABLE(16b,100b)
29348 + _ASM_EXTABLE(17b,100b)
29349 + _ASM_EXTABLE(18b,100b)
29350 + _ASM_EXTABLE(19b,100b)
29351 + _ASM_EXTABLE(20b,100b)
29352 + _ASM_EXTABLE(21b,100b)
29353 + _ASM_EXTABLE(22b,100b)
29354 + _ASM_EXTABLE(23b,100b)
29355 + _ASM_EXTABLE(24b,100b)
29356 + _ASM_EXTABLE(25b,100b)
29357 + _ASM_EXTABLE(26b,100b)
29358 + _ASM_EXTABLE(27b,100b)
29359 + _ASM_EXTABLE(28b,100b)
29360 + _ASM_EXTABLE(29b,100b)
29361 + _ASM_EXTABLE(30b,100b)
29362 + _ASM_EXTABLE(31b,100b)
29363 + _ASM_EXTABLE(32b,100b)
29364 + _ASM_EXTABLE(33b,100b)
29365 + _ASM_EXTABLE(34b,100b)
29366 + _ASM_EXTABLE(35b,100b)
29367 + _ASM_EXTABLE(36b,100b)
29368 + _ASM_EXTABLE(37b,100b)
29369 + _ASM_EXTABLE(99b,101b)
29370 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29371 + : "1"(to), "2"(from), "0"(size)
29372 + : "eax", "edx", "memory");
29373 + return size;
29374 +}
29375 +
29376 +static unsigned long __size_overflow(3)
29377 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29378 {
29379 int d0, d1;
29380 __asm__ __volatile__(
29381 " .align 2,0x90\n"
29382 - "0: movl 32(%4), %%eax\n"
29383 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29384 " cmpl $67, %0\n"
29385 " jbe 2f\n"
29386 - "1: movl 64(%4), %%eax\n"
29387 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29388 " .align 2,0x90\n"
29389 - "2: movl 0(%4), %%eax\n"
29390 - "21: movl 4(%4), %%edx\n"
29391 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29392 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29393 " movl %%eax, 0(%3)\n"
29394 " movl %%edx, 4(%3)\n"
29395 - "3: movl 8(%4), %%eax\n"
29396 - "31: movl 12(%4),%%edx\n"
29397 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29398 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29399 " movl %%eax, 8(%3)\n"
29400 " movl %%edx, 12(%3)\n"
29401 - "4: movl 16(%4), %%eax\n"
29402 - "41: movl 20(%4), %%edx\n"
29403 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29404 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29405 " movl %%eax, 16(%3)\n"
29406 " movl %%edx, 20(%3)\n"
29407 - "10: movl 24(%4), %%eax\n"
29408 - "51: movl 28(%4), %%edx\n"
29409 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29410 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29411 " movl %%eax, 24(%3)\n"
29412 " movl %%edx, 28(%3)\n"
29413 - "11: movl 32(%4), %%eax\n"
29414 - "61: movl 36(%4), %%edx\n"
29415 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29416 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29417 " movl %%eax, 32(%3)\n"
29418 " movl %%edx, 36(%3)\n"
29419 - "12: movl 40(%4), %%eax\n"
29420 - "71: movl 44(%4), %%edx\n"
29421 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29422 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29423 " movl %%eax, 40(%3)\n"
29424 " movl %%edx, 44(%3)\n"
29425 - "13: movl 48(%4), %%eax\n"
29426 - "81: movl 52(%4), %%edx\n"
29427 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29428 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29429 " movl %%eax, 48(%3)\n"
29430 " movl %%edx, 52(%3)\n"
29431 - "14: movl 56(%4), %%eax\n"
29432 - "91: movl 60(%4), %%edx\n"
29433 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29434 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29435 " movl %%eax, 56(%3)\n"
29436 " movl %%edx, 60(%3)\n"
29437 " addl $-64, %0\n"
29438 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29439 " shrl $2, %0\n"
29440 " andl $3, %%eax\n"
29441 " cld\n"
29442 - "6: rep; movsl\n"
29443 + "6: rep; "__copyuser_seg" movsl\n"
29444 " movl %%eax,%0\n"
29445 - "7: rep; movsb\n"
29446 + "7: rep; "__copyuser_seg" movsb\n"
29447 "8:\n"
29448 ".section .fixup,\"ax\"\n"
29449 "9: lea 0(%%eax,%0,4),%0\n"
29450 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29451 * hyoshiok@miraclelinux.com
29452 */
29453
29454 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29455 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29456 const void __user *from, unsigned long size)
29457 {
29458 int d0, d1;
29459
29460 __asm__ __volatile__(
29461 " .align 2,0x90\n"
29462 - "0: movl 32(%4), %%eax\n"
29463 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29464 " cmpl $67, %0\n"
29465 " jbe 2f\n"
29466 - "1: movl 64(%4), %%eax\n"
29467 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29468 " .align 2,0x90\n"
29469 - "2: movl 0(%4), %%eax\n"
29470 - "21: movl 4(%4), %%edx\n"
29471 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29472 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29473 " movnti %%eax, 0(%3)\n"
29474 " movnti %%edx, 4(%3)\n"
29475 - "3: movl 8(%4), %%eax\n"
29476 - "31: movl 12(%4),%%edx\n"
29477 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29478 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29479 " movnti %%eax, 8(%3)\n"
29480 " movnti %%edx, 12(%3)\n"
29481 - "4: movl 16(%4), %%eax\n"
29482 - "41: movl 20(%4), %%edx\n"
29483 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29484 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29485 " movnti %%eax, 16(%3)\n"
29486 " movnti %%edx, 20(%3)\n"
29487 - "10: movl 24(%4), %%eax\n"
29488 - "51: movl 28(%4), %%edx\n"
29489 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29490 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29491 " movnti %%eax, 24(%3)\n"
29492 " movnti %%edx, 28(%3)\n"
29493 - "11: movl 32(%4), %%eax\n"
29494 - "61: movl 36(%4), %%edx\n"
29495 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29496 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29497 " movnti %%eax, 32(%3)\n"
29498 " movnti %%edx, 36(%3)\n"
29499 - "12: movl 40(%4), %%eax\n"
29500 - "71: movl 44(%4), %%edx\n"
29501 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29502 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29503 " movnti %%eax, 40(%3)\n"
29504 " movnti %%edx, 44(%3)\n"
29505 - "13: movl 48(%4), %%eax\n"
29506 - "81: movl 52(%4), %%edx\n"
29507 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29508 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29509 " movnti %%eax, 48(%3)\n"
29510 " movnti %%edx, 52(%3)\n"
29511 - "14: movl 56(%4), %%eax\n"
29512 - "91: movl 60(%4), %%edx\n"
29513 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29514 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29515 " movnti %%eax, 56(%3)\n"
29516 " movnti %%edx, 60(%3)\n"
29517 " addl $-64, %0\n"
29518 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29519 " shrl $2, %0\n"
29520 " andl $3, %%eax\n"
29521 " cld\n"
29522 - "6: rep; movsl\n"
29523 + "6: rep; "__copyuser_seg" movsl\n"
29524 " movl %%eax,%0\n"
29525 - "7: rep; movsb\n"
29526 + "7: rep; "__copyuser_seg" movsb\n"
29527 "8:\n"
29528 ".section .fixup,\"ax\"\n"
29529 "9: lea 0(%%eax,%0,4),%0\n"
29530 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29531 return size;
29532 }
29533
29534 -static unsigned long __copy_user_intel_nocache(void *to,
29535 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29536 const void __user *from, unsigned long size)
29537 {
29538 int d0, d1;
29539
29540 __asm__ __volatile__(
29541 " .align 2,0x90\n"
29542 - "0: movl 32(%4), %%eax\n"
29543 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29544 " cmpl $67, %0\n"
29545 " jbe 2f\n"
29546 - "1: movl 64(%4), %%eax\n"
29547 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29548 " .align 2,0x90\n"
29549 - "2: movl 0(%4), %%eax\n"
29550 - "21: movl 4(%4), %%edx\n"
29551 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29552 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29553 " movnti %%eax, 0(%3)\n"
29554 " movnti %%edx, 4(%3)\n"
29555 - "3: movl 8(%4), %%eax\n"
29556 - "31: movl 12(%4),%%edx\n"
29557 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29558 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29559 " movnti %%eax, 8(%3)\n"
29560 " movnti %%edx, 12(%3)\n"
29561 - "4: movl 16(%4), %%eax\n"
29562 - "41: movl 20(%4), %%edx\n"
29563 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29564 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29565 " movnti %%eax, 16(%3)\n"
29566 " movnti %%edx, 20(%3)\n"
29567 - "10: movl 24(%4), %%eax\n"
29568 - "51: movl 28(%4), %%edx\n"
29569 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29570 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29571 " movnti %%eax, 24(%3)\n"
29572 " movnti %%edx, 28(%3)\n"
29573 - "11: movl 32(%4), %%eax\n"
29574 - "61: movl 36(%4), %%edx\n"
29575 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29576 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29577 " movnti %%eax, 32(%3)\n"
29578 " movnti %%edx, 36(%3)\n"
29579 - "12: movl 40(%4), %%eax\n"
29580 - "71: movl 44(%4), %%edx\n"
29581 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29582 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29583 " movnti %%eax, 40(%3)\n"
29584 " movnti %%edx, 44(%3)\n"
29585 - "13: movl 48(%4), %%eax\n"
29586 - "81: movl 52(%4), %%edx\n"
29587 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29588 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29589 " movnti %%eax, 48(%3)\n"
29590 " movnti %%edx, 52(%3)\n"
29591 - "14: movl 56(%4), %%eax\n"
29592 - "91: movl 60(%4), %%edx\n"
29593 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29594 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29595 " movnti %%eax, 56(%3)\n"
29596 " movnti %%edx, 60(%3)\n"
29597 " addl $-64, %0\n"
29598 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29599 " shrl $2, %0\n"
29600 " andl $3, %%eax\n"
29601 " cld\n"
29602 - "6: rep; movsl\n"
29603 + "6: rep; "__copyuser_seg" movsl\n"
29604 " movl %%eax,%0\n"
29605 - "7: rep; movsb\n"
29606 + "7: rep; "__copyuser_seg" movsb\n"
29607 "8:\n"
29608 ".section .fixup,\"ax\"\n"
29609 "9: lea 0(%%eax,%0,4),%0\n"
29610 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29611 */
29612 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29613 unsigned long size);
29614 -unsigned long __copy_user_intel(void __user *to, const void *from,
29615 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29616 + unsigned long size);
29617 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29618 unsigned long size);
29619 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29620 const void __user *from, unsigned long size);
29621 #endif /* CONFIG_X86_INTEL_USERCOPY */
29622
29623 /* Generic arbitrary sized copy. */
29624 -#define __copy_user(to, from, size) \
29625 +#define __copy_user(to, from, size, prefix, set, restore) \
29626 do { \
29627 int __d0, __d1, __d2; \
29628 __asm__ __volatile__( \
29629 + set \
29630 " cmp $7,%0\n" \
29631 " jbe 1f\n" \
29632 " movl %1,%0\n" \
29633 " negl %0\n" \
29634 " andl $7,%0\n" \
29635 " subl %0,%3\n" \
29636 - "4: rep; movsb\n" \
29637 + "4: rep; "prefix"movsb\n" \
29638 " movl %3,%0\n" \
29639 " shrl $2,%0\n" \
29640 " andl $3,%3\n" \
29641 " .align 2,0x90\n" \
29642 - "0: rep; movsl\n" \
29643 + "0: rep; "prefix"movsl\n" \
29644 " movl %3,%0\n" \
29645 - "1: rep; movsb\n" \
29646 + "1: rep; "prefix"movsb\n" \
29647 "2:\n" \
29648 + restore \
29649 ".section .fixup,\"ax\"\n" \
29650 "5: addl %3,%0\n" \
29651 " jmp 2b\n" \
29652 @@ -538,14 +650,14 @@ do { \
29653 " negl %0\n" \
29654 " andl $7,%0\n" \
29655 " subl %0,%3\n" \
29656 - "4: rep; movsb\n" \
29657 + "4: rep; "__copyuser_seg"movsb\n" \
29658 " movl %3,%0\n" \
29659 " shrl $2,%0\n" \
29660 " andl $3,%3\n" \
29661 " .align 2,0x90\n" \
29662 - "0: rep; movsl\n" \
29663 + "0: rep; "__copyuser_seg"movsl\n" \
29664 " movl %3,%0\n" \
29665 - "1: rep; movsb\n" \
29666 + "1: rep; "__copyuser_seg"movsb\n" \
29667 "2:\n" \
29668 ".section .fixup,\"ax\"\n" \
29669 "5: addl %3,%0\n" \
29670 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29671 {
29672 stac();
29673 if (movsl_is_ok(to, from, n))
29674 - __copy_user(to, from, n);
29675 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29676 else
29677 - n = __copy_user_intel(to, from, n);
29678 + n = __generic_copy_to_user_intel(to, from, n);
29679 clac();
29680 return n;
29681 }
29682 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29683 {
29684 stac();
29685 if (movsl_is_ok(to, from, n))
29686 - __copy_user(to, from, n);
29687 + __copy_user(to, from, n, __copyuser_seg, "", "");
29688 else
29689 - n = __copy_user_intel((void __user *)to,
29690 - (const void *)from, n);
29691 + n = __generic_copy_from_user_intel(to, from, n);
29692 clac();
29693 return n;
29694 }
29695 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29696 if (n > 64 && cpu_has_xmm2)
29697 n = __copy_user_intel_nocache(to, from, n);
29698 else
29699 - __copy_user(to, from, n);
29700 + __copy_user(to, from, n, __copyuser_seg, "", "");
29701 #else
29702 - __copy_user(to, from, n);
29703 + __copy_user(to, from, n, __copyuser_seg, "", "");
29704 #endif
29705 clac();
29706 return n;
29707 }
29708 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29709
29710 -/**
29711 - * copy_to_user: - Copy a block of data into user space.
29712 - * @to: Destination address, in user space.
29713 - * @from: Source address, in kernel space.
29714 - * @n: Number of bytes to copy.
29715 - *
29716 - * Context: User context only. This function may sleep.
29717 - *
29718 - * Copy data from kernel space to user space.
29719 - *
29720 - * Returns number of bytes that could not be copied.
29721 - * On success, this will be zero.
29722 - */
29723 -unsigned long
29724 -copy_to_user(void __user *to, const void *from, unsigned long n)
29725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29726 +void __set_fs(mm_segment_t x)
29727 {
29728 - if (access_ok(VERIFY_WRITE, to, n))
29729 - n = __copy_to_user(to, from, n);
29730 - return n;
29731 + switch (x.seg) {
29732 + case 0:
29733 + loadsegment(gs, 0);
29734 + break;
29735 + case TASK_SIZE_MAX:
29736 + loadsegment(gs, __USER_DS);
29737 + break;
29738 + case -1UL:
29739 + loadsegment(gs, __KERNEL_DS);
29740 + break;
29741 + default:
29742 + BUG();
29743 + }
29744 }
29745 -EXPORT_SYMBOL(copy_to_user);
29746 +EXPORT_SYMBOL(__set_fs);
29747
29748 -/**
29749 - * copy_from_user: - Copy a block of data from user space.
29750 - * @to: Destination address, in kernel space.
29751 - * @from: Source address, in user space.
29752 - * @n: Number of bytes to copy.
29753 - *
29754 - * Context: User context only. This function may sleep.
29755 - *
29756 - * Copy data from user space to kernel space.
29757 - *
29758 - * Returns number of bytes that could not be copied.
29759 - * On success, this will be zero.
29760 - *
29761 - * If some data could not be copied, this function will pad the copied
29762 - * data to the requested size using zero bytes.
29763 - */
29764 -unsigned long
29765 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29766 +void set_fs(mm_segment_t x)
29767 {
29768 - if (access_ok(VERIFY_READ, from, n))
29769 - n = __copy_from_user(to, from, n);
29770 - else
29771 - memset(to, 0, n);
29772 - return n;
29773 + current_thread_info()->addr_limit = x;
29774 + __set_fs(x);
29775 }
29776 -EXPORT_SYMBOL(_copy_from_user);
29777 +EXPORT_SYMBOL(set_fs);
29778 +#endif
29779 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29780 index 906fea3..0194a18 100644
29781 --- a/arch/x86/lib/usercopy_64.c
29782 +++ b/arch/x86/lib/usercopy_64.c
29783 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29784 might_fault();
29785 /* no memory constraint because it doesn't change any memory gcc knows
29786 about */
29787 + pax_open_userland();
29788 stac();
29789 asm volatile(
29790 " testq %[size8],%[size8]\n"
29791 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29792 _ASM_EXTABLE(0b,3b)
29793 _ASM_EXTABLE(1b,2b)
29794 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29795 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29796 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29797 [zero] "r" (0UL), [eight] "r" (8UL));
29798 clac();
29799 + pax_close_userland();
29800 return size;
29801 }
29802 EXPORT_SYMBOL(__clear_user);
29803 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29804 }
29805 EXPORT_SYMBOL(clear_user);
29806
29807 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29808 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29809 {
29810 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29811 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29812 - }
29813 - return len;
29814 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29815 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29816 + return len;
29817 }
29818 EXPORT_SYMBOL(copy_in_user);
29819
29820 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29821 * it is not necessary to optimize tail handling.
29822 */
29823 unsigned long
29824 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29825 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29826 {
29827 char c;
29828 unsigned zero_len;
29829
29830 + clac();
29831 + pax_close_userland();
29832 for (; len; --len, to++) {
29833 if (__get_user_nocheck(c, from++, sizeof(char)))
29834 break;
29835 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29836 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29837 if (__put_user_nocheck(c, to++, sizeof(char)))
29838 break;
29839 - clac();
29840 return len;
29841 }
29842 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29843 index 23d8e5f..9ccc13a 100644
29844 --- a/arch/x86/mm/Makefile
29845 +++ b/arch/x86/mm/Makefile
29846 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29847 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29848
29849 obj-$(CONFIG_MEMTEST) += memtest.o
29850 +
29851 +quote:="
29852 +obj-$(CONFIG_X86_64) += uderef_64.o
29853 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29854 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29855 index 903ec1e..c4166b2 100644
29856 --- a/arch/x86/mm/extable.c
29857 +++ b/arch/x86/mm/extable.c
29858 @@ -6,12 +6,24 @@
29859 static inline unsigned long
29860 ex_insn_addr(const struct exception_table_entry *x)
29861 {
29862 - return (unsigned long)&x->insn + x->insn;
29863 + unsigned long reloc = 0;
29864 +
29865 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29866 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29867 +#endif
29868 +
29869 + return (unsigned long)&x->insn + x->insn + reloc;
29870 }
29871 static inline unsigned long
29872 ex_fixup_addr(const struct exception_table_entry *x)
29873 {
29874 - return (unsigned long)&x->fixup + x->fixup;
29875 + unsigned long reloc = 0;
29876 +
29877 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29878 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29879 +#endif
29880 +
29881 + return (unsigned long)&x->fixup + x->fixup + reloc;
29882 }
29883
29884 int fixup_exception(struct pt_regs *regs)
29885 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29886 unsigned long new_ip;
29887
29888 #ifdef CONFIG_PNPBIOS
29889 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29890 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29891 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29892 extern u32 pnp_bios_is_utter_crap;
29893 pnp_bios_is_utter_crap = 1;
29894 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29895 i += 4;
29896 p->fixup -= i;
29897 i += 4;
29898 +
29899 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29900 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29901 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29902 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29903 +#endif
29904 +
29905 }
29906 }
29907
29908 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29909 index 654be4a..a4a3da1 100644
29910 --- a/arch/x86/mm/fault.c
29911 +++ b/arch/x86/mm/fault.c
29912 @@ -14,11 +14,18 @@
29913 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29914 #include <linux/prefetch.h> /* prefetchw */
29915 #include <linux/context_tracking.h> /* exception_enter(), ... */
29916 +#include <linux/unistd.h>
29917 +#include <linux/compiler.h>
29918
29919 #include <asm/traps.h> /* dotraplinkage, ... */
29920 #include <asm/pgalloc.h> /* pgd_*(), ... */
29921 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29922 #include <asm/fixmap.h> /* VSYSCALL_START */
29923 +#include <asm/tlbflush.h>
29924 +
29925 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29926 +#include <asm/stacktrace.h>
29927 +#endif
29928
29929 /*
29930 * Page fault error code bits:
29931 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29932 int ret = 0;
29933
29934 /* kprobe_running() needs smp_processor_id() */
29935 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29936 + if (kprobes_built_in() && !user_mode(regs)) {
29937 preempt_disable();
29938 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29939 ret = 1;
29940 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29941 return !instr_lo || (instr_lo>>1) == 1;
29942 case 0x00:
29943 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29944 - if (probe_kernel_address(instr, opcode))
29945 + if (user_mode(regs)) {
29946 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29947 + return 0;
29948 + } else if (probe_kernel_address(instr, opcode))
29949 return 0;
29950
29951 *prefetch = (instr_lo == 0xF) &&
29952 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29953 while (instr < max_instr) {
29954 unsigned char opcode;
29955
29956 - if (probe_kernel_address(instr, opcode))
29957 + if (user_mode(regs)) {
29958 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29959 + break;
29960 + } else if (probe_kernel_address(instr, opcode))
29961 break;
29962
29963 instr++;
29964 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29965 force_sig_info(si_signo, &info, tsk);
29966 }
29967
29968 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29969 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29970 +#endif
29971 +
29972 +#ifdef CONFIG_PAX_EMUTRAMP
29973 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29974 +#endif
29975 +
29976 +#ifdef CONFIG_PAX_PAGEEXEC
29977 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29978 +{
29979 + pgd_t *pgd;
29980 + pud_t *pud;
29981 + pmd_t *pmd;
29982 +
29983 + pgd = pgd_offset(mm, address);
29984 + if (!pgd_present(*pgd))
29985 + return NULL;
29986 + pud = pud_offset(pgd, address);
29987 + if (!pud_present(*pud))
29988 + return NULL;
29989 + pmd = pmd_offset(pud, address);
29990 + if (!pmd_present(*pmd))
29991 + return NULL;
29992 + return pmd;
29993 +}
29994 +#endif
29995 +
29996 DEFINE_SPINLOCK(pgd_lock);
29997 LIST_HEAD(pgd_list);
29998
29999 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
30000 for (address = VMALLOC_START & PMD_MASK;
30001 address >= TASK_SIZE && address < FIXADDR_TOP;
30002 address += PMD_SIZE) {
30003 +
30004 +#ifdef CONFIG_PAX_PER_CPU_PGD
30005 + unsigned long cpu;
30006 +#else
30007 struct page *page;
30008 +#endif
30009
30010 spin_lock(&pgd_lock);
30011 +
30012 +#ifdef CONFIG_PAX_PER_CPU_PGD
30013 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30014 + pgd_t *pgd = get_cpu_pgd(cpu, user);
30015 + pmd_t *ret;
30016 +
30017 + ret = vmalloc_sync_one(pgd, address);
30018 + if (!ret)
30019 + break;
30020 + pgd = get_cpu_pgd(cpu, kernel);
30021 +#else
30022 list_for_each_entry(page, &pgd_list, lru) {
30023 + pgd_t *pgd;
30024 spinlock_t *pgt_lock;
30025 pmd_t *ret;
30026
30027 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
30028 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30029
30030 spin_lock(pgt_lock);
30031 - ret = vmalloc_sync_one(page_address(page), address);
30032 + pgd = page_address(page);
30033 +#endif
30034 +
30035 + ret = vmalloc_sync_one(pgd, address);
30036 +
30037 +#ifndef CONFIG_PAX_PER_CPU_PGD
30038 spin_unlock(pgt_lock);
30039 +#endif
30040
30041 if (!ret)
30042 break;
30043 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30044 * an interrupt in the middle of a task switch..
30045 */
30046 pgd_paddr = read_cr3();
30047 +
30048 +#ifdef CONFIG_PAX_PER_CPU_PGD
30049 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30050 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30051 +#endif
30052 +
30053 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30054 if (!pmd_k)
30055 return -1;
30056 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30057 * happen within a race in page table update. In the later
30058 * case just flush:
30059 */
30060 - pgd = pgd_offset(current->active_mm, address);
30061 +
30062 pgd_ref = pgd_offset_k(address);
30063 if (pgd_none(*pgd_ref))
30064 return -1;
30065
30066 +#ifdef CONFIG_PAX_PER_CPU_PGD
30067 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30068 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30069 + if (pgd_none(*pgd)) {
30070 + set_pgd(pgd, *pgd_ref);
30071 + arch_flush_lazy_mmu_mode();
30072 + } else {
30073 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30074 + }
30075 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30076 +#else
30077 + pgd = pgd_offset(current->active_mm, address);
30078 +#endif
30079 +
30080 if (pgd_none(*pgd)) {
30081 set_pgd(pgd, *pgd_ref);
30082 arch_flush_lazy_mmu_mode();
30083 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30084 static int is_errata100(struct pt_regs *regs, unsigned long address)
30085 {
30086 #ifdef CONFIG_X86_64
30087 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30088 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30089 return 1;
30090 #endif
30091 return 0;
30092 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30093 }
30094
30095 static const char nx_warning[] = KERN_CRIT
30096 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30097 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30098
30099 static void
30100 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30101 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30102 if (!oops_may_print())
30103 return;
30104
30105 - if (error_code & PF_INSTR) {
30106 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30107 unsigned int level;
30108
30109 pte_t *pte = lookup_address(address, &level);
30110
30111 if (pte && pte_present(*pte) && !pte_exec(*pte))
30112 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30113 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30114 }
30115
30116 +#ifdef CONFIG_PAX_KERNEXEC
30117 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30118 + if (current->signal->curr_ip)
30119 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30120 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30121 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30122 + else
30123 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30124 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30125 + }
30126 +#endif
30127 +
30128 printk(KERN_ALERT "BUG: unable to handle kernel ");
30129 if (address < PAGE_SIZE)
30130 printk(KERN_CONT "NULL pointer dereference");
30131 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30132 return;
30133 }
30134 #endif
30135 +
30136 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30137 + if (pax_is_fetch_fault(regs, error_code, address)) {
30138 +
30139 +#ifdef CONFIG_PAX_EMUTRAMP
30140 + switch (pax_handle_fetch_fault(regs)) {
30141 + case 2:
30142 + return;
30143 + }
30144 +#endif
30145 +
30146 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30147 + do_group_exit(SIGKILL);
30148 + }
30149 +#endif
30150 +
30151 /* Kernel addresses are always protection faults: */
30152 if (address >= TASK_SIZE)
30153 error_code |= PF_PROT;
30154 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30155 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30156 printk(KERN_ERR
30157 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30158 - tsk->comm, tsk->pid, address);
30159 + tsk->comm, task_pid_nr(tsk), address);
30160 code = BUS_MCEERR_AR;
30161 }
30162 #endif
30163 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30164 return 1;
30165 }
30166
30167 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30168 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30169 +{
30170 + pte_t *pte;
30171 + pmd_t *pmd;
30172 + spinlock_t *ptl;
30173 + unsigned char pte_mask;
30174 +
30175 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30176 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30177 + return 0;
30178 +
30179 + /* PaX: it's our fault, let's handle it if we can */
30180 +
30181 + /* PaX: take a look at read faults before acquiring any locks */
30182 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30183 + /* instruction fetch attempt from a protected page in user mode */
30184 + up_read(&mm->mmap_sem);
30185 +
30186 +#ifdef CONFIG_PAX_EMUTRAMP
30187 + switch (pax_handle_fetch_fault(regs)) {
30188 + case 2:
30189 + return 1;
30190 + }
30191 +#endif
30192 +
30193 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30194 + do_group_exit(SIGKILL);
30195 + }
30196 +
30197 + pmd = pax_get_pmd(mm, address);
30198 + if (unlikely(!pmd))
30199 + return 0;
30200 +
30201 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30202 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30203 + pte_unmap_unlock(pte, ptl);
30204 + return 0;
30205 + }
30206 +
30207 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30208 + /* write attempt to a protected page in user mode */
30209 + pte_unmap_unlock(pte, ptl);
30210 + return 0;
30211 + }
30212 +
30213 +#ifdef CONFIG_SMP
30214 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30215 +#else
30216 + if (likely(address > get_limit(regs->cs)))
30217 +#endif
30218 + {
30219 + set_pte(pte, pte_mkread(*pte));
30220 + __flush_tlb_one(address);
30221 + pte_unmap_unlock(pte, ptl);
30222 + up_read(&mm->mmap_sem);
30223 + return 1;
30224 + }
30225 +
30226 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30227 +
30228 + /*
30229 + * PaX: fill DTLB with user rights and retry
30230 + */
30231 + __asm__ __volatile__ (
30232 + "orb %2,(%1)\n"
30233 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30234 +/*
30235 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30236 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30237 + * page fault when examined during a TLB load attempt. this is true not only
30238 + * for PTEs holding a non-present entry but also present entries that will
30239 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30240 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30241 + * for our target pages since their PTEs are simply not in the TLBs at all.
30242 +
30243 + * the best thing in omitting it is that we gain around 15-20% speed in the
30244 + * fast path of the page fault handler and can get rid of tracing since we
30245 + * can no longer flush unintended entries.
30246 + */
30247 + "invlpg (%0)\n"
30248 +#endif
30249 + __copyuser_seg"testb $0,(%0)\n"
30250 + "xorb %3,(%1)\n"
30251 + :
30252 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30253 + : "memory", "cc");
30254 + pte_unmap_unlock(pte, ptl);
30255 + up_read(&mm->mmap_sem);
30256 + return 1;
30257 +}
30258 +#endif
30259 +
30260 /*
30261 * Handle a spurious fault caused by a stale TLB entry.
30262 *
30263 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30264 static inline int
30265 access_error(unsigned long error_code, struct vm_area_struct *vma)
30266 {
30267 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30268 + return 1;
30269 +
30270 if (error_code & PF_WRITE) {
30271 /* write, present and write, not present: */
30272 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30273 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30274 if (error_code & PF_USER)
30275 return false;
30276
30277 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30278 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30279 return false;
30280
30281 return true;
30282 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30283 {
30284 struct vm_area_struct *vma;
30285 struct task_struct *tsk;
30286 - unsigned long address;
30287 struct mm_struct *mm;
30288 int fault;
30289 int write = error_code & PF_WRITE;
30290 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30291 (write ? FAULT_FLAG_WRITE : 0);
30292
30293 - tsk = current;
30294 - mm = tsk->mm;
30295 -
30296 /* Get the faulting address: */
30297 - address = read_cr2();
30298 + unsigned long address = read_cr2();
30299 +
30300 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30301 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30302 + if (!search_exception_tables(regs->ip)) {
30303 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30304 + bad_area_nosemaphore(regs, error_code, address);
30305 + return;
30306 + }
30307 + if (address < pax_user_shadow_base) {
30308 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30309 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30310 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30311 + } else
30312 + address -= pax_user_shadow_base;
30313 + }
30314 +#endif
30315 +
30316 + tsk = current;
30317 + mm = tsk->mm;
30318
30319 /*
30320 * Detect and handle instructions that would cause a page fault for
30321 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30322 * User-mode registers count as a user access even for any
30323 * potential system fault or CPU buglet:
30324 */
30325 - if (user_mode_vm(regs)) {
30326 + if (user_mode(regs)) {
30327 local_irq_enable();
30328 error_code |= PF_USER;
30329 } else {
30330 @@ -1142,6 +1365,11 @@ retry:
30331 might_sleep();
30332 }
30333
30334 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30335 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30336 + return;
30337 +#endif
30338 +
30339 vma = find_vma(mm, address);
30340 if (unlikely(!vma)) {
30341 bad_area(regs, error_code, address);
30342 @@ -1153,18 +1381,24 @@ retry:
30343 bad_area(regs, error_code, address);
30344 return;
30345 }
30346 - if (error_code & PF_USER) {
30347 - /*
30348 - * Accessing the stack below %sp is always a bug.
30349 - * The large cushion allows instructions like enter
30350 - * and pusha to work. ("enter $65535, $31" pushes
30351 - * 32 pointers and then decrements %sp by 65535.)
30352 - */
30353 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30354 - bad_area(regs, error_code, address);
30355 - return;
30356 - }
30357 + /*
30358 + * Accessing the stack below %sp is always a bug.
30359 + * The large cushion allows instructions like enter
30360 + * and pusha to work. ("enter $65535, $31" pushes
30361 + * 32 pointers and then decrements %sp by 65535.)
30362 + */
30363 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30364 + bad_area(regs, error_code, address);
30365 + return;
30366 }
30367 +
30368 +#ifdef CONFIG_PAX_SEGMEXEC
30369 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30370 + bad_area(regs, error_code, address);
30371 + return;
30372 + }
30373 +#endif
30374 +
30375 if (unlikely(expand_stack(vma, address))) {
30376 bad_area(regs, error_code, address);
30377 return;
30378 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30379 __do_page_fault(regs, error_code);
30380 exception_exit(prev_state);
30381 }
30382 +
30383 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30384 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30385 +{
30386 + struct mm_struct *mm = current->mm;
30387 + unsigned long ip = regs->ip;
30388 +
30389 + if (v8086_mode(regs))
30390 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30391 +
30392 +#ifdef CONFIG_PAX_PAGEEXEC
30393 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30394 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30395 + return true;
30396 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30397 + return true;
30398 + return false;
30399 + }
30400 +#endif
30401 +
30402 +#ifdef CONFIG_PAX_SEGMEXEC
30403 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30404 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30405 + return true;
30406 + return false;
30407 + }
30408 +#endif
30409 +
30410 + return false;
30411 +}
30412 +#endif
30413 +
30414 +#ifdef CONFIG_PAX_EMUTRAMP
30415 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30416 +{
30417 + int err;
30418 +
30419 + do { /* PaX: libffi trampoline emulation */
30420 + unsigned char mov, jmp;
30421 + unsigned int addr1, addr2;
30422 +
30423 +#ifdef CONFIG_X86_64
30424 + if ((regs->ip + 9) >> 32)
30425 + break;
30426 +#endif
30427 +
30428 + err = get_user(mov, (unsigned char __user *)regs->ip);
30429 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30430 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30431 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30432 +
30433 + if (err)
30434 + break;
30435 +
30436 + if (mov == 0xB8 && jmp == 0xE9) {
30437 + regs->ax = addr1;
30438 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30439 + return 2;
30440 + }
30441 + } while (0);
30442 +
30443 + do { /* PaX: gcc trampoline emulation #1 */
30444 + unsigned char mov1, mov2;
30445 + unsigned short jmp;
30446 + unsigned int addr1, addr2;
30447 +
30448 +#ifdef CONFIG_X86_64
30449 + if ((regs->ip + 11) >> 32)
30450 + break;
30451 +#endif
30452 +
30453 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30454 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30455 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30456 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30457 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30458 +
30459 + if (err)
30460 + break;
30461 +
30462 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30463 + regs->cx = addr1;
30464 + regs->ax = addr2;
30465 + regs->ip = addr2;
30466 + return 2;
30467 + }
30468 + } while (0);
30469 +
30470 + do { /* PaX: gcc trampoline emulation #2 */
30471 + unsigned char mov, jmp;
30472 + unsigned int addr1, addr2;
30473 +
30474 +#ifdef CONFIG_X86_64
30475 + if ((regs->ip + 9) >> 32)
30476 + break;
30477 +#endif
30478 +
30479 + err = get_user(mov, (unsigned char __user *)regs->ip);
30480 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30481 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30482 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30483 +
30484 + if (err)
30485 + break;
30486 +
30487 + if (mov == 0xB9 && jmp == 0xE9) {
30488 + regs->cx = addr1;
30489 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30490 + return 2;
30491 + }
30492 + } while (0);
30493 +
30494 + return 1; /* PaX in action */
30495 +}
30496 +
30497 +#ifdef CONFIG_X86_64
30498 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30499 +{
30500 + int err;
30501 +
30502 + do { /* PaX: libffi trampoline emulation */
30503 + unsigned short mov1, mov2, jmp1;
30504 + unsigned char stcclc, jmp2;
30505 + unsigned long addr1, addr2;
30506 +
30507 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30508 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30509 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30510 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30511 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30512 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30513 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30514 +
30515 + if (err)
30516 + break;
30517 +
30518 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30519 + regs->r11 = addr1;
30520 + regs->r10 = addr2;
30521 + if (stcclc == 0xF8)
30522 + regs->flags &= ~X86_EFLAGS_CF;
30523 + else
30524 + regs->flags |= X86_EFLAGS_CF;
30525 + regs->ip = addr1;
30526 + return 2;
30527 + }
30528 + } while (0);
30529 +
30530 + do { /* PaX: gcc trampoline emulation #1 */
30531 + unsigned short mov1, mov2, jmp1;
30532 + unsigned char jmp2;
30533 + unsigned int addr1;
30534 + unsigned long addr2;
30535 +
30536 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30537 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30538 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30539 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30540 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30541 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30542 +
30543 + if (err)
30544 + break;
30545 +
30546 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30547 + regs->r11 = addr1;
30548 + regs->r10 = addr2;
30549 + regs->ip = addr1;
30550 + return 2;
30551 + }
30552 + } while (0);
30553 +
30554 + do { /* PaX: gcc trampoline emulation #2 */
30555 + unsigned short mov1, mov2, jmp1;
30556 + unsigned char jmp2;
30557 + unsigned long addr1, addr2;
30558 +
30559 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30560 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30561 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30562 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30563 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30564 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30565 +
30566 + if (err)
30567 + break;
30568 +
30569 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30570 + regs->r11 = addr1;
30571 + regs->r10 = addr2;
30572 + regs->ip = addr1;
30573 + return 2;
30574 + }
30575 + } while (0);
30576 +
30577 + return 1; /* PaX in action */
30578 +}
30579 +#endif
30580 +
30581 +/*
30582 + * PaX: decide what to do with offenders (regs->ip = fault address)
30583 + *
30584 + * returns 1 when task should be killed
30585 + * 2 when gcc trampoline was detected
30586 + */
30587 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30588 +{
30589 + if (v8086_mode(regs))
30590 + return 1;
30591 +
30592 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30593 + return 1;
30594 +
30595 +#ifdef CONFIG_X86_32
30596 + return pax_handle_fetch_fault_32(regs);
30597 +#else
30598 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30599 + return pax_handle_fetch_fault_32(regs);
30600 + else
30601 + return pax_handle_fetch_fault_64(regs);
30602 +#endif
30603 +}
30604 +#endif
30605 +
30606 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30607 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30608 +{
30609 + long i;
30610 +
30611 + printk(KERN_ERR "PAX: bytes at PC: ");
30612 + for (i = 0; i < 20; i++) {
30613 + unsigned char c;
30614 + if (get_user(c, (unsigned char __force_user *)pc+i))
30615 + printk(KERN_CONT "?? ");
30616 + else
30617 + printk(KERN_CONT "%02x ", c);
30618 + }
30619 + printk("\n");
30620 +
30621 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30622 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30623 + unsigned long c;
30624 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30625 +#ifdef CONFIG_X86_32
30626 + printk(KERN_CONT "???????? ");
30627 +#else
30628 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30629 + printk(KERN_CONT "???????? ???????? ");
30630 + else
30631 + printk(KERN_CONT "???????????????? ");
30632 +#endif
30633 + } else {
30634 +#ifdef CONFIG_X86_64
30635 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30636 + printk(KERN_CONT "%08x ", (unsigned int)c);
30637 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30638 + } else
30639 +#endif
30640 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30641 + }
30642 + }
30643 + printk("\n");
30644 +}
30645 +#endif
30646 +
30647 +/**
30648 + * probe_kernel_write(): safely attempt to write to a location
30649 + * @dst: address to write to
30650 + * @src: pointer to the data that shall be written
30651 + * @size: size of the data chunk
30652 + *
30653 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30654 + * happens, handle that and return -EFAULT.
30655 + */
30656 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30657 +{
30658 + long ret;
30659 + mm_segment_t old_fs = get_fs();
30660 +
30661 + set_fs(KERNEL_DS);
30662 + pagefault_disable();
30663 + pax_open_kernel();
30664 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30665 + pax_close_kernel();
30666 + pagefault_enable();
30667 + set_fs(old_fs);
30668 +
30669 + return ret ? -EFAULT : 0;
30670 +}
30671 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30672 index dd74e46..7d26398 100644
30673 --- a/arch/x86/mm/gup.c
30674 +++ b/arch/x86/mm/gup.c
30675 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30676 addr = start;
30677 len = (unsigned long) nr_pages << PAGE_SHIFT;
30678 end = start + len;
30679 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30680 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30681 (void __user *)start, len)))
30682 return 0;
30683
30684 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30685 index 4500142..53a363c 100644
30686 --- a/arch/x86/mm/highmem_32.c
30687 +++ b/arch/x86/mm/highmem_32.c
30688 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30689 idx = type + KM_TYPE_NR*smp_processor_id();
30690 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30691 BUG_ON(!pte_none(*(kmap_pte-idx)));
30692 +
30693 + pax_open_kernel();
30694 set_pte(kmap_pte-idx, mk_pte(page, prot));
30695 + pax_close_kernel();
30696 +
30697 arch_flush_lazy_mmu_mode();
30698
30699 return (void *)vaddr;
30700 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30701 index 7e73e8c..11d3b86 100644
30702 --- a/arch/x86/mm/hugetlbpage.c
30703 +++ b/arch/x86/mm/hugetlbpage.c
30704 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30705 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30706 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30707 unsigned long addr, unsigned long len,
30708 - unsigned long pgoff, unsigned long flags)
30709 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30710 {
30711 struct hstate *h = hstate_file(file);
30712 struct vm_unmapped_area_info info;
30713 -
30714 +
30715 info.flags = 0;
30716 info.length = len;
30717 info.low_limit = TASK_UNMAPPED_BASE;
30718 +
30719 +#ifdef CONFIG_PAX_RANDMMAP
30720 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30721 + info.low_limit += current->mm->delta_mmap;
30722 +#endif
30723 +
30724 info.high_limit = TASK_SIZE;
30725 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30726 info.align_offset = 0;
30727 + info.threadstack_offset = offset;
30728 return vm_unmapped_area(&info);
30729 }
30730
30731 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30732 unsigned long addr0, unsigned long len,
30733 - unsigned long pgoff, unsigned long flags)
30734 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30735 {
30736 struct hstate *h = hstate_file(file);
30737 struct vm_unmapped_area_info info;
30738 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30739 info.high_limit = current->mm->mmap_base;
30740 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30741 info.align_offset = 0;
30742 + info.threadstack_offset = offset;
30743 addr = vm_unmapped_area(&info);
30744
30745 /*
30746 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30747 VM_BUG_ON(addr != -ENOMEM);
30748 info.flags = 0;
30749 info.low_limit = TASK_UNMAPPED_BASE;
30750 +
30751 +#ifdef CONFIG_PAX_RANDMMAP
30752 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30753 + info.low_limit += current->mm->delta_mmap;
30754 +#endif
30755 +
30756 info.high_limit = TASK_SIZE;
30757 addr = vm_unmapped_area(&info);
30758 }
30759 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30760 struct hstate *h = hstate_file(file);
30761 struct mm_struct *mm = current->mm;
30762 struct vm_area_struct *vma;
30763 + unsigned long pax_task_size = TASK_SIZE;
30764 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30765
30766 if (len & ~huge_page_mask(h))
30767 return -EINVAL;
30768 - if (len > TASK_SIZE)
30769 +
30770 +#ifdef CONFIG_PAX_SEGMEXEC
30771 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30772 + pax_task_size = SEGMEXEC_TASK_SIZE;
30773 +#endif
30774 +
30775 + pax_task_size -= PAGE_SIZE;
30776 +
30777 + if (len > pax_task_size)
30778 return -ENOMEM;
30779
30780 if (flags & MAP_FIXED) {
30781 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30782 return addr;
30783 }
30784
30785 +#ifdef CONFIG_PAX_RANDMMAP
30786 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30787 +#endif
30788 +
30789 if (addr) {
30790 addr = ALIGN(addr, huge_page_size(h));
30791 vma = find_vma(mm, addr);
30792 - if (TASK_SIZE - len >= addr &&
30793 - (!vma || addr + len <= vma->vm_start))
30794 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30795 return addr;
30796 }
30797 if (mm->get_unmapped_area == arch_get_unmapped_area)
30798 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30799 - pgoff, flags);
30800 + pgoff, flags, offset);
30801 else
30802 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30803 - pgoff, flags);
30804 + pgoff, flags, offset);
30805 }
30806
30807 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30808 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30809 index 04664cd..dae6e5d 100644
30810 --- a/arch/x86/mm/init.c
30811 +++ b/arch/x86/mm/init.c
30812 @@ -4,6 +4,7 @@
30813 #include <linux/swap.h>
30814 #include <linux/memblock.h>
30815 #include <linux/bootmem.h> /* for max_low_pfn */
30816 +#include <linux/tboot.h>
30817
30818 #include <asm/cacheflush.h>
30819 #include <asm/e820.h>
30820 @@ -17,6 +18,8 @@
30821 #include <asm/proto.h>
30822 #include <asm/dma.h> /* for MAX_DMA_PFN */
30823 #include <asm/microcode.h>
30824 +#include <asm/desc.h>
30825 +#include <asm/bios_ebda.h>
30826
30827 #include "mm_internal.h"
30828
30829 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30830 early_ioremap_page_table_range_init();
30831 #endif
30832
30833 +#ifdef CONFIG_PAX_PER_CPU_PGD
30834 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30835 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30836 + KERNEL_PGD_PTRS);
30837 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30838 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30839 + KERNEL_PGD_PTRS);
30840 + load_cr3(get_cpu_pgd(0, kernel));
30841 +#else
30842 load_cr3(swapper_pg_dir);
30843 +#endif
30844 +
30845 __flush_tlb_all();
30846
30847 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30848 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30849 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30850 * mmio resources as well as potential bios/acpi data regions.
30851 */
30852 +
30853 +#ifdef CONFIG_GRKERNSEC_KMEM
30854 +static unsigned int ebda_start __read_only;
30855 +static unsigned int ebda_end __read_only;
30856 +#endif
30857 +
30858 int devmem_is_allowed(unsigned long pagenr)
30859 {
30860 - if (pagenr < 256)
30861 +#ifdef CONFIG_GRKERNSEC_KMEM
30862 + /* allow BDA */
30863 + if (!pagenr)
30864 return 1;
30865 + /* allow EBDA */
30866 + if (pagenr >= ebda_start && pagenr < ebda_end)
30867 + return 1;
30868 + /* if tboot is in use, allow access to its hardcoded serial log range */
30869 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30870 + return 1;
30871 +#else
30872 + if (!pagenr)
30873 + return 1;
30874 +#ifdef CONFIG_VM86
30875 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30876 + return 1;
30877 +#endif
30878 +#endif
30879 +
30880 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30881 + return 1;
30882 +#ifdef CONFIG_GRKERNSEC_KMEM
30883 + /* throw out everything else below 1MB */
30884 + if (pagenr <= 256)
30885 + return 0;
30886 +#endif
30887 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30888 return 0;
30889 if (!page_is_ram(pagenr))
30890 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30891 #endif
30892 }
30893
30894 +#ifdef CONFIG_GRKERNSEC_KMEM
30895 +static inline void gr_init_ebda(void)
30896 +{
30897 + unsigned int ebda_addr;
30898 + unsigned int ebda_size = 0;
30899 +
30900 + ebda_addr = get_bios_ebda();
30901 + if (ebda_addr) {
30902 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30903 + ebda_size <<= 10;
30904 + }
30905 + if (ebda_addr && ebda_size) {
30906 + ebda_start = ebda_addr >> PAGE_SHIFT;
30907 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30908 + } else {
30909 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30910 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30911 + }
30912 +}
30913 +#else
30914 +static inline void gr_init_ebda(void) { }
30915 +#endif
30916 +
30917 void free_initmem(void)
30918 {
30919 +#ifdef CONFIG_PAX_KERNEXEC
30920 +#ifdef CONFIG_X86_32
30921 + /* PaX: limit KERNEL_CS to actual size */
30922 + unsigned long addr, limit;
30923 + struct desc_struct d;
30924 + int cpu;
30925 +#else
30926 + pgd_t *pgd;
30927 + pud_t *pud;
30928 + pmd_t *pmd;
30929 + unsigned long addr, end;
30930 +#endif
30931 +#endif
30932 +
30933 + gr_init_ebda();
30934 +
30935 +#ifdef CONFIG_PAX_KERNEXEC
30936 +#ifdef CONFIG_X86_32
30937 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30938 + limit = (limit - 1UL) >> PAGE_SHIFT;
30939 +
30940 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30941 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30942 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30943 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30944 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30945 + }
30946 +
30947 + /* PaX: make KERNEL_CS read-only */
30948 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30949 + if (!paravirt_enabled())
30950 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30951 +/*
30952 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30953 + pgd = pgd_offset_k(addr);
30954 + pud = pud_offset(pgd, addr);
30955 + pmd = pmd_offset(pud, addr);
30956 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30957 + }
30958 +*/
30959 +#ifdef CONFIG_X86_PAE
30960 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30961 +/*
30962 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30963 + pgd = pgd_offset_k(addr);
30964 + pud = pud_offset(pgd, addr);
30965 + pmd = pmd_offset(pud, addr);
30966 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30967 + }
30968 +*/
30969 +#endif
30970 +
30971 +#ifdef CONFIG_MODULES
30972 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30973 +#endif
30974 +
30975 +#else
30976 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30977 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30978 + pgd = pgd_offset_k(addr);
30979 + pud = pud_offset(pgd, addr);
30980 + pmd = pmd_offset(pud, addr);
30981 + if (!pmd_present(*pmd))
30982 + continue;
30983 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30984 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30985 + else
30986 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30987 + }
30988 +
30989 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30990 + end = addr + KERNEL_IMAGE_SIZE;
30991 + for (; addr < end; addr += PMD_SIZE) {
30992 + pgd = pgd_offset_k(addr);
30993 + pud = pud_offset(pgd, addr);
30994 + pmd = pmd_offset(pud, addr);
30995 + if (!pmd_present(*pmd))
30996 + continue;
30997 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30998 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30999 + }
31000 +#endif
31001 +
31002 + flush_tlb_all();
31003 +#endif
31004 +
31005 free_init_pages("unused kernel",
31006 (unsigned long)(&__init_begin),
31007 (unsigned long)(&__init_end));
31008 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
31009 index 4287f1f..3b99c71 100644
31010 --- a/arch/x86/mm/init_32.c
31011 +++ b/arch/x86/mm/init_32.c
31012 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
31013 bool __read_mostly __vmalloc_start_set = false;
31014
31015 /*
31016 - * Creates a middle page table and puts a pointer to it in the
31017 - * given global directory entry. This only returns the gd entry
31018 - * in non-PAE compilation mode, since the middle layer is folded.
31019 - */
31020 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
31021 -{
31022 - pud_t *pud;
31023 - pmd_t *pmd_table;
31024 -
31025 -#ifdef CONFIG_X86_PAE
31026 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
31027 - pmd_table = (pmd_t *)alloc_low_page();
31028 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
31029 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
31030 - pud = pud_offset(pgd, 0);
31031 - BUG_ON(pmd_table != pmd_offset(pud, 0));
31032 -
31033 - return pmd_table;
31034 - }
31035 -#endif
31036 - pud = pud_offset(pgd, 0);
31037 - pmd_table = pmd_offset(pud, 0);
31038 -
31039 - return pmd_table;
31040 -}
31041 -
31042 -/*
31043 * Create a page table and place a pointer to it in a middle page
31044 * directory entry:
31045 */
31046 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31047 pte_t *page_table = (pte_t *)alloc_low_page();
31048
31049 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31050 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31051 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31052 +#else
31053 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31054 +#endif
31055 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31056 }
31057
31058 return pte_offset_kernel(pmd, 0);
31059 }
31060
31061 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31062 +{
31063 + pud_t *pud;
31064 + pmd_t *pmd_table;
31065 +
31066 + pud = pud_offset(pgd, 0);
31067 + pmd_table = pmd_offset(pud, 0);
31068 +
31069 + return pmd_table;
31070 +}
31071 +
31072 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31073 {
31074 int pgd_idx = pgd_index(vaddr);
31075 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31076 int pgd_idx, pmd_idx;
31077 unsigned long vaddr;
31078 pgd_t *pgd;
31079 + pud_t *pud;
31080 pmd_t *pmd;
31081 pte_t *pte = NULL;
31082 unsigned long count = page_table_range_init_count(start, end);
31083 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31084 pgd = pgd_base + pgd_idx;
31085
31086 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31087 - pmd = one_md_table_init(pgd);
31088 - pmd = pmd + pmd_index(vaddr);
31089 + pud = pud_offset(pgd, vaddr);
31090 + pmd = pmd_offset(pud, vaddr);
31091 +
31092 +#ifdef CONFIG_X86_PAE
31093 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31094 +#endif
31095 +
31096 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31097 pmd++, pmd_idx++) {
31098 pte = page_table_kmap_check(one_page_table_init(pmd),
31099 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31100 }
31101 }
31102
31103 -static inline int is_kernel_text(unsigned long addr)
31104 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31105 {
31106 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31107 - return 1;
31108 - return 0;
31109 + if ((start > ktla_ktva((unsigned long)_etext) ||
31110 + end <= ktla_ktva((unsigned long)_stext)) &&
31111 + (start > ktla_ktva((unsigned long)_einittext) ||
31112 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31113 +
31114 +#ifdef CONFIG_ACPI_SLEEP
31115 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31116 +#endif
31117 +
31118 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31119 + return 0;
31120 + return 1;
31121 }
31122
31123 /*
31124 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31125 unsigned long last_map_addr = end;
31126 unsigned long start_pfn, end_pfn;
31127 pgd_t *pgd_base = swapper_pg_dir;
31128 - int pgd_idx, pmd_idx, pte_ofs;
31129 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31130 unsigned long pfn;
31131 pgd_t *pgd;
31132 + pud_t *pud;
31133 pmd_t *pmd;
31134 pte_t *pte;
31135 unsigned pages_2m, pages_4k;
31136 @@ -291,8 +295,13 @@ repeat:
31137 pfn = start_pfn;
31138 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31139 pgd = pgd_base + pgd_idx;
31140 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31141 - pmd = one_md_table_init(pgd);
31142 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31143 + pud = pud_offset(pgd, 0);
31144 + pmd = pmd_offset(pud, 0);
31145 +
31146 +#ifdef CONFIG_X86_PAE
31147 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31148 +#endif
31149
31150 if (pfn >= end_pfn)
31151 continue;
31152 @@ -304,14 +313,13 @@ repeat:
31153 #endif
31154 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31155 pmd++, pmd_idx++) {
31156 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31157 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31158
31159 /*
31160 * Map with big pages if possible, otherwise
31161 * create normal page tables:
31162 */
31163 if (use_pse) {
31164 - unsigned int addr2;
31165 pgprot_t prot = PAGE_KERNEL_LARGE;
31166 /*
31167 * first pass will use the same initial
31168 @@ -322,11 +330,7 @@ repeat:
31169 _PAGE_PSE);
31170
31171 pfn &= PMD_MASK >> PAGE_SHIFT;
31172 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31173 - PAGE_OFFSET + PAGE_SIZE-1;
31174 -
31175 - if (is_kernel_text(addr) ||
31176 - is_kernel_text(addr2))
31177 + if (is_kernel_text(address, address + PMD_SIZE))
31178 prot = PAGE_KERNEL_LARGE_EXEC;
31179
31180 pages_2m++;
31181 @@ -343,7 +347,7 @@ repeat:
31182 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31183 pte += pte_ofs;
31184 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31185 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31186 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31187 pgprot_t prot = PAGE_KERNEL;
31188 /*
31189 * first pass will use the same initial
31190 @@ -351,7 +355,7 @@ repeat:
31191 */
31192 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31193
31194 - if (is_kernel_text(addr))
31195 + if (is_kernel_text(address, address + PAGE_SIZE))
31196 prot = PAGE_KERNEL_EXEC;
31197
31198 pages_4k++;
31199 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31200
31201 pud = pud_offset(pgd, va);
31202 pmd = pmd_offset(pud, va);
31203 - if (!pmd_present(*pmd))
31204 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31205 break;
31206
31207 /* should not be large page here */
31208 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31209
31210 static void __init pagetable_init(void)
31211 {
31212 - pgd_t *pgd_base = swapper_pg_dir;
31213 -
31214 - permanent_kmaps_init(pgd_base);
31215 + permanent_kmaps_init(swapper_pg_dir);
31216 }
31217
31218 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31219 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31220 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31221
31222 /* user-defined highmem size */
31223 @@ -787,10 +789,10 @@ void __init mem_init(void)
31224 ((unsigned long)&__init_end -
31225 (unsigned long)&__init_begin) >> 10,
31226
31227 - (unsigned long)&_etext, (unsigned long)&_edata,
31228 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31229 + (unsigned long)&_sdata, (unsigned long)&_edata,
31230 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31231
31232 - (unsigned long)&_text, (unsigned long)&_etext,
31233 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31234 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31235
31236 /*
31237 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31238 if (!kernel_set_to_readonly)
31239 return;
31240
31241 + start = ktla_ktva(start);
31242 pr_debug("Set kernel text: %lx - %lx for read write\n",
31243 start, start+size);
31244
31245 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31246 if (!kernel_set_to_readonly)
31247 return;
31248
31249 + start = ktla_ktva(start);
31250 pr_debug("Set kernel text: %lx - %lx for read only\n",
31251 start, start+size);
31252
31253 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31254 unsigned long start = PFN_ALIGN(_text);
31255 unsigned long size = PFN_ALIGN(_etext) - start;
31256
31257 + start = ktla_ktva(start);
31258 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31259 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31260 size >> 10);
31261 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31262 index 104d56a..62ba13f 100644
31263 --- a/arch/x86/mm/init_64.c
31264 +++ b/arch/x86/mm/init_64.c
31265 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31266 * around without checking the pgd every time.
31267 */
31268
31269 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31270 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31271 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31272
31273 int force_personality32;
31274 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31275
31276 for (address = start; address <= end; address += PGDIR_SIZE) {
31277 const pgd_t *pgd_ref = pgd_offset_k(address);
31278 +
31279 +#ifdef CONFIG_PAX_PER_CPU_PGD
31280 + unsigned long cpu;
31281 +#else
31282 struct page *page;
31283 +#endif
31284
31285 if (pgd_none(*pgd_ref))
31286 continue;
31287
31288 spin_lock(&pgd_lock);
31289 +
31290 +#ifdef CONFIG_PAX_PER_CPU_PGD
31291 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31292 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31293 +
31294 + if (pgd_none(*pgd))
31295 + set_pgd(pgd, *pgd_ref);
31296 + else
31297 + BUG_ON(pgd_page_vaddr(*pgd)
31298 + != pgd_page_vaddr(*pgd_ref));
31299 + pgd = pgd_offset_cpu(cpu, kernel, address);
31300 +#else
31301 list_for_each_entry(page, &pgd_list, lru) {
31302 pgd_t *pgd;
31303 spinlock_t *pgt_lock;
31304 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31305 /* the pgt_lock only for Xen */
31306 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31307 spin_lock(pgt_lock);
31308 +#endif
31309
31310 if (pgd_none(*pgd))
31311 set_pgd(pgd, *pgd_ref);
31312 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31313 BUG_ON(pgd_page_vaddr(*pgd)
31314 != pgd_page_vaddr(*pgd_ref));
31315
31316 +#ifndef CONFIG_PAX_PER_CPU_PGD
31317 spin_unlock(pgt_lock);
31318 +#endif
31319 +
31320 }
31321 spin_unlock(&pgd_lock);
31322 }
31323 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31324 {
31325 if (pgd_none(*pgd)) {
31326 pud_t *pud = (pud_t *)spp_getpage();
31327 - pgd_populate(&init_mm, pgd, pud);
31328 + pgd_populate_kernel(&init_mm, pgd, pud);
31329 if (pud != pud_offset(pgd, 0))
31330 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31331 pud, pud_offset(pgd, 0));
31332 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31333 {
31334 if (pud_none(*pud)) {
31335 pmd_t *pmd = (pmd_t *) spp_getpage();
31336 - pud_populate(&init_mm, pud, pmd);
31337 + pud_populate_kernel(&init_mm, pud, pmd);
31338 if (pmd != pmd_offset(pud, 0))
31339 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31340 pmd, pmd_offset(pud, 0));
31341 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31342 pmd = fill_pmd(pud, vaddr);
31343 pte = fill_pte(pmd, vaddr);
31344
31345 + pax_open_kernel();
31346 set_pte(pte, new_pte);
31347 + pax_close_kernel();
31348
31349 /*
31350 * It's enough to flush this one mapping.
31351 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31352 pgd = pgd_offset_k((unsigned long)__va(phys));
31353 if (pgd_none(*pgd)) {
31354 pud = (pud_t *) spp_getpage();
31355 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31356 - _PAGE_USER));
31357 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31358 }
31359 pud = pud_offset(pgd, (unsigned long)__va(phys));
31360 if (pud_none(*pud)) {
31361 pmd = (pmd_t *) spp_getpage();
31362 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31363 - _PAGE_USER));
31364 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31365 }
31366 pmd = pmd_offset(pud, phys);
31367 BUG_ON(!pmd_none(*pmd));
31368 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31369 prot);
31370
31371 spin_lock(&init_mm.page_table_lock);
31372 - pud_populate(&init_mm, pud, pmd);
31373 + pud_populate_kernel(&init_mm, pud, pmd);
31374 spin_unlock(&init_mm.page_table_lock);
31375 }
31376 __flush_tlb_all();
31377 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31378 page_size_mask);
31379
31380 spin_lock(&init_mm.page_table_lock);
31381 - pgd_populate(&init_mm, pgd, pud);
31382 + pgd_populate_kernel(&init_mm, pgd, pud);
31383 spin_unlock(&init_mm.page_table_lock);
31384 pgd_changed = true;
31385 }
31386 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31387 static struct vm_area_struct gate_vma = {
31388 .vm_start = VSYSCALL_START,
31389 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31390 - .vm_page_prot = PAGE_READONLY_EXEC,
31391 - .vm_flags = VM_READ | VM_EXEC
31392 + .vm_page_prot = PAGE_READONLY,
31393 + .vm_flags = VM_READ
31394 };
31395
31396 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31397 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31398
31399 const char *arch_vma_name(struct vm_area_struct *vma)
31400 {
31401 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31402 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31403 return "[vdso]";
31404 if (vma == &gate_vma)
31405 return "[vsyscall]";
31406 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31407 index 7b179b4..6bd17777 100644
31408 --- a/arch/x86/mm/iomap_32.c
31409 +++ b/arch/x86/mm/iomap_32.c
31410 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31411 type = kmap_atomic_idx_push();
31412 idx = type + KM_TYPE_NR * smp_processor_id();
31413 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31414 +
31415 + pax_open_kernel();
31416 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31417 + pax_close_kernel();
31418 +
31419 arch_flush_lazy_mmu_mode();
31420
31421 return (void *)vaddr;
31422 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31423 index 0215e2c..1c62dab 100644
31424 --- a/arch/x86/mm/ioremap.c
31425 +++ b/arch/x86/mm/ioremap.c
31426 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31427 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31428 int is_ram = page_is_ram(pfn);
31429
31430 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31431 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31432 return NULL;
31433 WARN_ON_ONCE(is_ram);
31434 }
31435 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31436 *
31437 * Caller must ensure there is only one unmapping for the same pointer.
31438 */
31439 -void iounmap(volatile void __iomem *addr)
31440 +void iounmap(const volatile void __iomem *addr)
31441 {
31442 struct vm_struct *p, *o;
31443
31444 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31445
31446 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31447 if (page_is_ram(start >> PAGE_SHIFT))
31448 +#ifdef CONFIG_HIGHMEM
31449 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31450 +#endif
31451 return __va(phys);
31452
31453 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31454 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31455 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31456 {
31457 if (page_is_ram(phys >> PAGE_SHIFT))
31458 +#ifdef CONFIG_HIGHMEM
31459 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31460 +#endif
31461 return;
31462
31463 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31464 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31465 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31466
31467 static __initdata int after_paging_init;
31468 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31469 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31470
31471 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31472 {
31473 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31474 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31475
31476 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31477 - memset(bm_pte, 0, sizeof(bm_pte));
31478 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31479 + pmd_populate_user(&init_mm, pmd, bm_pte);
31480
31481 /*
31482 * The boot-ioremap range spans multiple pmds, for which
31483 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31484 index d87dd6d..bf3fa66 100644
31485 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31486 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31487 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31488 * memory (e.g. tracked pages)? For now, we need this to avoid
31489 * invoking kmemcheck for PnP BIOS calls.
31490 */
31491 - if (regs->flags & X86_VM_MASK)
31492 + if (v8086_mode(regs))
31493 return false;
31494 - if (regs->cs != __KERNEL_CS)
31495 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31496 return false;
31497
31498 pte = kmemcheck_pte_lookup(address);
31499 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31500 index 25e7e13..1964579 100644
31501 --- a/arch/x86/mm/mmap.c
31502 +++ b/arch/x86/mm/mmap.c
31503 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31504 * Leave an at least ~128 MB hole with possible stack randomization.
31505 */
31506 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31507 -#define MAX_GAP (TASK_SIZE/6*5)
31508 +#define MAX_GAP (pax_task_size/6*5)
31509
31510 static int mmap_is_legacy(void)
31511 {
31512 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31513 return rnd << PAGE_SHIFT;
31514 }
31515
31516 -static unsigned long mmap_base(void)
31517 +static unsigned long mmap_base(struct mm_struct *mm)
31518 {
31519 unsigned long gap = rlimit(RLIMIT_STACK);
31520 + unsigned long pax_task_size = TASK_SIZE;
31521 +
31522 +#ifdef CONFIG_PAX_SEGMEXEC
31523 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31524 + pax_task_size = SEGMEXEC_TASK_SIZE;
31525 +#endif
31526
31527 if (gap < MIN_GAP)
31528 gap = MIN_GAP;
31529 else if (gap > MAX_GAP)
31530 gap = MAX_GAP;
31531
31532 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31533 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31534 }
31535
31536 /*
31537 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31538 * does, but not when emulating X86_32
31539 */
31540 -static unsigned long mmap_legacy_base(void)
31541 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31542 {
31543 - if (mmap_is_ia32())
31544 + if (mmap_is_ia32()) {
31545 +
31546 +#ifdef CONFIG_PAX_SEGMEXEC
31547 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31548 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31549 + else
31550 +#endif
31551 +
31552 return TASK_UNMAPPED_BASE;
31553 - else
31554 + } else
31555 return TASK_UNMAPPED_BASE + mmap_rnd();
31556 }
31557
31558 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31559 */
31560 void arch_pick_mmap_layout(struct mm_struct *mm)
31561 {
31562 - mm->mmap_legacy_base = mmap_legacy_base();
31563 - mm->mmap_base = mmap_base();
31564 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31565 + mm->mmap_base = mmap_base(mm);
31566 +
31567 +#ifdef CONFIG_PAX_RANDMMAP
31568 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31569 + mm->mmap_legacy_base += mm->delta_mmap;
31570 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31571 + }
31572 +#endif
31573
31574 if (mmap_is_legacy()) {
31575 mm->mmap_base = mm->mmap_legacy_base;
31576 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31577 index 0057a7a..95c7edd 100644
31578 --- a/arch/x86/mm/mmio-mod.c
31579 +++ b/arch/x86/mm/mmio-mod.c
31580 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31581 break;
31582 default:
31583 {
31584 - unsigned char *ip = (unsigned char *)instptr;
31585 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31586 my_trace->opcode = MMIO_UNKNOWN_OP;
31587 my_trace->width = 0;
31588 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31589 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31590 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31591 void __iomem *addr)
31592 {
31593 - static atomic_t next_id;
31594 + static atomic_unchecked_t next_id;
31595 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31596 /* These are page-unaligned. */
31597 struct mmiotrace_map map = {
31598 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31599 .private = trace
31600 },
31601 .phys = offset,
31602 - .id = atomic_inc_return(&next_id)
31603 + .id = atomic_inc_return_unchecked(&next_id)
31604 };
31605 map.map_id = trace->id;
31606
31607 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31608 ioremap_trace_core(offset, size, addr);
31609 }
31610
31611 -static void iounmap_trace_core(volatile void __iomem *addr)
31612 +static void iounmap_trace_core(const volatile void __iomem *addr)
31613 {
31614 struct mmiotrace_map map = {
31615 .phys = 0,
31616 @@ -328,7 +328,7 @@ not_enabled:
31617 }
31618 }
31619
31620 -void mmiotrace_iounmap(volatile void __iomem *addr)
31621 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31622 {
31623 might_sleep();
31624 if (is_enabled()) /* recheck and proper locking in *_core() */
31625 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31626 index 8bf93ba..dbcd670 100644
31627 --- a/arch/x86/mm/numa.c
31628 +++ b/arch/x86/mm/numa.c
31629 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31630 return true;
31631 }
31632
31633 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31634 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31635 {
31636 unsigned long uninitialized_var(pfn_align);
31637 int i, nid;
31638 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31639 index d0b1773..4c3327c 100644
31640 --- a/arch/x86/mm/pageattr-test.c
31641 +++ b/arch/x86/mm/pageattr-test.c
31642 @@ -36,7 +36,7 @@ enum {
31643
31644 static int pte_testbit(pte_t pte)
31645 {
31646 - return pte_flags(pte) & _PAGE_UNUSED1;
31647 + return pte_flags(pte) & _PAGE_CPA_TEST;
31648 }
31649
31650 struct split_state {
31651 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31652 index bb32480..75f2f5e 100644
31653 --- a/arch/x86/mm/pageattr.c
31654 +++ b/arch/x86/mm/pageattr.c
31655 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31656 */
31657 #ifdef CONFIG_PCI_BIOS
31658 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31659 - pgprot_val(forbidden) |= _PAGE_NX;
31660 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31661 #endif
31662
31663 /*
31664 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31665 * Does not cover __inittext since that is gone later on. On
31666 * 64bit we do not enforce !NX on the low mapping
31667 */
31668 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31669 - pgprot_val(forbidden) |= _PAGE_NX;
31670 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31671 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31672
31673 +#ifdef CONFIG_DEBUG_RODATA
31674 /*
31675 * The .rodata section needs to be read-only. Using the pfn
31676 * catches all aliases.
31677 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31678 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31679 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31680 pgprot_val(forbidden) |= _PAGE_RW;
31681 +#endif
31682
31683 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31684 /*
31685 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31686 }
31687 #endif
31688
31689 +#ifdef CONFIG_PAX_KERNEXEC
31690 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31691 + pgprot_val(forbidden) |= _PAGE_RW;
31692 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31693 + }
31694 +#endif
31695 +
31696 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31697
31698 return prot;
31699 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31700 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31701 {
31702 /* change init_mm */
31703 + pax_open_kernel();
31704 set_pte_atomic(kpte, pte);
31705 +
31706 #ifdef CONFIG_X86_32
31707 if (!SHARED_KERNEL_PMD) {
31708 +
31709 +#ifdef CONFIG_PAX_PER_CPU_PGD
31710 + unsigned long cpu;
31711 +#else
31712 struct page *page;
31713 +#endif
31714
31715 +#ifdef CONFIG_PAX_PER_CPU_PGD
31716 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31717 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31718 +#else
31719 list_for_each_entry(page, &pgd_list, lru) {
31720 - pgd_t *pgd;
31721 + pgd_t *pgd = (pgd_t *)page_address(page);
31722 +#endif
31723 +
31724 pud_t *pud;
31725 pmd_t *pmd;
31726
31727 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31728 + pgd += pgd_index(address);
31729 pud = pud_offset(pgd, address);
31730 pmd = pmd_offset(pud, address);
31731 set_pte_atomic((pte_t *)pmd, pte);
31732 }
31733 }
31734 #endif
31735 + pax_close_kernel();
31736 }
31737
31738 static int
31739 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31740 index 6574388..87e9bef 100644
31741 --- a/arch/x86/mm/pat.c
31742 +++ b/arch/x86/mm/pat.c
31743 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31744
31745 if (!entry) {
31746 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31747 - current->comm, current->pid, start, end - 1);
31748 + current->comm, task_pid_nr(current), start, end - 1);
31749 return -EINVAL;
31750 }
31751
31752 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31753
31754 while (cursor < to) {
31755 if (!devmem_is_allowed(pfn)) {
31756 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31757 - current->comm, from, to - 1);
31758 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31759 + current->comm, from, to - 1, cursor);
31760 return 0;
31761 }
31762 cursor += PAGE_SIZE;
31763 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31764 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31765 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31766 "for [mem %#010Lx-%#010Lx]\n",
31767 - current->comm, current->pid,
31768 + current->comm, task_pid_nr(current),
31769 cattr_name(flags),
31770 base, (unsigned long long)(base + size-1));
31771 return -EINVAL;
31772 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31773 flags = lookup_memtype(paddr);
31774 if (want_flags != flags) {
31775 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31776 - current->comm, current->pid,
31777 + current->comm, task_pid_nr(current),
31778 cattr_name(want_flags),
31779 (unsigned long long)paddr,
31780 (unsigned long long)(paddr + size - 1),
31781 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31782 free_memtype(paddr, paddr + size);
31783 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31784 " for [mem %#010Lx-%#010Lx], got %s\n",
31785 - current->comm, current->pid,
31786 + current->comm, task_pid_nr(current),
31787 cattr_name(want_flags),
31788 (unsigned long long)paddr,
31789 (unsigned long long)(paddr + size - 1),
31790 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31791 index 415f6c4..d319983 100644
31792 --- a/arch/x86/mm/pat_rbtree.c
31793 +++ b/arch/x86/mm/pat_rbtree.c
31794 @@ -160,7 +160,7 @@ success:
31795
31796 failure:
31797 printk(KERN_INFO "%s:%d conflicting memory types "
31798 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31799 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31800 end, cattr_name(found_type), cattr_name(match->type));
31801 return -EBUSY;
31802 }
31803 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31804 index 9f0614d..92ae64a 100644
31805 --- a/arch/x86/mm/pf_in.c
31806 +++ b/arch/x86/mm/pf_in.c
31807 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31808 int i;
31809 enum reason_type rv = OTHERS;
31810
31811 - p = (unsigned char *)ins_addr;
31812 + p = (unsigned char *)ktla_ktva(ins_addr);
31813 p += skip_prefix(p, &prf);
31814 p += get_opcode(p, &opcode);
31815
31816 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31817 struct prefix_bits prf;
31818 int i;
31819
31820 - p = (unsigned char *)ins_addr;
31821 + p = (unsigned char *)ktla_ktva(ins_addr);
31822 p += skip_prefix(p, &prf);
31823 p += get_opcode(p, &opcode);
31824
31825 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31826 struct prefix_bits prf;
31827 int i;
31828
31829 - p = (unsigned char *)ins_addr;
31830 + p = (unsigned char *)ktla_ktva(ins_addr);
31831 p += skip_prefix(p, &prf);
31832 p += get_opcode(p, &opcode);
31833
31834 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31835 struct prefix_bits prf;
31836 int i;
31837
31838 - p = (unsigned char *)ins_addr;
31839 + p = (unsigned char *)ktla_ktva(ins_addr);
31840 p += skip_prefix(p, &prf);
31841 p += get_opcode(p, &opcode);
31842 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31843 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31844 struct prefix_bits prf;
31845 int i;
31846
31847 - p = (unsigned char *)ins_addr;
31848 + p = (unsigned char *)ktla_ktva(ins_addr);
31849 p += skip_prefix(p, &prf);
31850 p += get_opcode(p, &opcode);
31851 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31852 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31853 index dfa537a..fd45c64 100644
31854 --- a/arch/x86/mm/pgtable.c
31855 +++ b/arch/x86/mm/pgtable.c
31856 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31857 list_del(&page->lru);
31858 }
31859
31860 -#define UNSHARED_PTRS_PER_PGD \
31861 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31862 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31863 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31864
31865 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31866 +{
31867 + unsigned int count = USER_PGD_PTRS;
31868
31869 + if (!pax_user_shadow_base)
31870 + return;
31871 +
31872 + while (count--)
31873 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31874 +}
31875 +#endif
31876 +
31877 +#ifdef CONFIG_PAX_PER_CPU_PGD
31878 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31879 +{
31880 + unsigned int count = USER_PGD_PTRS;
31881 +
31882 + while (count--) {
31883 + pgd_t pgd;
31884 +
31885 +#ifdef CONFIG_X86_64
31886 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31887 +#else
31888 + pgd = *src++;
31889 +#endif
31890 +
31891 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31892 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31893 +#endif
31894 +
31895 + *dst++ = pgd;
31896 + }
31897 +
31898 +}
31899 +#endif
31900 +
31901 +#ifdef CONFIG_X86_64
31902 +#define pxd_t pud_t
31903 +#define pyd_t pgd_t
31904 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31905 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31906 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31907 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31908 +#define PYD_SIZE PGDIR_SIZE
31909 +#else
31910 +#define pxd_t pmd_t
31911 +#define pyd_t pud_t
31912 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31913 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31914 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31915 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31916 +#define PYD_SIZE PUD_SIZE
31917 +#endif
31918 +
31919 +#ifdef CONFIG_PAX_PER_CPU_PGD
31920 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31921 +static inline void pgd_dtor(pgd_t *pgd) {}
31922 +#else
31923 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31924 {
31925 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31926 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31927 pgd_list_del(pgd);
31928 spin_unlock(&pgd_lock);
31929 }
31930 +#endif
31931
31932 /*
31933 * List of all pgd's needed for non-PAE so it can invalidate entries
31934 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31935 * -- nyc
31936 */
31937
31938 -#ifdef CONFIG_X86_PAE
31939 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31940 /*
31941 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31942 * updating the top-level pagetable entries to guarantee the
31943 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31944 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31945 * and initialize the kernel pmds here.
31946 */
31947 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31948 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31949
31950 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31951 {
31952 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31953 */
31954 flush_tlb_mm(mm);
31955 }
31956 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31957 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31958 #else /* !CONFIG_X86_PAE */
31959
31960 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31961 -#define PREALLOCATED_PMDS 0
31962 +#define PREALLOCATED_PXDS 0
31963
31964 #endif /* CONFIG_X86_PAE */
31965
31966 -static void free_pmds(pmd_t *pmds[])
31967 +static void free_pxds(pxd_t *pxds[])
31968 {
31969 int i;
31970
31971 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31972 - if (pmds[i])
31973 - free_page((unsigned long)pmds[i]);
31974 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31975 + if (pxds[i])
31976 + free_page((unsigned long)pxds[i]);
31977 }
31978
31979 -static int preallocate_pmds(pmd_t *pmds[])
31980 +static int preallocate_pxds(pxd_t *pxds[])
31981 {
31982 int i;
31983 bool failed = false;
31984
31985 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31986 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31987 - if (pmd == NULL)
31988 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31989 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31990 + if (pxd == NULL)
31991 failed = true;
31992 - pmds[i] = pmd;
31993 + pxds[i] = pxd;
31994 }
31995
31996 if (failed) {
31997 - free_pmds(pmds);
31998 + free_pxds(pxds);
31999 return -ENOMEM;
32000 }
32001
32002 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
32003 * preallocate which never got a corresponding vma will need to be
32004 * freed manually.
32005 */
32006 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
32007 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
32008 {
32009 int i;
32010
32011 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32012 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32013 pgd_t pgd = pgdp[i];
32014
32015 if (pgd_val(pgd) != 0) {
32016 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
32017 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
32018
32019 - pgdp[i] = native_make_pgd(0);
32020 + set_pgd(pgdp + i, native_make_pgd(0));
32021
32022 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
32023 - pmd_free(mm, pmd);
32024 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
32025 + pxd_free(mm, pxd);
32026 }
32027 }
32028 }
32029
32030 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
32031 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
32032 {
32033 - pud_t *pud;
32034 + pyd_t *pyd;
32035 int i;
32036
32037 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
32038 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
32039 return;
32040
32041 - pud = pud_offset(pgd, 0);
32042 -
32043 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
32044 - pmd_t *pmd = pmds[i];
32045 +#ifdef CONFIG_X86_64
32046 + pyd = pyd_offset(mm, 0L);
32047 +#else
32048 + pyd = pyd_offset(pgd, 0L);
32049 +#endif
32050
32051 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32052 + pxd_t *pxd = pxds[i];
32053 if (i >= KERNEL_PGD_BOUNDARY)
32054 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32055 - sizeof(pmd_t) * PTRS_PER_PMD);
32056 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32057 + sizeof(pxd_t) * PTRS_PER_PMD);
32058
32059 - pud_populate(mm, pud, pmd);
32060 + pyd_populate(mm, pyd, pxd);
32061 }
32062 }
32063
32064 pgd_t *pgd_alloc(struct mm_struct *mm)
32065 {
32066 pgd_t *pgd;
32067 - pmd_t *pmds[PREALLOCATED_PMDS];
32068 + pxd_t *pxds[PREALLOCATED_PXDS];
32069
32070 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32071
32072 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32073
32074 mm->pgd = pgd;
32075
32076 - if (preallocate_pmds(pmds) != 0)
32077 + if (preallocate_pxds(pxds) != 0)
32078 goto out_free_pgd;
32079
32080 if (paravirt_pgd_alloc(mm) != 0)
32081 - goto out_free_pmds;
32082 + goto out_free_pxds;
32083
32084 /*
32085 * Make sure that pre-populating the pmds is atomic with
32086 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32087 spin_lock(&pgd_lock);
32088
32089 pgd_ctor(mm, pgd);
32090 - pgd_prepopulate_pmd(mm, pgd, pmds);
32091 + pgd_prepopulate_pxd(mm, pgd, pxds);
32092
32093 spin_unlock(&pgd_lock);
32094
32095 return pgd;
32096
32097 -out_free_pmds:
32098 - free_pmds(pmds);
32099 +out_free_pxds:
32100 + free_pxds(pxds);
32101 out_free_pgd:
32102 free_page((unsigned long)pgd);
32103 out:
32104 @@ -300,7 +363,7 @@ out:
32105
32106 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32107 {
32108 - pgd_mop_up_pmds(mm, pgd);
32109 + pgd_mop_up_pxds(mm, pgd);
32110 pgd_dtor(pgd);
32111 paravirt_pgd_free(mm, pgd);
32112 free_page((unsigned long)pgd);
32113 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32114 index a69bcb8..19068ab 100644
32115 --- a/arch/x86/mm/pgtable_32.c
32116 +++ b/arch/x86/mm/pgtable_32.c
32117 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32118 return;
32119 }
32120 pte = pte_offset_kernel(pmd, vaddr);
32121 +
32122 + pax_open_kernel();
32123 if (pte_val(pteval))
32124 set_pte_at(&init_mm, vaddr, pte, pteval);
32125 else
32126 pte_clear(&init_mm, vaddr, pte);
32127 + pax_close_kernel();
32128
32129 /*
32130 * It's enough to flush this one mapping.
32131 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32132 index e666cbb..61788c45 100644
32133 --- a/arch/x86/mm/physaddr.c
32134 +++ b/arch/x86/mm/physaddr.c
32135 @@ -10,7 +10,7 @@
32136 #ifdef CONFIG_X86_64
32137
32138 #ifdef CONFIG_DEBUG_VIRTUAL
32139 -unsigned long __phys_addr(unsigned long x)
32140 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32141 {
32142 unsigned long y = x - __START_KERNEL_map;
32143
32144 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32145 #else
32146
32147 #ifdef CONFIG_DEBUG_VIRTUAL
32148 -unsigned long __phys_addr(unsigned long x)
32149 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32150 {
32151 unsigned long phys_addr = x - PAGE_OFFSET;
32152 /* VMALLOC_* aren't constants */
32153 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32154 index 90555bf..f5f1828 100644
32155 --- a/arch/x86/mm/setup_nx.c
32156 +++ b/arch/x86/mm/setup_nx.c
32157 @@ -5,8 +5,10 @@
32158 #include <asm/pgtable.h>
32159 #include <asm/proto.h>
32160
32161 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32162 static int disable_nx;
32163
32164 +#ifndef CONFIG_PAX_PAGEEXEC
32165 /*
32166 * noexec = on|off
32167 *
32168 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32169 return 0;
32170 }
32171 early_param("noexec", noexec_setup);
32172 +#endif
32173 +
32174 +#endif
32175
32176 void x86_configure_nx(void)
32177 {
32178 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32179 if (cpu_has_nx && !disable_nx)
32180 __supported_pte_mask |= _PAGE_NX;
32181 else
32182 +#endif
32183 __supported_pte_mask &= ~_PAGE_NX;
32184 }
32185
32186 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32187 index 282375f..e03a98f 100644
32188 --- a/arch/x86/mm/tlb.c
32189 +++ b/arch/x86/mm/tlb.c
32190 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32191 BUG();
32192 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32193 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32194 +
32195 +#ifndef CONFIG_PAX_PER_CPU_PGD
32196 load_cr3(swapper_pg_dir);
32197 +#endif
32198 +
32199 }
32200 }
32201 EXPORT_SYMBOL_GPL(leave_mm);
32202 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32203 new file mode 100644
32204 index 0000000..dace51c
32205 --- /dev/null
32206 +++ b/arch/x86/mm/uderef_64.c
32207 @@ -0,0 +1,37 @@
32208 +#include <linux/mm.h>
32209 +#include <asm/pgtable.h>
32210 +#include <asm/uaccess.h>
32211 +
32212 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32213 +/* PaX: due to the special call convention these functions must
32214 + * - remain leaf functions under all configurations,
32215 + * - never be called directly, only dereferenced from the wrappers.
32216 + */
32217 +void __pax_open_userland(void)
32218 +{
32219 + unsigned int cpu;
32220 +
32221 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32222 + return;
32223 +
32224 + cpu = raw_get_cpu();
32225 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32226 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32227 + raw_put_cpu_no_resched();
32228 +}
32229 +EXPORT_SYMBOL(__pax_open_userland);
32230 +
32231 +void __pax_close_userland(void)
32232 +{
32233 + unsigned int cpu;
32234 +
32235 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32236 + return;
32237 +
32238 + cpu = raw_get_cpu();
32239 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32240 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32241 + raw_put_cpu_no_resched();
32242 +}
32243 +EXPORT_SYMBOL(__pax_close_userland);
32244 +#endif
32245 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32246 index 877b9a1..a8ecf42 100644
32247 --- a/arch/x86/net/bpf_jit.S
32248 +++ b/arch/x86/net/bpf_jit.S
32249 @@ -9,6 +9,7 @@
32250 */
32251 #include <linux/linkage.h>
32252 #include <asm/dwarf2.h>
32253 +#include <asm/alternative-asm.h>
32254
32255 /*
32256 * Calling convention :
32257 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32258 jle bpf_slow_path_word
32259 mov (SKBDATA,%rsi),%eax
32260 bswap %eax /* ntohl() */
32261 + pax_force_retaddr
32262 ret
32263
32264 sk_load_half:
32265 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32266 jle bpf_slow_path_half
32267 movzwl (SKBDATA,%rsi),%eax
32268 rol $8,%ax # ntohs()
32269 + pax_force_retaddr
32270 ret
32271
32272 sk_load_byte:
32273 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32274 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32275 jle bpf_slow_path_byte
32276 movzbl (SKBDATA,%rsi),%eax
32277 + pax_force_retaddr
32278 ret
32279
32280 /**
32281 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32282 movzbl (SKBDATA,%rsi),%ebx
32283 and $15,%bl
32284 shl $2,%bl
32285 + pax_force_retaddr
32286 ret
32287
32288 /* rsi contains offset and can be scratched */
32289 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32290 js bpf_error
32291 mov -12(%rbp),%eax
32292 bswap %eax
32293 + pax_force_retaddr
32294 ret
32295
32296 bpf_slow_path_half:
32297 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32298 mov -12(%rbp),%ax
32299 rol $8,%ax
32300 movzwl %ax,%eax
32301 + pax_force_retaddr
32302 ret
32303
32304 bpf_slow_path_byte:
32305 bpf_slow_path_common(1)
32306 js bpf_error
32307 movzbl -12(%rbp),%eax
32308 + pax_force_retaddr
32309 ret
32310
32311 bpf_slow_path_byte_msh:
32312 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32313 and $15,%al
32314 shl $2,%al
32315 xchg %eax,%ebx
32316 + pax_force_retaddr
32317 ret
32318
32319 #define sk_negative_common(SIZE) \
32320 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32321 sk_negative_common(4)
32322 mov (%rax), %eax
32323 bswap %eax
32324 + pax_force_retaddr
32325 ret
32326
32327 bpf_slow_path_half_neg:
32328 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32329 mov (%rax),%ax
32330 rol $8,%ax
32331 movzwl %ax,%eax
32332 + pax_force_retaddr
32333 ret
32334
32335 bpf_slow_path_byte_neg:
32336 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32337 .globl sk_load_byte_negative_offset
32338 sk_negative_common(1)
32339 movzbl (%rax), %eax
32340 + pax_force_retaddr
32341 ret
32342
32343 bpf_slow_path_byte_msh_neg:
32344 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32345 and $15,%al
32346 shl $2,%al
32347 xchg %eax,%ebx
32348 + pax_force_retaddr
32349 ret
32350
32351 bpf_error:
32352 @@ -197,4 +210,5 @@ bpf_error:
32353 xor %eax,%eax
32354 mov -8(%rbp),%rbx
32355 leaveq
32356 + pax_force_retaddr
32357 ret
32358 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32359 index 79c216a..08d39cc 100644
32360 --- a/arch/x86/net/bpf_jit_comp.c
32361 +++ b/arch/x86/net/bpf_jit_comp.c
32362 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32363 return ptr + len;
32364 }
32365
32366 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32367 +#define MAX_INSTR_CODE_SIZE 96
32368 +#else
32369 +#define MAX_INSTR_CODE_SIZE 64
32370 +#endif
32371 +
32372 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32373
32374 #define EMIT1(b1) EMIT(b1, 1)
32375 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32376 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32377 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32378 +
32379 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32380 +/* original constant will appear in ecx */
32381 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32382 +do { \
32383 + /* mov ecx, randkey */ \
32384 + EMIT1(0xb9); \
32385 + EMIT(_key, 4); \
32386 + /* xor ecx, randkey ^ off */ \
32387 + EMIT2(0x81, 0xf1); \
32388 + EMIT((_key) ^ (_off), 4); \
32389 +} while (0)
32390 +
32391 +#define EMIT1_off32(b1, _off) \
32392 +do { \
32393 + switch (b1) { \
32394 + case 0x05: /* add eax, imm32 */ \
32395 + case 0x2d: /* sub eax, imm32 */ \
32396 + case 0x25: /* and eax, imm32 */ \
32397 + case 0x0d: /* or eax, imm32 */ \
32398 + case 0xb8: /* mov eax, imm32 */ \
32399 + case 0x35: /* xor eax, imm32 */ \
32400 + case 0x3d: /* cmp eax, imm32 */ \
32401 + case 0xa9: /* test eax, imm32 */ \
32402 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32403 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32404 + break; \
32405 + case 0xbb: /* mov ebx, imm32 */ \
32406 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32407 + /* mov ebx, ecx */ \
32408 + EMIT2(0x89, 0xcb); \
32409 + break; \
32410 + case 0xbe: /* mov esi, imm32 */ \
32411 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32412 + /* mov esi, ecx */ \
32413 + EMIT2(0x89, 0xce); \
32414 + break; \
32415 + case 0xe8: /* call rel imm32, always to known funcs */ \
32416 + EMIT1(b1); \
32417 + EMIT(_off, 4); \
32418 + break; \
32419 + case 0xe9: /* jmp rel imm32 */ \
32420 + EMIT1(b1); \
32421 + EMIT(_off, 4); \
32422 + /* prevent fall-through, we're not called if off = 0 */ \
32423 + EMIT(0xcccccccc, 4); \
32424 + EMIT(0xcccccccc, 4); \
32425 + break; \
32426 + default: \
32427 + BUILD_BUG(); \
32428 + } \
32429 +} while (0)
32430 +
32431 +#define EMIT2_off32(b1, b2, _off) \
32432 +do { \
32433 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32434 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32435 + EMIT(randkey, 4); \
32436 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32437 + EMIT((_off) - randkey, 4); \
32438 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32439 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32440 + /* imul eax, ecx */ \
32441 + EMIT3(0x0f, 0xaf, 0xc1); \
32442 + } else { \
32443 + BUILD_BUG(); \
32444 + } \
32445 +} while (0)
32446 +#else
32447 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32448 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32449 +#endif
32450
32451 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32452 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32453 @@ -91,6 +168,24 @@ do { \
32454 #define X86_JBE 0x76
32455 #define X86_JA 0x77
32456
32457 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32458 +#define APPEND_FLOW_VERIFY() \
32459 +do { \
32460 + /* mov ecx, randkey */ \
32461 + EMIT1(0xb9); \
32462 + EMIT(randkey, 4); \
32463 + /* cmp ecx, randkey */ \
32464 + EMIT2(0x81, 0xf9); \
32465 + EMIT(randkey, 4); \
32466 + /* jz after 8 int 3s */ \
32467 + EMIT2(0x74, 0x08); \
32468 + EMIT(0xcccccccc, 4); \
32469 + EMIT(0xcccccccc, 4); \
32470 +} while (0)
32471 +#else
32472 +#define APPEND_FLOW_VERIFY() do { } while (0)
32473 +#endif
32474 +
32475 #define EMIT_COND_JMP(op, offset) \
32476 do { \
32477 if (is_near(offset)) \
32478 @@ -98,6 +193,7 @@ do { \
32479 else { \
32480 EMIT2(0x0f, op + 0x10); \
32481 EMIT(offset, 4); /* jxx .+off32 */ \
32482 + APPEND_FLOW_VERIFY(); \
32483 } \
32484 } while (0)
32485
32486 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32487 return -1;
32488 }
32489
32490 -struct bpf_binary_header {
32491 - unsigned int pages;
32492 - /* Note : for security reasons, bpf code will follow a randomly
32493 - * sized amount of int3 instructions
32494 - */
32495 - u8 image[];
32496 -};
32497 -
32498 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32499 +/* Note : for security reasons, bpf code will follow a randomly
32500 + * sized amount of int3 instructions
32501 + */
32502 +static u8 *bpf_alloc_binary(unsigned int proglen,
32503 u8 **image_ptr)
32504 {
32505 unsigned int sz, hole;
32506 - struct bpf_binary_header *header;
32507 + u8 *header;
32508
32509 /* Most of BPF filters are really small,
32510 * but if some of them fill a page, allow at least
32511 * 128 extra bytes to insert a random section of int3
32512 */
32513 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32514 - header = module_alloc(sz);
32515 + sz = round_up(proglen + 128, PAGE_SIZE);
32516 + header = module_alloc_exec(sz);
32517 if (!header)
32518 return NULL;
32519
32520 + pax_open_kernel();
32521 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32522 + pax_close_kernel();
32523
32524 - header->pages = sz / PAGE_SIZE;
32525 - hole = sz - (proglen + sizeof(*header));
32526 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32527
32528 /* insert a random number of int3 instructions before BPF code */
32529 - *image_ptr = &header->image[prandom_u32() % hole];
32530 + *image_ptr = &header[prandom_u32() % hole];
32531 return header;
32532 }
32533
32534 void bpf_jit_compile(struct sk_filter *fp)
32535 {
32536 - u8 temp[64];
32537 + u8 temp[MAX_INSTR_CODE_SIZE];
32538 u8 *prog;
32539 unsigned int proglen, oldproglen = 0;
32540 int ilen, i;
32541 int t_offset, f_offset;
32542 u8 t_op, f_op, seen = 0, pass;
32543 u8 *image = NULL;
32544 - struct bpf_binary_header *header = NULL;
32545 + u8 *header = NULL;
32546 u8 *func;
32547 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32548 unsigned int cleanup_addr; /* epilogue code offset */
32549 unsigned int *addrs;
32550 const struct sock_filter *filter = fp->insns;
32551 int flen = fp->len;
32552 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32553 + unsigned int randkey;
32554 +#endif
32555
32556 if (!bpf_jit_enable)
32557 return;
32558 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32559 if (addrs == NULL)
32560 return;
32561
32562 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32563 + randkey = get_random_int();
32564 +#endif
32565 +
32566 /* Before first pass, make a rough estimation of addrs[]
32567 - * each bpf instruction is translated to less than 64 bytes
32568 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32569 */
32570 for (proglen = 0, i = 0; i < flen; i++) {
32571 - proglen += 64;
32572 + proglen += MAX_INSTR_CODE_SIZE;
32573 addrs[i] = proglen;
32574 }
32575 cleanup_addr = proglen; /* epilogue address */
32576 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32577 case BPF_S_ALU_MUL_K: /* A *= K */
32578 if (is_imm8(K))
32579 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32580 - else {
32581 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32582 - EMIT(K, 4);
32583 - }
32584 + else
32585 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32586 break;
32587 case BPF_S_ALU_DIV_X: /* A /= X; */
32588 seen |= SEEN_XREG;
32589 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32590 break;
32591 case BPF_S_ALU_MOD_K: /* A %= K; */
32592 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32593 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32594 + DILUTE_CONST_SEQUENCE(K, randkey);
32595 +#else
32596 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32597 +#endif
32598 EMIT2(0xf7, 0xf1); /* div %ecx */
32599 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32600 break;
32601 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32602 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32603 + DILUTE_CONST_SEQUENCE(K, randkey);
32604 + // imul rax, rcx
32605 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32606 +#else
32607 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32608 EMIT(K, 4);
32609 +#endif
32610 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32611 break;
32612 case BPF_S_ALU_AND_X:
32613 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32614 if (is_imm8(K)) {
32615 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32616 } else {
32617 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32618 - EMIT(K, 4);
32619 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32620 }
32621 } else {
32622 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32623 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32624 if (unlikely(proglen + ilen > oldproglen)) {
32625 pr_err("bpb_jit_compile fatal error\n");
32626 kfree(addrs);
32627 - module_free(NULL, header);
32628 + module_free_exec(NULL, image);
32629 return;
32630 }
32631 + pax_open_kernel();
32632 memcpy(image + proglen, temp, ilen);
32633 + pax_close_kernel();
32634 }
32635 proglen += ilen;
32636 addrs[i] = proglen;
32637 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32638
32639 if (image) {
32640 bpf_flush_icache(header, image + proglen);
32641 - set_memory_ro((unsigned long)header, header->pages);
32642 fp->bpf_func = (void *)image;
32643 }
32644 out:
32645 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32646 {
32647 if (fp->bpf_func != sk_run_filter) {
32648 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32649 - struct bpf_binary_header *header = (void *)addr;
32650 -
32651 - set_memory_rw(addr, header->pages);
32652 - module_free(NULL, header);
32653 + set_memory_rw(addr, 1);
32654 + module_free_exec(NULL, (void *)addr);
32655 }
32656 }
32657 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32658 index d6aa6e8..266395a 100644
32659 --- a/arch/x86/oprofile/backtrace.c
32660 +++ b/arch/x86/oprofile/backtrace.c
32661 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32662 struct stack_frame_ia32 *fp;
32663 unsigned long bytes;
32664
32665 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32666 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32667 if (bytes != sizeof(bufhead))
32668 return NULL;
32669
32670 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32671 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32672
32673 oprofile_add_trace(bufhead[0].return_address);
32674
32675 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32676 struct stack_frame bufhead[2];
32677 unsigned long bytes;
32678
32679 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32680 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32681 if (bytes != sizeof(bufhead))
32682 return NULL;
32683
32684 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32685 {
32686 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32687
32688 - if (!user_mode_vm(regs)) {
32689 + if (!user_mode(regs)) {
32690 unsigned long stack = kernel_stack_pointer(regs);
32691 if (depth)
32692 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32693 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32694 index 48768df..ba9143c 100644
32695 --- a/arch/x86/oprofile/nmi_int.c
32696 +++ b/arch/x86/oprofile/nmi_int.c
32697 @@ -23,6 +23,7 @@
32698 #include <asm/nmi.h>
32699 #include <asm/msr.h>
32700 #include <asm/apic.h>
32701 +#include <asm/pgtable.h>
32702
32703 #include "op_counter.h"
32704 #include "op_x86_model.h"
32705 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32706 if (ret)
32707 return ret;
32708
32709 - if (!model->num_virt_counters)
32710 - model->num_virt_counters = model->num_counters;
32711 + if (!model->num_virt_counters) {
32712 + pax_open_kernel();
32713 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32714 + pax_close_kernel();
32715 + }
32716
32717 mux_init(ops);
32718
32719 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32720 index b2b9443..be58856 100644
32721 --- a/arch/x86/oprofile/op_model_amd.c
32722 +++ b/arch/x86/oprofile/op_model_amd.c
32723 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32724 num_counters = AMD64_NUM_COUNTERS;
32725 }
32726
32727 - op_amd_spec.num_counters = num_counters;
32728 - op_amd_spec.num_controls = num_counters;
32729 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32730 + pax_open_kernel();
32731 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32732 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32733 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32734 + pax_close_kernel();
32735
32736 return 0;
32737 }
32738 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32739 index d90528e..0127e2b 100644
32740 --- a/arch/x86/oprofile/op_model_ppro.c
32741 +++ b/arch/x86/oprofile/op_model_ppro.c
32742 @@ -19,6 +19,7 @@
32743 #include <asm/msr.h>
32744 #include <asm/apic.h>
32745 #include <asm/nmi.h>
32746 +#include <asm/pgtable.h>
32747
32748 #include "op_x86_model.h"
32749 #include "op_counter.h"
32750 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32751
32752 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32753
32754 - op_arch_perfmon_spec.num_counters = num_counters;
32755 - op_arch_perfmon_spec.num_controls = num_counters;
32756 + pax_open_kernel();
32757 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32758 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32759 + pax_close_kernel();
32760 }
32761
32762 static int arch_perfmon_init(struct oprofile_operations *ignore)
32763 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32764 index 71e8a67..6a313bb 100644
32765 --- a/arch/x86/oprofile/op_x86_model.h
32766 +++ b/arch/x86/oprofile/op_x86_model.h
32767 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32768 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32769 struct op_msrs const * const msrs);
32770 #endif
32771 -};
32772 +} __do_const;
32773
32774 struct op_counter_config;
32775
32776 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32777 index 372e9b8..e775a6c 100644
32778 --- a/arch/x86/pci/irq.c
32779 +++ b/arch/x86/pci/irq.c
32780 @@ -50,7 +50,7 @@ struct irq_router {
32781 struct irq_router_handler {
32782 u16 vendor;
32783 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32784 -};
32785 +} __do_const;
32786
32787 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32788 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32789 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32790 return 0;
32791 }
32792
32793 -static __initdata struct irq_router_handler pirq_routers[] = {
32794 +static __initconst const struct irq_router_handler pirq_routers[] = {
32795 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32796 { PCI_VENDOR_ID_AL, ali_router_probe },
32797 { PCI_VENDOR_ID_ITE, ite_router_probe },
32798 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32799 static void __init pirq_find_router(struct irq_router *r)
32800 {
32801 struct irq_routing_table *rt = pirq_table;
32802 - struct irq_router_handler *h;
32803 + const struct irq_router_handler *h;
32804
32805 #ifdef CONFIG_PCI_BIOS
32806 if (!rt->signature) {
32807 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32808 return 0;
32809 }
32810
32811 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32812 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32813 {
32814 .callback = fix_broken_hp_bios_irq9,
32815 .ident = "HP Pavilion N5400 Series Laptop",
32816 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32817 index 6eb18c4..20d83de 100644
32818 --- a/arch/x86/pci/mrst.c
32819 +++ b/arch/x86/pci/mrst.c
32820 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32821 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32822 pci_mmcfg_late_init();
32823 pcibios_enable_irq = mrst_pci_irq_enable;
32824 - pci_root_ops = pci_mrst_ops;
32825 + pax_open_kernel();
32826 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32827 + pax_close_kernel();
32828 pci_soc_mode = 1;
32829 /* Continue with standard init */
32830 return 1;
32831 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32832 index c77b24a..c979855 100644
32833 --- a/arch/x86/pci/pcbios.c
32834 +++ b/arch/x86/pci/pcbios.c
32835 @@ -79,7 +79,7 @@ union bios32 {
32836 static struct {
32837 unsigned long address;
32838 unsigned short segment;
32839 -} bios32_indirect = { 0, __KERNEL_CS };
32840 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32841
32842 /*
32843 * Returns the entry point for the given service, NULL on error
32844 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32845 unsigned long length; /* %ecx */
32846 unsigned long entry; /* %edx */
32847 unsigned long flags;
32848 + struct desc_struct d, *gdt;
32849
32850 local_irq_save(flags);
32851 - __asm__("lcall *(%%edi); cld"
32852 +
32853 + gdt = get_cpu_gdt_table(smp_processor_id());
32854 +
32855 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32856 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32857 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32858 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32859 +
32860 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32861 : "=a" (return_code),
32862 "=b" (address),
32863 "=c" (length),
32864 "=d" (entry)
32865 : "0" (service),
32866 "1" (0),
32867 - "D" (&bios32_indirect));
32868 + "D" (&bios32_indirect),
32869 + "r"(__PCIBIOS_DS)
32870 + : "memory");
32871 +
32872 + pax_open_kernel();
32873 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32874 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32875 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32876 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32877 + pax_close_kernel();
32878 +
32879 local_irq_restore(flags);
32880
32881 switch (return_code) {
32882 - case 0:
32883 - return address + entry;
32884 - case 0x80: /* Not present */
32885 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32886 - return 0;
32887 - default: /* Shouldn't happen */
32888 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32889 - service, return_code);
32890 + case 0: {
32891 + int cpu;
32892 + unsigned char flags;
32893 +
32894 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32895 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32896 + printk(KERN_WARNING "bios32_service: not valid\n");
32897 return 0;
32898 + }
32899 + address = address + PAGE_OFFSET;
32900 + length += 16UL; /* some BIOSs underreport this... */
32901 + flags = 4;
32902 + if (length >= 64*1024*1024) {
32903 + length >>= PAGE_SHIFT;
32904 + flags |= 8;
32905 + }
32906 +
32907 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32908 + gdt = get_cpu_gdt_table(cpu);
32909 + pack_descriptor(&d, address, length, 0x9b, flags);
32910 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32911 + pack_descriptor(&d, address, length, 0x93, flags);
32912 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32913 + }
32914 + return entry;
32915 + }
32916 + case 0x80: /* Not present */
32917 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32918 + return 0;
32919 + default: /* Shouldn't happen */
32920 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32921 + service, return_code);
32922 + return 0;
32923 }
32924 }
32925
32926 static struct {
32927 unsigned long address;
32928 unsigned short segment;
32929 -} pci_indirect = { 0, __KERNEL_CS };
32930 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32931
32932 -static int pci_bios_present;
32933 +static int pci_bios_present __read_only;
32934
32935 static int check_pcibios(void)
32936 {
32937 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32938 unsigned long flags, pcibios_entry;
32939
32940 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32941 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32942 + pci_indirect.address = pcibios_entry;
32943
32944 local_irq_save(flags);
32945 - __asm__(
32946 - "lcall *(%%edi); cld\n\t"
32947 + __asm__("movw %w6, %%ds\n\t"
32948 + "lcall *%%ss:(%%edi); cld\n\t"
32949 + "push %%ss\n\t"
32950 + "pop %%ds\n\t"
32951 "jc 1f\n\t"
32952 "xor %%ah, %%ah\n"
32953 "1:"
32954 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32955 "=b" (ebx),
32956 "=c" (ecx)
32957 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32958 - "D" (&pci_indirect)
32959 + "D" (&pci_indirect),
32960 + "r" (__PCIBIOS_DS)
32961 : "memory");
32962 local_irq_restore(flags);
32963
32964 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32965
32966 switch (len) {
32967 case 1:
32968 - __asm__("lcall *(%%esi); cld\n\t"
32969 + __asm__("movw %w6, %%ds\n\t"
32970 + "lcall *%%ss:(%%esi); cld\n\t"
32971 + "push %%ss\n\t"
32972 + "pop %%ds\n\t"
32973 "jc 1f\n\t"
32974 "xor %%ah, %%ah\n"
32975 "1:"
32976 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32977 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32978 "b" (bx),
32979 "D" ((long)reg),
32980 - "S" (&pci_indirect));
32981 + "S" (&pci_indirect),
32982 + "r" (__PCIBIOS_DS));
32983 /*
32984 * Zero-extend the result beyond 8 bits, do not trust the
32985 * BIOS having done it:
32986 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32987 *value &= 0xff;
32988 break;
32989 case 2:
32990 - __asm__("lcall *(%%esi); cld\n\t"
32991 + __asm__("movw %w6, %%ds\n\t"
32992 + "lcall *%%ss:(%%esi); cld\n\t"
32993 + "push %%ss\n\t"
32994 + "pop %%ds\n\t"
32995 "jc 1f\n\t"
32996 "xor %%ah, %%ah\n"
32997 "1:"
32998 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32999 : "1" (PCIBIOS_READ_CONFIG_WORD),
33000 "b" (bx),
33001 "D" ((long)reg),
33002 - "S" (&pci_indirect));
33003 + "S" (&pci_indirect),
33004 + "r" (__PCIBIOS_DS));
33005 /*
33006 * Zero-extend the result beyond 16 bits, do not trust the
33007 * BIOS having done it:
33008 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33009 *value &= 0xffff;
33010 break;
33011 case 4:
33012 - __asm__("lcall *(%%esi); cld\n\t"
33013 + __asm__("movw %w6, %%ds\n\t"
33014 + "lcall *%%ss:(%%esi); cld\n\t"
33015 + "push %%ss\n\t"
33016 + "pop %%ds\n\t"
33017 "jc 1f\n\t"
33018 "xor %%ah, %%ah\n"
33019 "1:"
33020 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33021 : "1" (PCIBIOS_READ_CONFIG_DWORD),
33022 "b" (bx),
33023 "D" ((long)reg),
33024 - "S" (&pci_indirect));
33025 + "S" (&pci_indirect),
33026 + "r" (__PCIBIOS_DS));
33027 break;
33028 }
33029
33030 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33031
33032 switch (len) {
33033 case 1:
33034 - __asm__("lcall *(%%esi); cld\n\t"
33035 + __asm__("movw %w6, %%ds\n\t"
33036 + "lcall *%%ss:(%%esi); cld\n\t"
33037 + "push %%ss\n\t"
33038 + "pop %%ds\n\t"
33039 "jc 1f\n\t"
33040 "xor %%ah, %%ah\n"
33041 "1:"
33042 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33043 "c" (value),
33044 "b" (bx),
33045 "D" ((long)reg),
33046 - "S" (&pci_indirect));
33047 + "S" (&pci_indirect),
33048 + "r" (__PCIBIOS_DS));
33049 break;
33050 case 2:
33051 - __asm__("lcall *(%%esi); cld\n\t"
33052 + __asm__("movw %w6, %%ds\n\t"
33053 + "lcall *%%ss:(%%esi); cld\n\t"
33054 + "push %%ss\n\t"
33055 + "pop %%ds\n\t"
33056 "jc 1f\n\t"
33057 "xor %%ah, %%ah\n"
33058 "1:"
33059 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33060 "c" (value),
33061 "b" (bx),
33062 "D" ((long)reg),
33063 - "S" (&pci_indirect));
33064 + "S" (&pci_indirect),
33065 + "r" (__PCIBIOS_DS));
33066 break;
33067 case 4:
33068 - __asm__("lcall *(%%esi); cld\n\t"
33069 + __asm__("movw %w6, %%ds\n\t"
33070 + "lcall *%%ss:(%%esi); cld\n\t"
33071 + "push %%ss\n\t"
33072 + "pop %%ds\n\t"
33073 "jc 1f\n\t"
33074 "xor %%ah, %%ah\n"
33075 "1:"
33076 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33077 "c" (value),
33078 "b" (bx),
33079 "D" ((long)reg),
33080 - "S" (&pci_indirect));
33081 + "S" (&pci_indirect),
33082 + "r" (__PCIBIOS_DS));
33083 break;
33084 }
33085
33086 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33087
33088 DBG("PCI: Fetching IRQ routing table... ");
33089 __asm__("push %%es\n\t"
33090 + "movw %w8, %%ds\n\t"
33091 "push %%ds\n\t"
33092 "pop %%es\n\t"
33093 - "lcall *(%%esi); cld\n\t"
33094 + "lcall *%%ss:(%%esi); cld\n\t"
33095 "pop %%es\n\t"
33096 + "push %%ss\n\t"
33097 + "pop %%ds\n"
33098 "jc 1f\n\t"
33099 "xor %%ah, %%ah\n"
33100 "1:"
33101 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33102 "1" (0),
33103 "D" ((long) &opt),
33104 "S" (&pci_indirect),
33105 - "m" (opt)
33106 + "m" (opt),
33107 + "r" (__PCIBIOS_DS)
33108 : "memory");
33109 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33110 if (ret & 0xff00)
33111 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33112 {
33113 int ret;
33114
33115 - __asm__("lcall *(%%esi); cld\n\t"
33116 + __asm__("movw %w5, %%ds\n\t"
33117 + "lcall *%%ss:(%%esi); cld\n\t"
33118 + "push %%ss\n\t"
33119 + "pop %%ds\n"
33120 "jc 1f\n\t"
33121 "xor %%ah, %%ah\n"
33122 "1:"
33123 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33124 : "0" (PCIBIOS_SET_PCI_HW_INT),
33125 "b" ((dev->bus->number << 8) | dev->devfn),
33126 "c" ((irq << 8) | (pin + 10)),
33127 - "S" (&pci_indirect));
33128 + "S" (&pci_indirect),
33129 + "r" (__PCIBIOS_DS));
33130 return !(ret & 0xff00);
33131 }
33132 EXPORT_SYMBOL(pcibios_set_irq_routing);
33133 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33134 index 40e4469..d915bf9 100644
33135 --- a/arch/x86/platform/efi/efi_32.c
33136 +++ b/arch/x86/platform/efi/efi_32.c
33137 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33138 {
33139 struct desc_ptr gdt_descr;
33140
33141 +#ifdef CONFIG_PAX_KERNEXEC
33142 + struct desc_struct d;
33143 +#endif
33144 +
33145 local_irq_save(efi_rt_eflags);
33146
33147 load_cr3(initial_page_table);
33148 __flush_tlb_all();
33149
33150 +#ifdef CONFIG_PAX_KERNEXEC
33151 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33152 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33153 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33154 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33155 +#endif
33156 +
33157 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33158 gdt_descr.size = GDT_SIZE - 1;
33159 load_gdt(&gdt_descr);
33160 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33161 {
33162 struct desc_ptr gdt_descr;
33163
33164 +#ifdef CONFIG_PAX_KERNEXEC
33165 + struct desc_struct d;
33166 +
33167 + memset(&d, 0, sizeof d);
33168 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33169 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33170 +#endif
33171 +
33172 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33173 gdt_descr.size = GDT_SIZE - 1;
33174 load_gdt(&gdt_descr);
33175
33176 +#ifdef CONFIG_PAX_PER_CPU_PGD
33177 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33178 +#else
33179 load_cr3(swapper_pg_dir);
33180 +#endif
33181 +
33182 __flush_tlb_all();
33183
33184 local_irq_restore(efi_rt_eflags);
33185 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33186 index 39a0e7f1..872396e 100644
33187 --- a/arch/x86/platform/efi/efi_64.c
33188 +++ b/arch/x86/platform/efi/efi_64.c
33189 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33190 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33191 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33192 }
33193 +
33194 +#ifdef CONFIG_PAX_PER_CPU_PGD
33195 + load_cr3(swapper_pg_dir);
33196 +#endif
33197 +
33198 __flush_tlb_all();
33199 }
33200
33201 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33202 for (pgd = 0; pgd < n_pgds; pgd++)
33203 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33204 kfree(save_pgd);
33205 +
33206 +#ifdef CONFIG_PAX_PER_CPU_PGD
33207 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33208 +#endif
33209 +
33210 __flush_tlb_all();
33211 local_irq_restore(efi_flags);
33212 early_code_mapping_set_exec(0);
33213 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33214 index fbe66e6..eae5e38 100644
33215 --- a/arch/x86/platform/efi/efi_stub_32.S
33216 +++ b/arch/x86/platform/efi/efi_stub_32.S
33217 @@ -6,7 +6,9 @@
33218 */
33219
33220 #include <linux/linkage.h>
33221 +#include <linux/init.h>
33222 #include <asm/page_types.h>
33223 +#include <asm/segment.h>
33224
33225 /*
33226 * efi_call_phys(void *, ...) is a function with variable parameters.
33227 @@ -20,7 +22,7 @@
33228 * service functions will comply with gcc calling convention, too.
33229 */
33230
33231 -.text
33232 +__INIT
33233 ENTRY(efi_call_phys)
33234 /*
33235 * 0. The function can only be called in Linux kernel. So CS has been
33236 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33237 * The mapping of lower virtual memory has been created in prelog and
33238 * epilog.
33239 */
33240 - movl $1f, %edx
33241 - subl $__PAGE_OFFSET, %edx
33242 - jmp *%edx
33243 +#ifdef CONFIG_PAX_KERNEXEC
33244 + movl $(__KERNEXEC_EFI_DS), %edx
33245 + mov %edx, %ds
33246 + mov %edx, %es
33247 + mov %edx, %ss
33248 + addl $2f,(1f)
33249 + ljmp *(1f)
33250 +
33251 +__INITDATA
33252 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33253 +.previous
33254 +
33255 +2:
33256 + subl $2b,(1b)
33257 +#else
33258 + jmp 1f-__PAGE_OFFSET
33259 1:
33260 +#endif
33261
33262 /*
33263 * 2. Now on the top of stack is the return
33264 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33265 * parameter 2, ..., param n. To make things easy, we save the return
33266 * address of efi_call_phys in a global variable.
33267 */
33268 - popl %edx
33269 - movl %edx, saved_return_addr
33270 - /* get the function pointer into ECX*/
33271 - popl %ecx
33272 - movl %ecx, efi_rt_function_ptr
33273 - movl $2f, %edx
33274 - subl $__PAGE_OFFSET, %edx
33275 - pushl %edx
33276 + popl (saved_return_addr)
33277 + popl (efi_rt_function_ptr)
33278
33279 /*
33280 * 3. Clear PG bit in %CR0.
33281 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33282 /*
33283 * 5. Call the physical function.
33284 */
33285 - jmp *%ecx
33286 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33287
33288 -2:
33289 /*
33290 * 6. After EFI runtime service returns, control will return to
33291 * following instruction. We'd better readjust stack pointer first.
33292 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33293 movl %cr0, %edx
33294 orl $0x80000000, %edx
33295 movl %edx, %cr0
33296 - jmp 1f
33297 -1:
33298 +
33299 /*
33300 * 8. Now restore the virtual mode from flat mode by
33301 * adding EIP with PAGE_OFFSET.
33302 */
33303 - movl $1f, %edx
33304 - jmp *%edx
33305 +#ifdef CONFIG_PAX_KERNEXEC
33306 + movl $(__KERNEL_DS), %edx
33307 + mov %edx, %ds
33308 + mov %edx, %es
33309 + mov %edx, %ss
33310 + ljmp $(__KERNEL_CS),$1f
33311 +#else
33312 + jmp 1f+__PAGE_OFFSET
33313 +#endif
33314 1:
33315
33316 /*
33317 * 9. Balance the stack. And because EAX contain the return value,
33318 * we'd better not clobber it.
33319 */
33320 - leal efi_rt_function_ptr, %edx
33321 - movl (%edx), %ecx
33322 - pushl %ecx
33323 + pushl (efi_rt_function_ptr)
33324
33325 /*
33326 - * 10. Push the saved return address onto the stack and return.
33327 + * 10. Return to the saved return address.
33328 */
33329 - leal saved_return_addr, %edx
33330 - movl (%edx), %ecx
33331 - pushl %ecx
33332 - ret
33333 + jmpl *(saved_return_addr)
33334 ENDPROC(efi_call_phys)
33335 .previous
33336
33337 -.data
33338 +__INITDATA
33339 saved_return_addr:
33340 .long 0
33341 efi_rt_function_ptr:
33342 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33343 index 4c07cca..2c8427d 100644
33344 --- a/arch/x86/platform/efi/efi_stub_64.S
33345 +++ b/arch/x86/platform/efi/efi_stub_64.S
33346 @@ -7,6 +7,7 @@
33347 */
33348
33349 #include <linux/linkage.h>
33350 +#include <asm/alternative-asm.h>
33351
33352 #define SAVE_XMM \
33353 mov %rsp, %rax; \
33354 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33355 call *%rdi
33356 addq $32, %rsp
33357 RESTORE_XMM
33358 + pax_force_retaddr 0, 1
33359 ret
33360 ENDPROC(efi_call0)
33361
33362 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33363 call *%rdi
33364 addq $32, %rsp
33365 RESTORE_XMM
33366 + pax_force_retaddr 0, 1
33367 ret
33368 ENDPROC(efi_call1)
33369
33370 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33371 call *%rdi
33372 addq $32, %rsp
33373 RESTORE_XMM
33374 + pax_force_retaddr 0, 1
33375 ret
33376 ENDPROC(efi_call2)
33377
33378 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33379 call *%rdi
33380 addq $32, %rsp
33381 RESTORE_XMM
33382 + pax_force_retaddr 0, 1
33383 ret
33384 ENDPROC(efi_call3)
33385
33386 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33387 call *%rdi
33388 addq $32, %rsp
33389 RESTORE_XMM
33390 + pax_force_retaddr 0, 1
33391 ret
33392 ENDPROC(efi_call4)
33393
33394 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33395 call *%rdi
33396 addq $48, %rsp
33397 RESTORE_XMM
33398 + pax_force_retaddr 0, 1
33399 ret
33400 ENDPROC(efi_call5)
33401
33402 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33403 call *%rdi
33404 addq $48, %rsp
33405 RESTORE_XMM
33406 + pax_force_retaddr 0, 1
33407 ret
33408 ENDPROC(efi_call6)
33409 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33410 index 47fe66f..6206449 100644
33411 --- a/arch/x86/platform/mrst/mrst.c
33412 +++ b/arch/x86/platform/mrst/mrst.c
33413 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33414 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33415 int sfi_mrtc_num;
33416
33417 -static void mrst_power_off(void)
33418 +static __noreturn void mrst_power_off(void)
33419 {
33420 + BUG();
33421 }
33422
33423 -static void mrst_reboot(void)
33424 +static __noreturn void mrst_reboot(void)
33425 {
33426 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33427 + BUG();
33428 }
33429
33430 /* parse all the mtimer info to a static mtimer array */
33431 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33432 index d6ee929..3637cb5 100644
33433 --- a/arch/x86/platform/olpc/olpc_dt.c
33434 +++ b/arch/x86/platform/olpc/olpc_dt.c
33435 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33436 return res;
33437 }
33438
33439 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33440 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33441 .nextprop = olpc_dt_nextprop,
33442 .getproplen = olpc_dt_getproplen,
33443 .getproperty = olpc_dt_getproperty,
33444 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33445 index 1cf5b30..fd45732 100644
33446 --- a/arch/x86/power/cpu.c
33447 +++ b/arch/x86/power/cpu.c
33448 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33449 static void fix_processor_context(void)
33450 {
33451 int cpu = smp_processor_id();
33452 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33453 -#ifdef CONFIG_X86_64
33454 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33455 - tss_desc tss;
33456 -#endif
33457 + struct tss_struct *t = init_tss + cpu;
33458 +
33459 set_tss_desc(cpu, t); /*
33460 * This just modifies memory; should not be
33461 * necessary. But... This is necessary, because
33462 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33463 */
33464
33465 #ifdef CONFIG_X86_64
33466 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33467 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33468 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33469 -
33470 syscall_init(); /* This sets MSR_*STAR and related */
33471 #endif
33472 load_TR_desc(); /* This does ltr */
33473 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33474 index a44f457..9140171 100644
33475 --- a/arch/x86/realmode/init.c
33476 +++ b/arch/x86/realmode/init.c
33477 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33478 __va(real_mode_header->trampoline_header);
33479
33480 #ifdef CONFIG_X86_32
33481 - trampoline_header->start = __pa_symbol(startup_32_smp);
33482 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33483 +
33484 +#ifdef CONFIG_PAX_KERNEXEC
33485 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33486 +#endif
33487 +
33488 + trampoline_header->boot_cs = __BOOT_CS;
33489 trampoline_header->gdt_limit = __BOOT_DS + 7;
33490 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33491 #else
33492 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33493 *trampoline_cr4_features = read_cr4();
33494
33495 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33496 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33497 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33498 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33499 #endif
33500 }
33501 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33502 index 8869287..d577672 100644
33503 --- a/arch/x86/realmode/rm/Makefile
33504 +++ b/arch/x86/realmode/rm/Makefile
33505 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33506 $(call cc-option, -fno-unit-at-a-time)) \
33507 $(call cc-option, -fno-stack-protector) \
33508 $(call cc-option, -mpreferred-stack-boundary=2)
33509 +ifdef CONSTIFY_PLUGIN
33510 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33511 +endif
33512 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33513 GCOV_PROFILE := n
33514 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33515 index a28221d..93c40f1 100644
33516 --- a/arch/x86/realmode/rm/header.S
33517 +++ b/arch/x86/realmode/rm/header.S
33518 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33519 #endif
33520 /* APM/BIOS reboot */
33521 .long pa_machine_real_restart_asm
33522 -#ifdef CONFIG_X86_64
33523 +#ifdef CONFIG_X86_32
33524 + .long __KERNEL_CS
33525 +#else
33526 .long __KERNEL32_CS
33527 #endif
33528 END(real_mode_header)
33529 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33530 index c1b2791..f9e31c7 100644
33531 --- a/arch/x86/realmode/rm/trampoline_32.S
33532 +++ b/arch/x86/realmode/rm/trampoline_32.S
33533 @@ -25,6 +25,12 @@
33534 #include <asm/page_types.h>
33535 #include "realmode.h"
33536
33537 +#ifdef CONFIG_PAX_KERNEXEC
33538 +#define ta(X) (X)
33539 +#else
33540 +#define ta(X) (pa_ ## X)
33541 +#endif
33542 +
33543 .text
33544 .code16
33545
33546 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33547
33548 cli # We should be safe anyway
33549
33550 - movl tr_start, %eax # where we need to go
33551 -
33552 movl $0xA5A5A5A5, trampoline_status
33553 # write marker for master knows we're running
33554
33555 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33556 movw $1, %dx # protected mode (PE) bit
33557 lmsw %dx # into protected mode
33558
33559 - ljmpl $__BOOT_CS, $pa_startup_32
33560 + ljmpl *(trampoline_header)
33561
33562 .section ".text32","ax"
33563 .code32
33564 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33565 .balign 8
33566 GLOBAL(trampoline_header)
33567 tr_start: .space 4
33568 - tr_gdt_pad: .space 2
33569 + tr_boot_cs: .space 2
33570 tr_gdt: .space 6
33571 END(trampoline_header)
33572
33573 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33574 index bb360dc..d0fd8f8 100644
33575 --- a/arch/x86/realmode/rm/trampoline_64.S
33576 +++ b/arch/x86/realmode/rm/trampoline_64.S
33577 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33578 movl %edx, %gs
33579
33580 movl pa_tr_cr4, %eax
33581 + andl $~X86_CR4_PCIDE, %eax
33582 movl %eax, %cr4 # Enable PAE mode
33583
33584 # Setup trampoline 4 level pagetables
33585 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33586 wrmsr
33587
33588 # Enable paging and in turn activate Long Mode
33589 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33590 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33591 movl %eax, %cr0
33592
33593 /*
33594 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33595 index e812034..c747134 100644
33596 --- a/arch/x86/tools/Makefile
33597 +++ b/arch/x86/tools/Makefile
33598 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33599
33600 $(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
33601
33602 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33603 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33604 hostprogs-y += relocs
33605 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33606 relocs: $(obj)/relocs
33607 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33608 index f7bab68..b6d9886 100644
33609 --- a/arch/x86/tools/relocs.c
33610 +++ b/arch/x86/tools/relocs.c
33611 @@ -1,5 +1,7 @@
33612 /* This is included from relocs_32/64.c */
33613
33614 +#include "../../../include/generated/autoconf.h"
33615 +
33616 #define ElfW(type) _ElfW(ELF_BITS, type)
33617 #define _ElfW(bits, type) __ElfW(bits, type)
33618 #define __ElfW(bits, type) Elf##bits##_##type
33619 @@ -11,6 +13,7 @@
33620 #define Elf_Sym ElfW(Sym)
33621
33622 static Elf_Ehdr ehdr;
33623 +static Elf_Phdr *phdr;
33624
33625 struct relocs {
33626 uint32_t *offset;
33627 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33628 }
33629 }
33630
33631 +static void read_phdrs(FILE *fp)
33632 +{
33633 + unsigned int i;
33634 +
33635 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33636 + if (!phdr) {
33637 + die("Unable to allocate %d program headers\n",
33638 + ehdr.e_phnum);
33639 + }
33640 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33641 + die("Seek to %d failed: %s\n",
33642 + ehdr.e_phoff, strerror(errno));
33643 + }
33644 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33645 + die("Cannot read ELF program headers: %s\n",
33646 + strerror(errno));
33647 + }
33648 + for(i = 0; i < ehdr.e_phnum; i++) {
33649 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33650 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33651 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33652 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33653 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33654 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33655 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33656 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33657 + }
33658 +
33659 +}
33660 +
33661 static void read_shdrs(FILE *fp)
33662 {
33663 - int i;
33664 + unsigned int i;
33665 Elf_Shdr shdr;
33666
33667 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33668 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33669
33670 static void read_strtabs(FILE *fp)
33671 {
33672 - int i;
33673 + unsigned int i;
33674 for (i = 0; i < ehdr.e_shnum; i++) {
33675 struct section *sec = &secs[i];
33676 if (sec->shdr.sh_type != SHT_STRTAB) {
33677 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33678
33679 static void read_symtabs(FILE *fp)
33680 {
33681 - int i,j;
33682 + unsigned int i,j;
33683 for (i = 0; i < ehdr.e_shnum; i++) {
33684 struct section *sec = &secs[i];
33685 if (sec->shdr.sh_type != SHT_SYMTAB) {
33686 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33687 }
33688
33689
33690 -static void read_relocs(FILE *fp)
33691 +static void read_relocs(FILE *fp, int use_real_mode)
33692 {
33693 - int i,j;
33694 + unsigned int i,j;
33695 + uint32_t base;
33696 +
33697 for (i = 0; i < ehdr.e_shnum; i++) {
33698 struct section *sec = &secs[i];
33699 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33700 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33701 die("Cannot read symbol table: %s\n",
33702 strerror(errno));
33703 }
33704 + base = 0;
33705 +
33706 +#ifdef CONFIG_X86_32
33707 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33708 + if (phdr[j].p_type != PT_LOAD )
33709 + continue;
33710 + 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)
33711 + continue;
33712 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33713 + break;
33714 + }
33715 +#endif
33716 +
33717 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33718 Elf_Rel *rel = &sec->reltab[j];
33719 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33720 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33721 rel->r_info = elf_xword_to_cpu(rel->r_info);
33722 #if (SHT_REL_TYPE == SHT_RELA)
33723 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33724 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33725
33726 static void print_absolute_symbols(void)
33727 {
33728 - int i;
33729 + unsigned int i;
33730 const char *format;
33731
33732 if (ELF_BITS == 64)
33733 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33734 for (i = 0; i < ehdr.e_shnum; i++) {
33735 struct section *sec = &secs[i];
33736 char *sym_strtab;
33737 - int j;
33738 + unsigned int j;
33739
33740 if (sec->shdr.sh_type != SHT_SYMTAB) {
33741 continue;
33742 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33743
33744 static void print_absolute_relocs(void)
33745 {
33746 - int i, printed = 0;
33747 + unsigned int i, printed = 0;
33748 const char *format;
33749
33750 if (ELF_BITS == 64)
33751 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33752 struct section *sec_applies, *sec_symtab;
33753 char *sym_strtab;
33754 Elf_Sym *sh_symtab;
33755 - int j;
33756 + unsigned int j;
33757 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33758 continue;
33759 }
33760 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33761 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33762 Elf_Sym *sym, const char *symname))
33763 {
33764 - int i;
33765 + unsigned int i;
33766 /* Walk through the relocations */
33767 for (i = 0; i < ehdr.e_shnum; i++) {
33768 char *sym_strtab;
33769 Elf_Sym *sh_symtab;
33770 struct section *sec_applies, *sec_symtab;
33771 - int j;
33772 + unsigned int j;
33773 struct section *sec = &secs[i];
33774
33775 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33776 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33777 {
33778 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33779 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33780 + char *sym_strtab = sec->link->link->strtab;
33781 +
33782 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33783 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33784 + return 0;
33785 +
33786 +#ifdef CONFIG_PAX_KERNEXEC
33787 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33788 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33789 + return 0;
33790 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33791 + return 0;
33792 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33793 + return 0;
33794 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33795 + return 0;
33796 +#endif
33797
33798 switch (r_type) {
33799 case R_386_NONE:
33800 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33801
33802 static void emit_relocs(int as_text, int use_real_mode)
33803 {
33804 - int i;
33805 + unsigned int i;
33806 int (*write_reloc)(uint32_t, FILE *) = write32;
33807 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33808 const char *symname);
33809 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33810 {
33811 regex_init(use_real_mode);
33812 read_ehdr(fp);
33813 + read_phdrs(fp);
33814 read_shdrs(fp);
33815 read_strtabs(fp);
33816 read_symtabs(fp);
33817 - read_relocs(fp);
33818 + read_relocs(fp, use_real_mode);
33819 if (ELF_BITS == 64)
33820 percpu_init();
33821 if (show_absolute_syms) {
33822 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33823 index 80ffa5b..a33bd15 100644
33824 --- a/arch/x86/um/tls_32.c
33825 +++ b/arch/x86/um/tls_32.c
33826 @@ -260,7 +260,7 @@ out:
33827 if (unlikely(task == current &&
33828 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33829 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33830 - "without flushed TLS.", current->pid);
33831 + "without flushed TLS.", task_pid_nr(current));
33832 }
33833
33834 return 0;
33835 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33836 index fd14be1..e3c79c0 100644
33837 --- a/arch/x86/vdso/Makefile
33838 +++ b/arch/x86/vdso/Makefile
33839 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33840 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33841 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33842
33843 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33844 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33845 GCOV_PROFILE := n
33846
33847 #
33848 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33849 index d6bfb87..876ee18 100644
33850 --- a/arch/x86/vdso/vdso32-setup.c
33851 +++ b/arch/x86/vdso/vdso32-setup.c
33852 @@ -25,6 +25,7 @@
33853 #include <asm/tlbflush.h>
33854 #include <asm/vdso.h>
33855 #include <asm/proto.h>
33856 +#include <asm/mman.h>
33857
33858 enum {
33859 VDSO_DISABLED = 0,
33860 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33861 void enable_sep_cpu(void)
33862 {
33863 int cpu = get_cpu();
33864 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33865 + struct tss_struct *tss = init_tss + cpu;
33866
33867 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33868 put_cpu();
33869 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33870 gate_vma.vm_start = FIXADDR_USER_START;
33871 gate_vma.vm_end = FIXADDR_USER_END;
33872 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33873 - gate_vma.vm_page_prot = __P101;
33874 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33875
33876 return 0;
33877 }
33878 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33879 if (compat)
33880 addr = VDSO_HIGH_BASE;
33881 else {
33882 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33883 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33884 if (IS_ERR_VALUE(addr)) {
33885 ret = addr;
33886 goto up_fail;
33887 }
33888 }
33889
33890 - current->mm->context.vdso = (void *)addr;
33891 + current->mm->context.vdso = addr;
33892
33893 if (compat_uses_vma || !compat) {
33894 /*
33895 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33896 }
33897
33898 current_thread_info()->sysenter_return =
33899 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33900 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33901
33902 up_fail:
33903 if (ret)
33904 - current->mm->context.vdso = NULL;
33905 + current->mm->context.vdso = 0;
33906
33907 up_write(&mm->mmap_sem);
33908
33909 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33910
33911 const char *arch_vma_name(struct vm_area_struct *vma)
33912 {
33913 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33914 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33915 return "[vdso]";
33916 +
33917 +#ifdef CONFIG_PAX_SEGMEXEC
33918 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33919 + return "[vdso]";
33920 +#endif
33921 +
33922 return NULL;
33923 }
33924
33925 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33926 * Check to see if the corresponding task was created in compat vdso
33927 * mode.
33928 */
33929 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33930 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33931 return &gate_vma;
33932 return NULL;
33933 }
33934 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33935 index 431e875..cbb23f3 100644
33936 --- a/arch/x86/vdso/vma.c
33937 +++ b/arch/x86/vdso/vma.c
33938 @@ -16,8 +16,6 @@
33939 #include <asm/vdso.h>
33940 #include <asm/page.h>
33941
33942 -unsigned int __read_mostly vdso_enabled = 1;
33943 -
33944 extern char vdso_start[], vdso_end[];
33945 extern unsigned short vdso_sync_cpuid;
33946
33947 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33948 * unaligned here as a result of stack start randomization.
33949 */
33950 addr = PAGE_ALIGN(addr);
33951 - addr = align_vdso_addr(addr);
33952
33953 return addr;
33954 }
33955 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33956 unsigned size)
33957 {
33958 struct mm_struct *mm = current->mm;
33959 - unsigned long addr;
33960 + unsigned long addr = 0;
33961 int ret;
33962
33963 - if (!vdso_enabled)
33964 - return 0;
33965 -
33966 down_write(&mm->mmap_sem);
33967 +
33968 +#ifdef CONFIG_PAX_RANDMMAP
33969 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33970 +#endif
33971 +
33972 addr = vdso_addr(mm->start_stack, size);
33973 + addr = align_vdso_addr(addr);
33974 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33975 if (IS_ERR_VALUE(addr)) {
33976 ret = addr;
33977 goto up_fail;
33978 }
33979
33980 - current->mm->context.vdso = (void *)addr;
33981 + mm->context.vdso = addr;
33982
33983 ret = install_special_mapping(mm, addr, size,
33984 VM_READ|VM_EXEC|
33985 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33986 pages);
33987 - if (ret) {
33988 - current->mm->context.vdso = NULL;
33989 - goto up_fail;
33990 - }
33991 + if (ret)
33992 + mm->context.vdso = 0;
33993
33994 up_fail:
33995 up_write(&mm->mmap_sem);
33996 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33997 vdsox32_size);
33998 }
33999 #endif
34000 -
34001 -static __init int vdso_setup(char *s)
34002 -{
34003 - vdso_enabled = simple_strtoul(s, NULL, 0);
34004 - return 0;
34005 -}
34006 -__setup("vdso=", vdso_setup);
34007 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
34008 index 193097e..7590269 100644
34009 --- a/arch/x86/xen/enlighten.c
34010 +++ b/arch/x86/xen/enlighten.c
34011 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
34012
34013 struct shared_info xen_dummy_shared_info;
34014
34015 -void *xen_initial_gdt;
34016 -
34017 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
34018 __read_mostly int xen_have_vector_callback;
34019 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
34020 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
34021 {
34022 unsigned long va = dtr->address;
34023 unsigned int size = dtr->size + 1;
34024 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34025 - unsigned long frames[pages];
34026 + unsigned long frames[65536 / PAGE_SIZE];
34027 int f;
34028
34029 /*
34030 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34031 {
34032 unsigned long va = dtr->address;
34033 unsigned int size = dtr->size + 1;
34034 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34035 - unsigned long frames[pages];
34036 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
34037 int f;
34038
34039 /*
34040 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34041 * 8-byte entries, or 16 4k pages..
34042 */
34043
34044 - BUG_ON(size > 65536);
34045 + BUG_ON(size > GDT_SIZE);
34046 BUG_ON(va & ~PAGE_MASK);
34047
34048 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34049 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34050 return 0;
34051 }
34052
34053 -static void set_xen_basic_apic_ops(void)
34054 +static void __init set_xen_basic_apic_ops(void)
34055 {
34056 apic->read = xen_apic_read;
34057 apic->write = xen_apic_write;
34058 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34059 #endif
34060 };
34061
34062 -static void xen_reboot(int reason)
34063 +static __noreturn void xen_reboot(int reason)
34064 {
34065 struct sched_shutdown r = { .reason = reason };
34066
34067 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34068 - BUG();
34069 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34070 + BUG();
34071 }
34072
34073 -static void xen_restart(char *msg)
34074 +static __noreturn void xen_restart(char *msg)
34075 {
34076 xen_reboot(SHUTDOWN_reboot);
34077 }
34078
34079 -static void xen_emergency_restart(void)
34080 +static __noreturn void xen_emergency_restart(void)
34081 {
34082 xen_reboot(SHUTDOWN_reboot);
34083 }
34084
34085 -static void xen_machine_halt(void)
34086 +static __noreturn void xen_machine_halt(void)
34087 {
34088 xen_reboot(SHUTDOWN_poweroff);
34089 }
34090
34091 -static void xen_machine_power_off(void)
34092 +static __noreturn void xen_machine_power_off(void)
34093 {
34094 if (pm_power_off)
34095 pm_power_off();
34096 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34097 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34098
34099 /* Work out if we support NX */
34100 - x86_configure_nx();
34101 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34102 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34103 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34104 + unsigned l, h;
34105 +
34106 + __supported_pte_mask |= _PAGE_NX;
34107 + rdmsr(MSR_EFER, l, h);
34108 + l |= EFER_NX;
34109 + wrmsr(MSR_EFER, l, h);
34110 + }
34111 +#endif
34112
34113 xen_setup_features();
34114
34115 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34116
34117 machine_ops = xen_machine_ops;
34118
34119 - /*
34120 - * The only reliable way to retain the initial address of the
34121 - * percpu gdt_page is to remember it here, so we can go and
34122 - * mark it RW later, when the initial percpu area is freed.
34123 - */
34124 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34125 -
34126 xen_smp_init();
34127
34128 #ifdef CONFIG_ACPI_NUMA
34129 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34130 index fdc3ba2..3daee39 100644
34131 --- a/arch/x86/xen/mmu.c
34132 +++ b/arch/x86/xen/mmu.c
34133 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34134 /* L3_k[510] -> level2_kernel_pgt
34135 * L3_i[511] -> level2_fixmap_pgt */
34136 convert_pfn_mfn(level3_kernel_pgt);
34137 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34138 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34139 + convert_pfn_mfn(level3_vmemmap_pgt);
34140
34141 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34142 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34143 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34144 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34145 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34146 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34147 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34148 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34149 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34150 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34151 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34152 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34153 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34154 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34155
34156 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34157 pv_mmu_ops.set_pud = xen_set_pud;
34158 #if PAGETABLE_LEVELS == 4
34159 pv_mmu_ops.set_pgd = xen_set_pgd;
34160 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34161 #endif
34162
34163 /* This will work as long as patching hasn't happened yet
34164 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34165 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34166 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34167 .set_pgd = xen_set_pgd_hyper,
34168 + .set_pgd_batched = xen_set_pgd_hyper,
34169
34170 .alloc_pud = xen_alloc_pmd_init,
34171 .release_pud = xen_release_pmd_init,
34172 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34173 index b81c88e..2cbe7b8 100644
34174 --- a/arch/x86/xen/smp.c
34175 +++ b/arch/x86/xen/smp.c
34176 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34177 {
34178 BUG_ON(smp_processor_id() != 0);
34179 native_smp_prepare_boot_cpu();
34180 -
34181 - /* We've switched to the "real" per-cpu gdt, so make sure the
34182 - old memory can be recycled */
34183 - make_lowmem_page_readwrite(xen_initial_gdt);
34184 -
34185 xen_filter_cpu_maps();
34186 xen_setup_vcpu_info_placement();
34187 }
34188 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34189 ctxt->user_regs.ss = __KERNEL_DS;
34190 #ifdef CONFIG_X86_32
34191 ctxt->user_regs.fs = __KERNEL_PERCPU;
34192 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34193 + savesegment(gs, ctxt->user_regs.gs);
34194 #else
34195 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34196 #endif
34197 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34198
34199 {
34200 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34201 - ctxt->user_regs.ds = __USER_DS;
34202 - ctxt->user_regs.es = __USER_DS;
34203 + ctxt->user_regs.ds = __KERNEL_DS;
34204 + ctxt->user_regs.es = __KERNEL_DS;
34205
34206 xen_copy_trap_info(ctxt->trap_ctxt);
34207
34208 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34209 int rc;
34210
34211 per_cpu(current_task, cpu) = idle;
34212 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34213 #ifdef CONFIG_X86_32
34214 irq_ctx_init(cpu);
34215 #else
34216 clear_tsk_thread_flag(idle, TIF_FORK);
34217 - per_cpu(kernel_stack, cpu) =
34218 - (unsigned long)task_stack_page(idle) -
34219 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34220 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34221 #endif
34222 xen_setup_runstate_info(cpu);
34223 xen_setup_timer(cpu);
34224 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34225
34226 void __init xen_smp_init(void)
34227 {
34228 - smp_ops = xen_smp_ops;
34229 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34230 xen_fill_possible_map();
34231 xen_init_spinlocks();
34232 }
34233 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34234 index 33ca6e4..0ded929 100644
34235 --- a/arch/x86/xen/xen-asm_32.S
34236 +++ b/arch/x86/xen/xen-asm_32.S
34237 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34238 ESP_OFFSET=4 # bytes pushed onto stack
34239
34240 /*
34241 - * Store vcpu_info pointer for easy access. Do it this way to
34242 - * avoid having to reload %fs
34243 + * Store vcpu_info pointer for easy access.
34244 */
34245 #ifdef CONFIG_SMP
34246 - GET_THREAD_INFO(%eax)
34247 - movl %ss:TI_cpu(%eax), %eax
34248 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34249 - mov %ss:xen_vcpu(%eax), %eax
34250 + push %fs
34251 + mov $(__KERNEL_PERCPU), %eax
34252 + mov %eax, %fs
34253 + mov PER_CPU_VAR(xen_vcpu), %eax
34254 + pop %fs
34255 #else
34256 movl %ss:xen_vcpu, %eax
34257 #endif
34258 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34259 index 7faed58..ba4427c 100644
34260 --- a/arch/x86/xen/xen-head.S
34261 +++ b/arch/x86/xen/xen-head.S
34262 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34263 #ifdef CONFIG_X86_32
34264 mov %esi,xen_start_info
34265 mov $init_thread_union+THREAD_SIZE,%esp
34266 +#ifdef CONFIG_SMP
34267 + movl $cpu_gdt_table,%edi
34268 + movl $__per_cpu_load,%eax
34269 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34270 + rorl $16,%eax
34271 + movb %al,__KERNEL_PERCPU + 4(%edi)
34272 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34273 + movl $__per_cpu_end - 1,%eax
34274 + subl $__per_cpu_start,%eax
34275 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34276 +#endif
34277 #else
34278 mov %rsi,xen_start_info
34279 mov $init_thread_union+THREAD_SIZE,%rsp
34280 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34281 index 86782c5..fa272c8 100644
34282 --- a/arch/x86/xen/xen-ops.h
34283 +++ b/arch/x86/xen/xen-ops.h
34284 @@ -10,8 +10,6 @@
34285 extern const char xen_hypervisor_callback[];
34286 extern const char xen_failsafe_callback[];
34287
34288 -extern void *xen_initial_gdt;
34289 -
34290 struct trap_info;
34291 void xen_copy_trap_info(struct trap_info *traps);
34292
34293 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34294 index 525bd3d..ef888b1 100644
34295 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34296 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34297 @@ -119,9 +119,9 @@
34298 ----------------------------------------------------------------------*/
34299
34300 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34301 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34302 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34303 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34304 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34305
34306 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34307 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34308 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34309 index 2f33760..835e50a 100644
34310 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34311 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34312 @@ -11,6 +11,7 @@
34313 #ifndef _XTENSA_CORE_H
34314 #define _XTENSA_CORE_H
34315
34316 +#include <linux/const.h>
34317
34318 /****************************************************************************
34319 Parameters Useful for Any Code, USER or PRIVILEGED
34320 @@ -112,9 +113,9 @@
34321 ----------------------------------------------------------------------*/
34322
34323 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34324 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34325 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34326 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34327 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34328
34329 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34330 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34331 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34332 index af00795..2bb8105 100644
34333 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34334 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34335 @@ -11,6 +11,7 @@
34336 #ifndef _XTENSA_CORE_CONFIGURATION_H
34337 #define _XTENSA_CORE_CONFIGURATION_H
34338
34339 +#include <linux/const.h>
34340
34341 /****************************************************************************
34342 Parameters Useful for Any Code, USER or PRIVILEGED
34343 @@ -118,9 +119,9 @@
34344 ----------------------------------------------------------------------*/
34345
34346 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34347 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34348 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34349 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34350 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34351
34352 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34353 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34354 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34355 index 290792a..416f287 100644
34356 --- a/block/blk-cgroup.c
34357 +++ b/block/blk-cgroup.c
34358 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34359
34360 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34361 {
34362 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34363 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34364 struct blkcg *blkcg;
34365 struct cgroup *parent = cgroup->parent;
34366
34367 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34368
34369 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34370 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34371 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34372 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34373 done:
34374 spin_lock_init(&blkcg->lock);
34375 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34376 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34377 index 4b8d9b54..a7178c0 100644
34378 --- a/block/blk-iopoll.c
34379 +++ b/block/blk-iopoll.c
34380 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34381 }
34382 EXPORT_SYMBOL(blk_iopoll_complete);
34383
34384 -static void blk_iopoll_softirq(struct softirq_action *h)
34385 +static __latent_entropy void blk_iopoll_softirq(void)
34386 {
34387 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34388 int rearm = 0, budget = blk_iopoll_budget;
34389 diff --git a/block/blk-map.c b/block/blk-map.c
34390 index 623e1cd..ca1e109 100644
34391 --- a/block/blk-map.c
34392 +++ b/block/blk-map.c
34393 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34394 if (!len || !kbuf)
34395 return -EINVAL;
34396
34397 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34398 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34399 if (do_copy)
34400 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34401 else
34402 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34403 index ec9e606..3f38839 100644
34404 --- a/block/blk-softirq.c
34405 +++ b/block/blk-softirq.c
34406 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34407 * Softirq action handler - move entries to local list and loop over them
34408 * while passing them to the queue registered handler.
34409 */
34410 -static void blk_done_softirq(struct softirq_action *h)
34411 +static __latent_entropy void blk_done_softirq(void)
34412 {
34413 struct list_head *cpu_list, local_list;
34414
34415 diff --git a/block/bsg.c b/block/bsg.c
34416 index 420a5a9..23834aa 100644
34417 --- a/block/bsg.c
34418 +++ b/block/bsg.c
34419 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34420 struct sg_io_v4 *hdr, struct bsg_device *bd,
34421 fmode_t has_write_perm)
34422 {
34423 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34424 + unsigned char *cmdptr;
34425 +
34426 if (hdr->request_len > BLK_MAX_CDB) {
34427 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34428 if (!rq->cmd)
34429 return -ENOMEM;
34430 - }
34431 + cmdptr = rq->cmd;
34432 + } else
34433 + cmdptr = tmpcmd;
34434
34435 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34436 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34437 hdr->request_len))
34438 return -EFAULT;
34439
34440 + if (cmdptr != rq->cmd)
34441 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34442 +
34443 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34444 if (blk_verify_command(rq->cmd, has_write_perm))
34445 return -EPERM;
34446 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34447 index 7e5d474..0cf0017 100644
34448 --- a/block/compat_ioctl.c
34449 +++ b/block/compat_ioctl.c
34450 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34451 err |= __get_user(f->spec1, &uf->spec1);
34452 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34453 err |= __get_user(name, &uf->name);
34454 - f->name = compat_ptr(name);
34455 + f->name = (void __force_kernel *)compat_ptr(name);
34456 if (err) {
34457 err = -EFAULT;
34458 goto out;
34459 diff --git a/block/genhd.c b/block/genhd.c
34460 index dadf42b..48dc887 100644
34461 --- a/block/genhd.c
34462 +++ b/block/genhd.c
34463 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34464
34465 /*
34466 * Register device numbers dev..(dev+range-1)
34467 - * range must be nonzero
34468 + * Noop if @range is zero.
34469 * The hash chain is sorted on range, so that subranges can override.
34470 */
34471 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34472 struct kobject *(*probe)(dev_t, int *, void *),
34473 int (*lock)(dev_t, void *), void *data)
34474 {
34475 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34476 + if (range)
34477 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34478 }
34479
34480 EXPORT_SYMBOL(blk_register_region);
34481
34482 +/* undo blk_register_region(), noop if @range is zero */
34483 void blk_unregister_region(dev_t devt, unsigned long range)
34484 {
34485 - kobj_unmap(bdev_map, devt, range);
34486 + if (range)
34487 + kobj_unmap(bdev_map, devt, range);
34488 }
34489
34490 EXPORT_SYMBOL(blk_unregister_region);
34491 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34492 index c85fc89..51e690b 100644
34493 --- a/block/partitions/efi.c
34494 +++ b/block/partitions/efi.c
34495 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34496 if (!gpt)
34497 return NULL;
34498
34499 + if (!le32_to_cpu(gpt->num_partition_entries))
34500 + return NULL;
34501 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34502 + if (!pte)
34503 + return NULL;
34504 +
34505 count = le32_to_cpu(gpt->num_partition_entries) *
34506 le32_to_cpu(gpt->sizeof_partition_entry);
34507 - if (!count)
34508 - return NULL;
34509 - pte = kmalloc(count, GFP_KERNEL);
34510 - if (!pte)
34511 - return NULL;
34512 -
34513 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34514 (u8 *) pte,
34515 count) < count) {
34516 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34517 index a5ffcc9..3cedc9c 100644
34518 --- a/block/scsi_ioctl.c
34519 +++ b/block/scsi_ioctl.c
34520 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34521 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34522 struct sg_io_hdr *hdr, fmode_t mode)
34523 {
34524 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34525 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34526 + unsigned char *cmdptr;
34527 +
34528 + if (rq->cmd != rq->__cmd)
34529 + cmdptr = rq->cmd;
34530 + else
34531 + cmdptr = tmpcmd;
34532 +
34533 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34534 return -EFAULT;
34535 +
34536 + if (cmdptr != rq->cmd)
34537 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34538 +
34539 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34540 return -EPERM;
34541
34542 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34543 int err;
34544 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34545 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34546 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34547 + unsigned char *cmdptr;
34548
34549 if (!sic)
34550 return -EINVAL;
34551 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34552 */
34553 err = -EFAULT;
34554 rq->cmd_len = cmdlen;
34555 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34556 +
34557 + if (rq->cmd != rq->__cmd)
34558 + cmdptr = rq->cmd;
34559 + else
34560 + cmdptr = tmpcmd;
34561 +
34562 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34563 goto error;
34564
34565 + if (rq->cmd != cmdptr)
34566 + memcpy(rq->cmd, cmdptr, cmdlen);
34567 +
34568 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34569 goto error;
34570
34571 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34572 index 7bdd61b..afec999 100644
34573 --- a/crypto/cryptd.c
34574 +++ b/crypto/cryptd.c
34575 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34576
34577 struct cryptd_blkcipher_request_ctx {
34578 crypto_completion_t complete;
34579 -};
34580 +} __no_const;
34581
34582 struct cryptd_hash_ctx {
34583 struct crypto_shash *child;
34584 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34585
34586 struct cryptd_aead_request_ctx {
34587 crypto_completion_t complete;
34588 -};
34589 +} __no_const;
34590
34591 static void cryptd_queue_worker(struct work_struct *work);
34592
34593 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34594 index f8c920c..ab2cb5a 100644
34595 --- a/crypto/pcrypt.c
34596 +++ b/crypto/pcrypt.c
34597 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34598 int ret;
34599
34600 pinst->kobj.kset = pcrypt_kset;
34601 - ret = kobject_add(&pinst->kobj, NULL, name);
34602 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34603 if (!ret)
34604 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34605
34606 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34607 index f220d64..d359ad6 100644
34608 --- a/drivers/acpi/apei/apei-internal.h
34609 +++ b/drivers/acpi/apei/apei-internal.h
34610 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34611 struct apei_exec_ins_type {
34612 u32 flags;
34613 apei_exec_ins_func_t run;
34614 -};
34615 +} __do_const;
34616
34617 struct apei_exec_context {
34618 u32 ip;
34619 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34620 index 33dc6a0..4b24b47 100644
34621 --- a/drivers/acpi/apei/cper.c
34622 +++ b/drivers/acpi/apei/cper.c
34623 @@ -39,12 +39,12 @@
34624 */
34625 u64 cper_next_record_id(void)
34626 {
34627 - static atomic64_t seq;
34628 + static atomic64_unchecked_t seq;
34629
34630 - if (!atomic64_read(&seq))
34631 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34632 + if (!atomic64_read_unchecked(&seq))
34633 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34634
34635 - return atomic64_inc_return(&seq);
34636 + return atomic64_inc_return_unchecked(&seq);
34637 }
34638 EXPORT_SYMBOL_GPL(cper_next_record_id);
34639
34640 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34641 index ec9b57d..9682b3a 100644
34642 --- a/drivers/acpi/apei/ghes.c
34643 +++ b/drivers/acpi/apei/ghes.c
34644 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34645 const struct acpi_hest_generic *generic,
34646 const struct acpi_hest_generic_status *estatus)
34647 {
34648 - static atomic_t seqno;
34649 + static atomic_unchecked_t seqno;
34650 unsigned int curr_seqno;
34651 char pfx_seq[64];
34652
34653 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34654 else
34655 pfx = KERN_ERR;
34656 }
34657 - curr_seqno = atomic_inc_return(&seqno);
34658 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34659 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34660 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34661 pfx_seq, generic->header.source_id);
34662 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34663 index be60399..778b33e8 100644
34664 --- a/drivers/acpi/bgrt.c
34665 +++ b/drivers/acpi/bgrt.c
34666 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34667 return -ENODEV;
34668
34669 sysfs_bin_attr_init(&image_attr);
34670 - image_attr.private = bgrt_image;
34671 - image_attr.size = bgrt_image_size;
34672 + pax_open_kernel();
34673 + *(void **)&image_attr.private = bgrt_image;
34674 + *(size_t *)&image_attr.size = bgrt_image_size;
34675 + pax_close_kernel();
34676
34677 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34678 if (!bgrt_kobj)
34679 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34680 index cb96296..b81293b 100644
34681 --- a/drivers/acpi/blacklist.c
34682 +++ b/drivers/acpi/blacklist.c
34683 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34684 u32 is_critical_error;
34685 };
34686
34687 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34688 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34689
34690 /*
34691 * POLICY: If *anything* doesn't work, put it on the blacklist.
34692 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34693 return 0;
34694 }
34695
34696 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34697 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34698 {
34699 .callback = dmi_disable_osi_vista,
34700 .ident = "Fujitsu Siemens",
34701 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34702 index f98dd00..7b69865 100644
34703 --- a/drivers/acpi/processor_idle.c
34704 +++ b/drivers/acpi/processor_idle.c
34705 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34706 {
34707 int i, count = CPUIDLE_DRIVER_STATE_START;
34708 struct acpi_processor_cx *cx;
34709 - struct cpuidle_state *state;
34710 + cpuidle_state_no_const *state;
34711 struct cpuidle_driver *drv = &acpi_idle_driver;
34712
34713 if (!pr->flags.power_setup_done)
34714 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34715 index 05306a5..733d1f0 100644
34716 --- a/drivers/acpi/sysfs.c
34717 +++ b/drivers/acpi/sysfs.c
34718 @@ -423,11 +423,11 @@ static u32 num_counters;
34719 static struct attribute **all_attrs;
34720 static u32 acpi_gpe_count;
34721
34722 -static struct attribute_group interrupt_stats_attr_group = {
34723 +static attribute_group_no_const interrupt_stats_attr_group = {
34724 .name = "interrupts",
34725 };
34726
34727 -static struct kobj_attribute *counter_attrs;
34728 +static kobj_attribute_no_const *counter_attrs;
34729
34730 static void delete_gpe_attr_array(void)
34731 {
34732 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34733 index acfd0f7..e5acb08 100644
34734 --- a/drivers/ata/libahci.c
34735 +++ b/drivers/ata/libahci.c
34736 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34737 }
34738 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34739
34740 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34741 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34742 struct ata_taskfile *tf, int is_cmd, u16 flags,
34743 unsigned long timeout_msec)
34744 {
34745 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34746 index c24354d..335c975 100644
34747 --- a/drivers/ata/libata-core.c
34748 +++ b/drivers/ata/libata-core.c
34749 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34750 static void ata_dev_xfermask(struct ata_device *dev);
34751 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34752
34753 -atomic_t ata_print_id = ATOMIC_INIT(0);
34754 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34755
34756 struct ata_force_param {
34757 const char *name;
34758 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34759 struct ata_port *ap;
34760 unsigned int tag;
34761
34762 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34763 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34764 ap = qc->ap;
34765
34766 qc->flags = 0;
34767 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34768 struct ata_port *ap;
34769 struct ata_link *link;
34770
34771 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34772 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34773 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34774 ap = qc->ap;
34775 link = qc->dev->link;
34776 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34777 return;
34778
34779 spin_lock(&lock);
34780 + pax_open_kernel();
34781
34782 for (cur = ops->inherits; cur; cur = cur->inherits) {
34783 void **inherit = (void **)cur;
34784 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34785 if (IS_ERR(*pp))
34786 *pp = NULL;
34787
34788 - ops->inherits = NULL;
34789 + *(struct ata_port_operations **)&ops->inherits = NULL;
34790
34791 + pax_close_kernel();
34792 spin_unlock(&lock);
34793 }
34794
34795 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34796
34797 /* give ports names and add SCSI hosts */
34798 for (i = 0; i < host->n_ports; i++) {
34799 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34800 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34801 host->ports[i]->local_port_no = i + 1;
34802 }
34803
34804 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34805 index b1e880a..8cf82e1 100644
34806 --- a/drivers/ata/libata-scsi.c
34807 +++ b/drivers/ata/libata-scsi.c
34808 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34809
34810 if (rc)
34811 return rc;
34812 - ap->print_id = atomic_inc_return(&ata_print_id);
34813 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34814 return 0;
34815 }
34816 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34817 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34818 index 577d902b..cb4781e 100644
34819 --- a/drivers/ata/libata.h
34820 +++ b/drivers/ata/libata.h
34821 @@ -53,7 +53,7 @@ enum {
34822 ATA_DNXFER_QUIET = (1 << 31),
34823 };
34824
34825 -extern atomic_t ata_print_id;
34826 +extern atomic_unchecked_t ata_print_id;
34827 extern int atapi_passthru16;
34828 extern int libata_fua;
34829 extern int libata_noacpi;
34830 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34831 index 848ed32..132f39d 100644
34832 --- a/drivers/ata/pata_arasan_cf.c
34833 +++ b/drivers/ata/pata_arasan_cf.c
34834 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34835 /* Handle platform specific quirks */
34836 if (quirk) {
34837 if (quirk & CF_BROKEN_PIO) {
34838 - ap->ops->set_piomode = NULL;
34839 + pax_open_kernel();
34840 + *(void **)&ap->ops->set_piomode = NULL;
34841 + pax_close_kernel();
34842 ap->pio_mask = 0;
34843 }
34844 if (quirk & CF_BROKEN_MWDMA)
34845 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34846 index f9b983a..887b9d8 100644
34847 --- a/drivers/atm/adummy.c
34848 +++ b/drivers/atm/adummy.c
34849 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34850 vcc->pop(vcc, skb);
34851 else
34852 dev_kfree_skb_any(skb);
34853 - atomic_inc(&vcc->stats->tx);
34854 + atomic_inc_unchecked(&vcc->stats->tx);
34855
34856 return 0;
34857 }
34858 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34859 index 62a7607..cc4be104 100644
34860 --- a/drivers/atm/ambassador.c
34861 +++ b/drivers/atm/ambassador.c
34862 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34863 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34864
34865 // VC layer stats
34866 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34867 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34868
34869 // free the descriptor
34870 kfree (tx_descr);
34871 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34872 dump_skb ("<<<", vc, skb);
34873
34874 // VC layer stats
34875 - atomic_inc(&atm_vcc->stats->rx);
34876 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34877 __net_timestamp(skb);
34878 // end of our responsibility
34879 atm_vcc->push (atm_vcc, skb);
34880 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34881 } else {
34882 PRINTK (KERN_INFO, "dropped over-size frame");
34883 // should we count this?
34884 - atomic_inc(&atm_vcc->stats->rx_drop);
34885 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34886 }
34887
34888 } else {
34889 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34890 }
34891
34892 if (check_area (skb->data, skb->len)) {
34893 - atomic_inc(&atm_vcc->stats->tx_err);
34894 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34895 return -ENOMEM; // ?
34896 }
34897
34898 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34899 index 0e3f8f9..765a7a5 100644
34900 --- a/drivers/atm/atmtcp.c
34901 +++ b/drivers/atm/atmtcp.c
34902 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34903 if (vcc->pop) vcc->pop(vcc,skb);
34904 else dev_kfree_skb(skb);
34905 if (dev_data) return 0;
34906 - atomic_inc(&vcc->stats->tx_err);
34907 + atomic_inc_unchecked(&vcc->stats->tx_err);
34908 return -ENOLINK;
34909 }
34910 size = skb->len+sizeof(struct atmtcp_hdr);
34911 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34912 if (!new_skb) {
34913 if (vcc->pop) vcc->pop(vcc,skb);
34914 else dev_kfree_skb(skb);
34915 - atomic_inc(&vcc->stats->tx_err);
34916 + atomic_inc_unchecked(&vcc->stats->tx_err);
34917 return -ENOBUFS;
34918 }
34919 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34920 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34921 if (vcc->pop) vcc->pop(vcc,skb);
34922 else dev_kfree_skb(skb);
34923 out_vcc->push(out_vcc,new_skb);
34924 - atomic_inc(&vcc->stats->tx);
34925 - atomic_inc(&out_vcc->stats->rx);
34926 + atomic_inc_unchecked(&vcc->stats->tx);
34927 + atomic_inc_unchecked(&out_vcc->stats->rx);
34928 return 0;
34929 }
34930
34931 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34932 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34933 read_unlock(&vcc_sklist_lock);
34934 if (!out_vcc) {
34935 - atomic_inc(&vcc->stats->tx_err);
34936 + atomic_inc_unchecked(&vcc->stats->tx_err);
34937 goto done;
34938 }
34939 skb_pull(skb,sizeof(struct atmtcp_hdr));
34940 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34941 __net_timestamp(new_skb);
34942 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34943 out_vcc->push(out_vcc,new_skb);
34944 - atomic_inc(&vcc->stats->tx);
34945 - atomic_inc(&out_vcc->stats->rx);
34946 + atomic_inc_unchecked(&vcc->stats->tx);
34947 + atomic_inc_unchecked(&out_vcc->stats->rx);
34948 done:
34949 if (vcc->pop) vcc->pop(vcc,skb);
34950 else dev_kfree_skb(skb);
34951 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34952 index b1955ba..b179940 100644
34953 --- a/drivers/atm/eni.c
34954 +++ b/drivers/atm/eni.c
34955 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34956 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34957 vcc->dev->number);
34958 length = 0;
34959 - atomic_inc(&vcc->stats->rx_err);
34960 + atomic_inc_unchecked(&vcc->stats->rx_err);
34961 }
34962 else {
34963 length = ATM_CELL_SIZE-1; /* no HEC */
34964 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34965 size);
34966 }
34967 eff = length = 0;
34968 - atomic_inc(&vcc->stats->rx_err);
34969 + atomic_inc_unchecked(&vcc->stats->rx_err);
34970 }
34971 else {
34972 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34973 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34974 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34975 vcc->dev->number,vcc->vci,length,size << 2,descr);
34976 length = eff = 0;
34977 - atomic_inc(&vcc->stats->rx_err);
34978 + atomic_inc_unchecked(&vcc->stats->rx_err);
34979 }
34980 }
34981 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34982 @@ -767,7 +767,7 @@ rx_dequeued++;
34983 vcc->push(vcc,skb);
34984 pushed++;
34985 }
34986 - atomic_inc(&vcc->stats->rx);
34987 + atomic_inc_unchecked(&vcc->stats->rx);
34988 }
34989 wake_up(&eni_dev->rx_wait);
34990 }
34991 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34992 PCI_DMA_TODEVICE);
34993 if (vcc->pop) vcc->pop(vcc,skb);
34994 else dev_kfree_skb_irq(skb);
34995 - atomic_inc(&vcc->stats->tx);
34996 + atomic_inc_unchecked(&vcc->stats->tx);
34997 wake_up(&eni_dev->tx_wait);
34998 dma_complete++;
34999 }
35000 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
35001 index b41c948..a002b17 100644
35002 --- a/drivers/atm/firestream.c
35003 +++ b/drivers/atm/firestream.c
35004 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
35005 }
35006 }
35007
35008 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35009 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35010
35011 fs_dprintk (FS_DEBUG_TXMEM, "i");
35012 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
35013 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35014 #endif
35015 skb_put (skb, qe->p1 & 0xffff);
35016 ATM_SKB(skb)->vcc = atm_vcc;
35017 - atomic_inc(&atm_vcc->stats->rx);
35018 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35019 __net_timestamp(skb);
35020 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
35021 atm_vcc->push (atm_vcc, skb);
35022 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35023 kfree (pe);
35024 }
35025 if (atm_vcc)
35026 - atomic_inc(&atm_vcc->stats->rx_drop);
35027 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35028 break;
35029 case 0x1f: /* Reassembly abort: no buffers. */
35030 /* Silently increment error counter. */
35031 if (atm_vcc)
35032 - atomic_inc(&atm_vcc->stats->rx_drop);
35033 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35034 break;
35035 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
35036 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
35037 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
35038 index 204814e..cede831 100644
35039 --- a/drivers/atm/fore200e.c
35040 +++ b/drivers/atm/fore200e.c
35041 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35042 #endif
35043 /* check error condition */
35044 if (*entry->status & STATUS_ERROR)
35045 - atomic_inc(&vcc->stats->tx_err);
35046 + atomic_inc_unchecked(&vcc->stats->tx_err);
35047 else
35048 - atomic_inc(&vcc->stats->tx);
35049 + atomic_inc_unchecked(&vcc->stats->tx);
35050 }
35051 }
35052
35053 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35054 if (skb == NULL) {
35055 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35056
35057 - atomic_inc(&vcc->stats->rx_drop);
35058 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35059 return -ENOMEM;
35060 }
35061
35062 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35063
35064 dev_kfree_skb_any(skb);
35065
35066 - atomic_inc(&vcc->stats->rx_drop);
35067 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35068 return -ENOMEM;
35069 }
35070
35071 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35072
35073 vcc->push(vcc, skb);
35074 - atomic_inc(&vcc->stats->rx);
35075 + atomic_inc_unchecked(&vcc->stats->rx);
35076
35077 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35078
35079 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35080 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35081 fore200e->atm_dev->number,
35082 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35083 - atomic_inc(&vcc->stats->rx_err);
35084 + atomic_inc_unchecked(&vcc->stats->rx_err);
35085 }
35086 }
35087
35088 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35089 goto retry_here;
35090 }
35091
35092 - atomic_inc(&vcc->stats->tx_err);
35093 + atomic_inc_unchecked(&vcc->stats->tx_err);
35094
35095 fore200e->tx_sat++;
35096 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35097 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35098 index 507362a..a845e57 100644
35099 --- a/drivers/atm/he.c
35100 +++ b/drivers/atm/he.c
35101 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35102
35103 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35104 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35105 - atomic_inc(&vcc->stats->rx_drop);
35106 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35107 goto return_host_buffers;
35108 }
35109
35110 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35111 RBRQ_LEN_ERR(he_dev->rbrq_head)
35112 ? "LEN_ERR" : "",
35113 vcc->vpi, vcc->vci);
35114 - atomic_inc(&vcc->stats->rx_err);
35115 + atomic_inc_unchecked(&vcc->stats->rx_err);
35116 goto return_host_buffers;
35117 }
35118
35119 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35120 vcc->push(vcc, skb);
35121 spin_lock(&he_dev->global_lock);
35122
35123 - atomic_inc(&vcc->stats->rx);
35124 + atomic_inc_unchecked(&vcc->stats->rx);
35125
35126 return_host_buffers:
35127 ++pdus_assembled;
35128 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35129 tpd->vcc->pop(tpd->vcc, tpd->skb);
35130 else
35131 dev_kfree_skb_any(tpd->skb);
35132 - atomic_inc(&tpd->vcc->stats->tx_err);
35133 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35134 }
35135 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35136 return;
35137 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35138 vcc->pop(vcc, skb);
35139 else
35140 dev_kfree_skb_any(skb);
35141 - atomic_inc(&vcc->stats->tx_err);
35142 + atomic_inc_unchecked(&vcc->stats->tx_err);
35143 return -EINVAL;
35144 }
35145
35146 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35147 vcc->pop(vcc, skb);
35148 else
35149 dev_kfree_skb_any(skb);
35150 - atomic_inc(&vcc->stats->tx_err);
35151 + atomic_inc_unchecked(&vcc->stats->tx_err);
35152 return -EINVAL;
35153 }
35154 #endif
35155 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35156 vcc->pop(vcc, skb);
35157 else
35158 dev_kfree_skb_any(skb);
35159 - atomic_inc(&vcc->stats->tx_err);
35160 + atomic_inc_unchecked(&vcc->stats->tx_err);
35161 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35162 return -ENOMEM;
35163 }
35164 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35165 vcc->pop(vcc, skb);
35166 else
35167 dev_kfree_skb_any(skb);
35168 - atomic_inc(&vcc->stats->tx_err);
35169 + atomic_inc_unchecked(&vcc->stats->tx_err);
35170 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35171 return -ENOMEM;
35172 }
35173 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35174 __enqueue_tpd(he_dev, tpd, cid);
35175 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35176
35177 - atomic_inc(&vcc->stats->tx);
35178 + atomic_inc_unchecked(&vcc->stats->tx);
35179
35180 return 0;
35181 }
35182 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35183 index 1dc0519..1aadaf7 100644
35184 --- a/drivers/atm/horizon.c
35185 +++ b/drivers/atm/horizon.c
35186 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35187 {
35188 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35189 // VC layer stats
35190 - atomic_inc(&vcc->stats->rx);
35191 + atomic_inc_unchecked(&vcc->stats->rx);
35192 __net_timestamp(skb);
35193 // end of our responsibility
35194 vcc->push (vcc, skb);
35195 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35196 dev->tx_iovec = NULL;
35197
35198 // VC layer stats
35199 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35200 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35201
35202 // free the skb
35203 hrz_kfree_skb (skb);
35204 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35205 index 272f009..a18ba55 100644
35206 --- a/drivers/atm/idt77252.c
35207 +++ b/drivers/atm/idt77252.c
35208 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35209 else
35210 dev_kfree_skb(skb);
35211
35212 - atomic_inc(&vcc->stats->tx);
35213 + atomic_inc_unchecked(&vcc->stats->tx);
35214 }
35215
35216 atomic_dec(&scq->used);
35217 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35218 if ((sb = dev_alloc_skb(64)) == NULL) {
35219 printk("%s: Can't allocate buffers for aal0.\n",
35220 card->name);
35221 - atomic_add(i, &vcc->stats->rx_drop);
35222 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35223 break;
35224 }
35225 if (!atm_charge(vcc, sb->truesize)) {
35226 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35227 card->name);
35228 - atomic_add(i - 1, &vcc->stats->rx_drop);
35229 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35230 dev_kfree_skb(sb);
35231 break;
35232 }
35233 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35234 ATM_SKB(sb)->vcc = vcc;
35235 __net_timestamp(sb);
35236 vcc->push(vcc, sb);
35237 - atomic_inc(&vcc->stats->rx);
35238 + atomic_inc_unchecked(&vcc->stats->rx);
35239
35240 cell += ATM_CELL_PAYLOAD;
35241 }
35242 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35243 "(CDC: %08x)\n",
35244 card->name, len, rpp->len, readl(SAR_REG_CDC));
35245 recycle_rx_pool_skb(card, rpp);
35246 - atomic_inc(&vcc->stats->rx_err);
35247 + atomic_inc_unchecked(&vcc->stats->rx_err);
35248 return;
35249 }
35250 if (stat & SAR_RSQE_CRC) {
35251 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35252 recycle_rx_pool_skb(card, rpp);
35253 - atomic_inc(&vcc->stats->rx_err);
35254 + atomic_inc_unchecked(&vcc->stats->rx_err);
35255 return;
35256 }
35257 if (skb_queue_len(&rpp->queue) > 1) {
35258 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35259 RXPRINTK("%s: Can't alloc RX skb.\n",
35260 card->name);
35261 recycle_rx_pool_skb(card, rpp);
35262 - atomic_inc(&vcc->stats->rx_err);
35263 + atomic_inc_unchecked(&vcc->stats->rx_err);
35264 return;
35265 }
35266 if (!atm_charge(vcc, skb->truesize)) {
35267 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35268 __net_timestamp(skb);
35269
35270 vcc->push(vcc, skb);
35271 - atomic_inc(&vcc->stats->rx);
35272 + atomic_inc_unchecked(&vcc->stats->rx);
35273
35274 return;
35275 }
35276 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35277 __net_timestamp(skb);
35278
35279 vcc->push(vcc, skb);
35280 - atomic_inc(&vcc->stats->rx);
35281 + atomic_inc_unchecked(&vcc->stats->rx);
35282
35283 if (skb->truesize > SAR_FB_SIZE_3)
35284 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35285 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35286 if (vcc->qos.aal != ATM_AAL0) {
35287 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35288 card->name, vpi, vci);
35289 - atomic_inc(&vcc->stats->rx_drop);
35290 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35291 goto drop;
35292 }
35293
35294 if ((sb = dev_alloc_skb(64)) == NULL) {
35295 printk("%s: Can't allocate buffers for AAL0.\n",
35296 card->name);
35297 - atomic_inc(&vcc->stats->rx_err);
35298 + atomic_inc_unchecked(&vcc->stats->rx_err);
35299 goto drop;
35300 }
35301
35302 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35303 ATM_SKB(sb)->vcc = vcc;
35304 __net_timestamp(sb);
35305 vcc->push(vcc, sb);
35306 - atomic_inc(&vcc->stats->rx);
35307 + atomic_inc_unchecked(&vcc->stats->rx);
35308
35309 drop:
35310 skb_pull(queue, 64);
35311 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35312
35313 if (vc == NULL) {
35314 printk("%s: NULL connection in send().\n", card->name);
35315 - atomic_inc(&vcc->stats->tx_err);
35316 + atomic_inc_unchecked(&vcc->stats->tx_err);
35317 dev_kfree_skb(skb);
35318 return -EINVAL;
35319 }
35320 if (!test_bit(VCF_TX, &vc->flags)) {
35321 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35322 - atomic_inc(&vcc->stats->tx_err);
35323 + atomic_inc_unchecked(&vcc->stats->tx_err);
35324 dev_kfree_skb(skb);
35325 return -EINVAL;
35326 }
35327 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35328 break;
35329 default:
35330 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35331 - atomic_inc(&vcc->stats->tx_err);
35332 + atomic_inc_unchecked(&vcc->stats->tx_err);
35333 dev_kfree_skb(skb);
35334 return -EINVAL;
35335 }
35336
35337 if (skb_shinfo(skb)->nr_frags != 0) {
35338 printk("%s: No scatter-gather yet.\n", card->name);
35339 - atomic_inc(&vcc->stats->tx_err);
35340 + atomic_inc_unchecked(&vcc->stats->tx_err);
35341 dev_kfree_skb(skb);
35342 return -EINVAL;
35343 }
35344 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35345
35346 err = queue_skb(card, vc, skb, oam);
35347 if (err) {
35348 - atomic_inc(&vcc->stats->tx_err);
35349 + atomic_inc_unchecked(&vcc->stats->tx_err);
35350 dev_kfree_skb(skb);
35351 return err;
35352 }
35353 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35354 skb = dev_alloc_skb(64);
35355 if (!skb) {
35356 printk("%s: Out of memory in send_oam().\n", card->name);
35357 - atomic_inc(&vcc->stats->tx_err);
35358 + atomic_inc_unchecked(&vcc->stats->tx_err);
35359 return -ENOMEM;
35360 }
35361 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35362 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35363 index 4217f29..88f547a 100644
35364 --- a/drivers/atm/iphase.c
35365 +++ b/drivers/atm/iphase.c
35366 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35367 status = (u_short) (buf_desc_ptr->desc_mode);
35368 if (status & (RX_CER | RX_PTE | RX_OFL))
35369 {
35370 - atomic_inc(&vcc->stats->rx_err);
35371 + atomic_inc_unchecked(&vcc->stats->rx_err);
35372 IF_ERR(printk("IA: bad packet, dropping it");)
35373 if (status & RX_CER) {
35374 IF_ERR(printk(" cause: packet CRC error\n");)
35375 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35376 len = dma_addr - buf_addr;
35377 if (len > iadev->rx_buf_sz) {
35378 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35379 - atomic_inc(&vcc->stats->rx_err);
35380 + atomic_inc_unchecked(&vcc->stats->rx_err);
35381 goto out_free_desc;
35382 }
35383
35384 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35385 ia_vcc = INPH_IA_VCC(vcc);
35386 if (ia_vcc == NULL)
35387 {
35388 - atomic_inc(&vcc->stats->rx_err);
35389 + atomic_inc_unchecked(&vcc->stats->rx_err);
35390 atm_return(vcc, skb->truesize);
35391 dev_kfree_skb_any(skb);
35392 goto INCR_DLE;
35393 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35394 if ((length > iadev->rx_buf_sz) || (length >
35395 (skb->len - sizeof(struct cpcs_trailer))))
35396 {
35397 - atomic_inc(&vcc->stats->rx_err);
35398 + atomic_inc_unchecked(&vcc->stats->rx_err);
35399 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35400 length, skb->len);)
35401 atm_return(vcc, skb->truesize);
35402 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35403
35404 IF_RX(printk("rx_dle_intr: skb push");)
35405 vcc->push(vcc,skb);
35406 - atomic_inc(&vcc->stats->rx);
35407 + atomic_inc_unchecked(&vcc->stats->rx);
35408 iadev->rx_pkt_cnt++;
35409 }
35410 INCR_DLE:
35411 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35412 {
35413 struct k_sonet_stats *stats;
35414 stats = &PRIV(_ia_dev[board])->sonet_stats;
35415 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35416 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35417 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35418 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35419 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35420 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35421 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35422 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35423 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35424 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35425 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35426 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35427 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35428 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35429 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35430 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35431 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35432 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35433 }
35434 ia_cmds.status = 0;
35435 break;
35436 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35437 if ((desc == 0) || (desc > iadev->num_tx_desc))
35438 {
35439 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35440 - atomic_inc(&vcc->stats->tx);
35441 + atomic_inc_unchecked(&vcc->stats->tx);
35442 if (vcc->pop)
35443 vcc->pop(vcc, skb);
35444 else
35445 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35446 ATM_DESC(skb) = vcc->vci;
35447 skb_queue_tail(&iadev->tx_dma_q, skb);
35448
35449 - atomic_inc(&vcc->stats->tx);
35450 + atomic_inc_unchecked(&vcc->stats->tx);
35451 iadev->tx_pkt_cnt++;
35452 /* Increment transaction counter */
35453 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35454
35455 #if 0
35456 /* add flow control logic */
35457 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35458 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35459 if (iavcc->vc_desc_cnt > 10) {
35460 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35461 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35462 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35463 index fa7d701..1e404c7 100644
35464 --- a/drivers/atm/lanai.c
35465 +++ b/drivers/atm/lanai.c
35466 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35467 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35468 lanai_endtx(lanai, lvcc);
35469 lanai_free_skb(lvcc->tx.atmvcc, skb);
35470 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35471 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35472 }
35473
35474 /* Try to fill the buffer - don't call unless there is backlog */
35475 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35476 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35477 __net_timestamp(skb);
35478 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35479 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35480 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35481 out:
35482 lvcc->rx.buf.ptr = end;
35483 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35484 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35485 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35486 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35487 lanai->stats.service_rxnotaal5++;
35488 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35489 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35490 return 0;
35491 }
35492 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35493 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35494 int bytes;
35495 read_unlock(&vcc_sklist_lock);
35496 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35497 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35498 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35499 lvcc->stats.x.aal5.service_trash++;
35500 bytes = (SERVICE_GET_END(s) * 16) -
35501 (((unsigned long) lvcc->rx.buf.ptr) -
35502 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35503 }
35504 if (s & SERVICE_STREAM) {
35505 read_unlock(&vcc_sklist_lock);
35506 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35507 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35508 lvcc->stats.x.aal5.service_stream++;
35509 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35510 "PDU on VCI %d!\n", lanai->number, vci);
35511 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35512 return 0;
35513 }
35514 DPRINTK("got rx crc error on vci %d\n", vci);
35515 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35516 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35517 lvcc->stats.x.aal5.service_rxcrc++;
35518 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35519 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35520 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35521 index 6587dc2..149833d 100644
35522 --- a/drivers/atm/nicstar.c
35523 +++ b/drivers/atm/nicstar.c
35524 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35525 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35526 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35527 card->index);
35528 - atomic_inc(&vcc->stats->tx_err);
35529 + atomic_inc_unchecked(&vcc->stats->tx_err);
35530 dev_kfree_skb_any(skb);
35531 return -EINVAL;
35532 }
35533 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35534 if (!vc->tx) {
35535 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35536 card->index);
35537 - atomic_inc(&vcc->stats->tx_err);
35538 + atomic_inc_unchecked(&vcc->stats->tx_err);
35539 dev_kfree_skb_any(skb);
35540 return -EINVAL;
35541 }
35542 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35543 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35544 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35545 card->index);
35546 - atomic_inc(&vcc->stats->tx_err);
35547 + atomic_inc_unchecked(&vcc->stats->tx_err);
35548 dev_kfree_skb_any(skb);
35549 return -EINVAL;
35550 }
35551
35552 if (skb_shinfo(skb)->nr_frags != 0) {
35553 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35554 - atomic_inc(&vcc->stats->tx_err);
35555 + atomic_inc_unchecked(&vcc->stats->tx_err);
35556 dev_kfree_skb_any(skb);
35557 return -EINVAL;
35558 }
35559 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35560 }
35561
35562 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35563 - atomic_inc(&vcc->stats->tx_err);
35564 + atomic_inc_unchecked(&vcc->stats->tx_err);
35565 dev_kfree_skb_any(skb);
35566 return -EIO;
35567 }
35568 - atomic_inc(&vcc->stats->tx);
35569 + atomic_inc_unchecked(&vcc->stats->tx);
35570
35571 return 0;
35572 }
35573 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35574 printk
35575 ("nicstar%d: Can't allocate buffers for aal0.\n",
35576 card->index);
35577 - atomic_add(i, &vcc->stats->rx_drop);
35578 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35579 break;
35580 }
35581 if (!atm_charge(vcc, sb->truesize)) {
35582 RXPRINTK
35583 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35584 card->index);
35585 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35586 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35587 dev_kfree_skb_any(sb);
35588 break;
35589 }
35590 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35591 ATM_SKB(sb)->vcc = vcc;
35592 __net_timestamp(sb);
35593 vcc->push(vcc, sb);
35594 - atomic_inc(&vcc->stats->rx);
35595 + atomic_inc_unchecked(&vcc->stats->rx);
35596 cell += ATM_CELL_PAYLOAD;
35597 }
35598
35599 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35600 if (iovb == NULL) {
35601 printk("nicstar%d: Out of iovec buffers.\n",
35602 card->index);
35603 - atomic_inc(&vcc->stats->rx_drop);
35604 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35605 recycle_rx_buf(card, skb);
35606 return;
35607 }
35608 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35609 small or large buffer itself. */
35610 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35611 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35612 - atomic_inc(&vcc->stats->rx_err);
35613 + atomic_inc_unchecked(&vcc->stats->rx_err);
35614 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35615 NS_MAX_IOVECS);
35616 NS_PRV_IOVCNT(iovb) = 0;
35617 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35618 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35619 card->index);
35620 which_list(card, skb);
35621 - atomic_inc(&vcc->stats->rx_err);
35622 + atomic_inc_unchecked(&vcc->stats->rx_err);
35623 recycle_rx_buf(card, skb);
35624 vc->rx_iov = NULL;
35625 recycle_iov_buf(card, iovb);
35626 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35627 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35628 card->index);
35629 which_list(card, skb);
35630 - atomic_inc(&vcc->stats->rx_err);
35631 + atomic_inc_unchecked(&vcc->stats->rx_err);
35632 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35633 NS_PRV_IOVCNT(iovb));
35634 vc->rx_iov = NULL;
35635 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35636 printk(" - PDU size mismatch.\n");
35637 else
35638 printk(".\n");
35639 - atomic_inc(&vcc->stats->rx_err);
35640 + atomic_inc_unchecked(&vcc->stats->rx_err);
35641 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35642 NS_PRV_IOVCNT(iovb));
35643 vc->rx_iov = NULL;
35644 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35645 /* skb points to a small buffer */
35646 if (!atm_charge(vcc, skb->truesize)) {
35647 push_rxbufs(card, skb);
35648 - atomic_inc(&vcc->stats->rx_drop);
35649 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35650 } else {
35651 skb_put(skb, len);
35652 dequeue_sm_buf(card, skb);
35653 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35654 ATM_SKB(skb)->vcc = vcc;
35655 __net_timestamp(skb);
35656 vcc->push(vcc, skb);
35657 - atomic_inc(&vcc->stats->rx);
35658 + atomic_inc_unchecked(&vcc->stats->rx);
35659 }
35660 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35661 struct sk_buff *sb;
35662 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35663 if (len <= NS_SMBUFSIZE) {
35664 if (!atm_charge(vcc, sb->truesize)) {
35665 push_rxbufs(card, sb);
35666 - atomic_inc(&vcc->stats->rx_drop);
35667 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35668 } else {
35669 skb_put(sb, len);
35670 dequeue_sm_buf(card, sb);
35671 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35672 ATM_SKB(sb)->vcc = vcc;
35673 __net_timestamp(sb);
35674 vcc->push(vcc, sb);
35675 - atomic_inc(&vcc->stats->rx);
35676 + atomic_inc_unchecked(&vcc->stats->rx);
35677 }
35678
35679 push_rxbufs(card, skb);
35680 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35681
35682 if (!atm_charge(vcc, skb->truesize)) {
35683 push_rxbufs(card, skb);
35684 - atomic_inc(&vcc->stats->rx_drop);
35685 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35686 } else {
35687 dequeue_lg_buf(card, skb);
35688 #ifdef NS_USE_DESTRUCTORS
35689 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35690 ATM_SKB(skb)->vcc = vcc;
35691 __net_timestamp(skb);
35692 vcc->push(vcc, skb);
35693 - atomic_inc(&vcc->stats->rx);
35694 + atomic_inc_unchecked(&vcc->stats->rx);
35695 }
35696
35697 push_rxbufs(card, sb);
35698 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35699 printk
35700 ("nicstar%d: Out of huge buffers.\n",
35701 card->index);
35702 - atomic_inc(&vcc->stats->rx_drop);
35703 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35704 recycle_iovec_rx_bufs(card,
35705 (struct iovec *)
35706 iovb->data,
35707 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35708 card->hbpool.count++;
35709 } else
35710 dev_kfree_skb_any(hb);
35711 - atomic_inc(&vcc->stats->rx_drop);
35712 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35713 } else {
35714 /* Copy the small buffer to the huge buffer */
35715 sb = (struct sk_buff *)iov->iov_base;
35716 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35717 #endif /* NS_USE_DESTRUCTORS */
35718 __net_timestamp(hb);
35719 vcc->push(vcc, hb);
35720 - atomic_inc(&vcc->stats->rx);
35721 + atomic_inc_unchecked(&vcc->stats->rx);
35722 }
35723 }
35724
35725 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35726 index 32784d1..4a8434a 100644
35727 --- a/drivers/atm/solos-pci.c
35728 +++ b/drivers/atm/solos-pci.c
35729 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35730 }
35731 atm_charge(vcc, skb->truesize);
35732 vcc->push(vcc, skb);
35733 - atomic_inc(&vcc->stats->rx);
35734 + atomic_inc_unchecked(&vcc->stats->rx);
35735 break;
35736
35737 case PKT_STATUS:
35738 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35739 vcc = SKB_CB(oldskb)->vcc;
35740
35741 if (vcc) {
35742 - atomic_inc(&vcc->stats->tx);
35743 + atomic_inc_unchecked(&vcc->stats->tx);
35744 solos_pop(vcc, oldskb);
35745 } else {
35746 dev_kfree_skb_irq(oldskb);
35747 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35748 index 0215934..ce9f5b1 100644
35749 --- a/drivers/atm/suni.c
35750 +++ b/drivers/atm/suni.c
35751 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35752
35753
35754 #define ADD_LIMITED(s,v) \
35755 - atomic_add((v),&stats->s); \
35756 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35757 + atomic_add_unchecked((v),&stats->s); \
35758 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35759
35760
35761 static void suni_hz(unsigned long from_timer)
35762 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35763 index 5120a96..e2572bd 100644
35764 --- a/drivers/atm/uPD98402.c
35765 +++ b/drivers/atm/uPD98402.c
35766 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35767 struct sonet_stats tmp;
35768 int error = 0;
35769
35770 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35771 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35772 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35773 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35774 if (zero && !error) {
35775 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35776
35777
35778 #define ADD_LIMITED(s,v) \
35779 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35780 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35781 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35782 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35783 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35784 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35785
35786
35787 static void stat_event(struct atm_dev *dev)
35788 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35789 if (reason & uPD98402_INT_PFM) stat_event(dev);
35790 if (reason & uPD98402_INT_PCO) {
35791 (void) GET(PCOCR); /* clear interrupt cause */
35792 - atomic_add(GET(HECCT),
35793 + atomic_add_unchecked(GET(HECCT),
35794 &PRIV(dev)->sonet_stats.uncorr_hcs);
35795 }
35796 if ((reason & uPD98402_INT_RFO) &&
35797 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35798 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35799 uPD98402_INT_LOS),PIMR); /* enable them */
35800 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35801 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35802 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35803 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35804 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35805 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35806 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35807 return 0;
35808 }
35809
35810 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35811 index 969c3c2..9b72956 100644
35812 --- a/drivers/atm/zatm.c
35813 +++ b/drivers/atm/zatm.c
35814 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35815 }
35816 if (!size) {
35817 dev_kfree_skb_irq(skb);
35818 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35819 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35820 continue;
35821 }
35822 if (!atm_charge(vcc,skb->truesize)) {
35823 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35824 skb->len = size;
35825 ATM_SKB(skb)->vcc = vcc;
35826 vcc->push(vcc,skb);
35827 - atomic_inc(&vcc->stats->rx);
35828 + atomic_inc_unchecked(&vcc->stats->rx);
35829 }
35830 zout(pos & 0xffff,MTA(mbx));
35831 #if 0 /* probably a stupid idea */
35832 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35833 skb_queue_head(&zatm_vcc->backlog,skb);
35834 break;
35835 }
35836 - atomic_inc(&vcc->stats->tx);
35837 + atomic_inc_unchecked(&vcc->stats->tx);
35838 wake_up(&zatm_vcc->tx_wait);
35839 }
35840
35841 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35842 index d414331..b4dd4ba 100644
35843 --- a/drivers/base/bus.c
35844 +++ b/drivers/base/bus.c
35845 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35846 return -EINVAL;
35847
35848 mutex_lock(&subsys->p->mutex);
35849 - list_add_tail(&sif->node, &subsys->p->interfaces);
35850 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35851 if (sif->add_dev) {
35852 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35853 while ((dev = subsys_dev_iter_next(&iter)))
35854 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35855 subsys = sif->subsys;
35856
35857 mutex_lock(&subsys->p->mutex);
35858 - list_del_init(&sif->node);
35859 + pax_list_del_init((struct list_head *)&sif->node);
35860 if (sif->remove_dev) {
35861 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35862 while ((dev = subsys_dev_iter_next(&iter)))
35863 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35864 index 7413d06..79155fa 100644
35865 --- a/drivers/base/devtmpfs.c
35866 +++ b/drivers/base/devtmpfs.c
35867 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35868 if (!thread)
35869 return 0;
35870
35871 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35872 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35873 if (err)
35874 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35875 else
35876 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35877 *err = sys_unshare(CLONE_NEWNS);
35878 if (*err)
35879 goto out;
35880 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35881 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35882 if (*err)
35883 goto out;
35884 - sys_chdir("/.."); /* will traverse into overmounted root */
35885 - sys_chroot(".");
35886 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35887 + sys_chroot((char __force_user *)".");
35888 complete(&setup_done);
35889 while (1) {
35890 spin_lock(&req_lock);
35891 diff --git a/drivers/base/node.c b/drivers/base/node.c
35892 index 7616a77c..8f57f51 100644
35893 --- a/drivers/base/node.c
35894 +++ b/drivers/base/node.c
35895 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35896 struct node_attr {
35897 struct device_attribute attr;
35898 enum node_states state;
35899 -};
35900 +} __do_const;
35901
35902 static ssize_t show_node_state(struct device *dev,
35903 struct device_attribute *attr, char *buf)
35904 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35905 index bfb8955..42c9b9a 100644
35906 --- a/drivers/base/power/domain.c
35907 +++ b/drivers/base/power/domain.c
35908 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35909 {
35910 struct cpuidle_driver *cpuidle_drv;
35911 struct gpd_cpu_data *cpu_data;
35912 - struct cpuidle_state *idle_state;
35913 + cpuidle_state_no_const *idle_state;
35914 int ret = 0;
35915
35916 if (IS_ERR_OR_NULL(genpd) || state < 0)
35917 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35918 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35919 {
35920 struct gpd_cpu_data *cpu_data;
35921 - struct cpuidle_state *idle_state;
35922 + cpuidle_state_no_const *idle_state;
35923 int ret = 0;
35924
35925 if (IS_ERR_OR_NULL(genpd))
35926 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35927 index a53ebd2..8f73eeb 100644
35928 --- a/drivers/base/power/sysfs.c
35929 +++ b/drivers/base/power/sysfs.c
35930 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35931 return -EIO;
35932 }
35933 }
35934 - return sprintf(buf, p);
35935 + return sprintf(buf, "%s", p);
35936 }
35937
35938 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35939 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35940 index 2d56f41..8830f19 100644
35941 --- a/drivers/base/power/wakeup.c
35942 +++ b/drivers/base/power/wakeup.c
35943 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35944 * They need to be modified together atomically, so it's better to use one
35945 * atomic variable to hold them both.
35946 */
35947 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35948 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35949
35950 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35951 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35952
35953 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35954 {
35955 - unsigned int comb = atomic_read(&combined_event_count);
35956 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35957
35958 *cnt = (comb >> IN_PROGRESS_BITS);
35959 *inpr = comb & MAX_IN_PROGRESS;
35960 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35961 ws->start_prevent_time = ws->last_time;
35962
35963 /* Increment the counter of events in progress. */
35964 - cec = atomic_inc_return(&combined_event_count);
35965 + cec = atomic_inc_return_unchecked(&combined_event_count);
35966
35967 trace_wakeup_source_activate(ws->name, cec);
35968 }
35969 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35970 * Increment the counter of registered wakeup events and decrement the
35971 * couter of wakeup events in progress simultaneously.
35972 */
35973 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35974 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35975 trace_wakeup_source_deactivate(ws->name, cec);
35976
35977 split_counters(&cnt, &inpr);
35978 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35979 index e8d11b6..7b1b36f 100644
35980 --- a/drivers/base/syscore.c
35981 +++ b/drivers/base/syscore.c
35982 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35983 void register_syscore_ops(struct syscore_ops *ops)
35984 {
35985 mutex_lock(&syscore_ops_lock);
35986 - list_add_tail(&ops->node, &syscore_ops_list);
35987 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35988 mutex_unlock(&syscore_ops_lock);
35989 }
35990 EXPORT_SYMBOL_GPL(register_syscore_ops);
35991 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35992 void unregister_syscore_ops(struct syscore_ops *ops)
35993 {
35994 mutex_lock(&syscore_ops_lock);
35995 - list_del(&ops->node);
35996 + pax_list_del((struct list_head *)&ops->node);
35997 mutex_unlock(&syscore_ops_lock);
35998 }
35999 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
36000 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
36001 index 90a4e6b..002d10f 100644
36002 --- a/drivers/block/cciss.c
36003 +++ b/drivers/block/cciss.c
36004 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
36005 while (!list_empty(&h->reqQ)) {
36006 c = list_entry(h->reqQ.next, CommandList_struct, list);
36007 /* can't do anything if fifo is full */
36008 - if ((h->access.fifo_full(h))) {
36009 + if ((h->access->fifo_full(h))) {
36010 dev_warn(&h->pdev->dev, "fifo full\n");
36011 break;
36012 }
36013 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
36014 h->Qdepth--;
36015
36016 /* Tell the controller execute command */
36017 - h->access.submit_command(h, c);
36018 + h->access->submit_command(h, c);
36019
36020 /* Put job onto the completed Q */
36021 addQ(&h->cmpQ, c);
36022 @@ -3447,17 +3447,17 @@ startio:
36023
36024 static inline unsigned long get_next_completion(ctlr_info_t *h)
36025 {
36026 - return h->access.command_completed(h);
36027 + return h->access->command_completed(h);
36028 }
36029
36030 static inline int interrupt_pending(ctlr_info_t *h)
36031 {
36032 - return h->access.intr_pending(h);
36033 + return h->access->intr_pending(h);
36034 }
36035
36036 static inline long interrupt_not_for_us(ctlr_info_t *h)
36037 {
36038 - return ((h->access.intr_pending(h) == 0) ||
36039 + return ((h->access->intr_pending(h) == 0) ||
36040 (h->interrupts_enabled == 0));
36041 }
36042
36043 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36044 u32 a;
36045
36046 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36047 - return h->access.command_completed(h);
36048 + return h->access->command_completed(h);
36049
36050 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36051 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36052 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36053 trans_support & CFGTBL_Trans_use_short_tags);
36054
36055 /* Change the access methods to the performant access methods */
36056 - h->access = SA5_performant_access;
36057 + h->access = &SA5_performant_access;
36058 h->transMethod = CFGTBL_Trans_Performant;
36059
36060 return;
36061 @@ -4320,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36062 if (prod_index < 0)
36063 return -ENODEV;
36064 h->product_name = products[prod_index].product_name;
36065 - h->access = *(products[prod_index].access);
36066 + h->access = products[prod_index].access;
36067
36068 if (cciss_board_disabled(h)) {
36069 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36070 @@ -5052,7 +5052,7 @@ reinit_after_soft_reset:
36071 }
36072
36073 /* make sure the board interrupts are off */
36074 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36075 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36076 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36077 if (rc)
36078 goto clean2;
36079 @@ -5102,7 +5102,7 @@ reinit_after_soft_reset:
36080 * fake ones to scoop up any residual completions.
36081 */
36082 spin_lock_irqsave(&h->lock, flags);
36083 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36084 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36085 spin_unlock_irqrestore(&h->lock, flags);
36086 free_irq(h->intr[h->intr_mode], h);
36087 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36088 @@ -5122,9 +5122,9 @@ reinit_after_soft_reset:
36089 dev_info(&h->pdev->dev, "Board READY.\n");
36090 dev_info(&h->pdev->dev,
36091 "Waiting for stale completions to drain.\n");
36092 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36093 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36094 msleep(10000);
36095 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36096 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36097
36098 rc = controller_reset_failed(h->cfgtable);
36099 if (rc)
36100 @@ -5147,7 +5147,7 @@ reinit_after_soft_reset:
36101 cciss_scsi_setup(h);
36102
36103 /* Turn the interrupts on so we can service requests */
36104 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36105 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36106
36107 /* Get the firmware version */
36108 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36109 @@ -5219,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36110 kfree(flush_buf);
36111 if (return_code != IO_OK)
36112 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36113 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36114 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36115 free_irq(h->intr[h->intr_mode], h);
36116 }
36117
36118 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36119 index 7fda30e..eb5dfe0 100644
36120 --- a/drivers/block/cciss.h
36121 +++ b/drivers/block/cciss.h
36122 @@ -101,7 +101,7 @@ struct ctlr_info
36123 /* information about each logical volume */
36124 drive_info_struct *drv[CISS_MAX_LUN];
36125
36126 - struct access_method access;
36127 + struct access_method *access;
36128
36129 /* queue and queue Info */
36130 struct list_head reqQ;
36131 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36132 index 2b94403..fd6ad1f 100644
36133 --- a/drivers/block/cpqarray.c
36134 +++ b/drivers/block/cpqarray.c
36135 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36136 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36137 goto Enomem4;
36138 }
36139 - hba[i]->access.set_intr_mask(hba[i], 0);
36140 + hba[i]->access->set_intr_mask(hba[i], 0);
36141 if (request_irq(hba[i]->intr, do_ida_intr,
36142 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36143 {
36144 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36145 add_timer(&hba[i]->timer);
36146
36147 /* Enable IRQ now that spinlock and rate limit timer are set up */
36148 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36149 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36150
36151 for(j=0; j<NWD; j++) {
36152 struct gendisk *disk = ida_gendisk[i][j];
36153 @@ -694,7 +694,7 @@ DBGINFO(
36154 for(i=0; i<NR_PRODUCTS; i++) {
36155 if (board_id == products[i].board_id) {
36156 c->product_name = products[i].product_name;
36157 - c->access = *(products[i].access);
36158 + c->access = products[i].access;
36159 break;
36160 }
36161 }
36162 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36163 hba[ctlr]->intr = intr;
36164 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36165 hba[ctlr]->product_name = products[j].product_name;
36166 - hba[ctlr]->access = *(products[j].access);
36167 + hba[ctlr]->access = products[j].access;
36168 hba[ctlr]->ctlr = ctlr;
36169 hba[ctlr]->board_id = board_id;
36170 hba[ctlr]->pci_dev = NULL; /* not PCI */
36171 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36172
36173 while((c = h->reqQ) != NULL) {
36174 /* Can't do anything if we're busy */
36175 - if (h->access.fifo_full(h) == 0)
36176 + if (h->access->fifo_full(h) == 0)
36177 return;
36178
36179 /* Get the first entry from the request Q */
36180 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36181 h->Qdepth--;
36182
36183 /* Tell the controller to do our bidding */
36184 - h->access.submit_command(h, c);
36185 + h->access->submit_command(h, c);
36186
36187 /* Get onto the completion Q */
36188 addQ(&h->cmpQ, c);
36189 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36190 unsigned long flags;
36191 __u32 a,a1;
36192
36193 - istat = h->access.intr_pending(h);
36194 + istat = h->access->intr_pending(h);
36195 /* Is this interrupt for us? */
36196 if (istat == 0)
36197 return IRQ_NONE;
36198 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36199 */
36200 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36201 if (istat & FIFO_NOT_EMPTY) {
36202 - while((a = h->access.command_completed(h))) {
36203 + while((a = h->access->command_completed(h))) {
36204 a1 = a; a &= ~3;
36205 if ((c = h->cmpQ) == NULL)
36206 {
36207 @@ -1448,11 +1448,11 @@ static int sendcmd(
36208 /*
36209 * Disable interrupt
36210 */
36211 - info_p->access.set_intr_mask(info_p, 0);
36212 + info_p->access->set_intr_mask(info_p, 0);
36213 /* Make sure there is room in the command FIFO */
36214 /* Actually it should be completely empty at this time. */
36215 for (i = 200000; i > 0; i--) {
36216 - temp = info_p->access.fifo_full(info_p);
36217 + temp = info_p->access->fifo_full(info_p);
36218 if (temp != 0) {
36219 break;
36220 }
36221 @@ -1465,7 +1465,7 @@ DBG(
36222 /*
36223 * Send the cmd
36224 */
36225 - info_p->access.submit_command(info_p, c);
36226 + info_p->access->submit_command(info_p, c);
36227 complete = pollcomplete(ctlr);
36228
36229 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36230 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36231 * we check the new geometry. Then turn interrupts back on when
36232 * we're done.
36233 */
36234 - host->access.set_intr_mask(host, 0);
36235 + host->access->set_intr_mask(host, 0);
36236 getgeometry(ctlr);
36237 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36238 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36239
36240 for(i=0; i<NWD; i++) {
36241 struct gendisk *disk = ida_gendisk[ctlr][i];
36242 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36243 /* Wait (up to 2 seconds) for a command to complete */
36244
36245 for (i = 200000; i > 0; i--) {
36246 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36247 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36248 if (done == 0) {
36249 udelay(10); /* a short fixed delay */
36250 } else
36251 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36252 index be73e9d..7fbf140 100644
36253 --- a/drivers/block/cpqarray.h
36254 +++ b/drivers/block/cpqarray.h
36255 @@ -99,7 +99,7 @@ struct ctlr_info {
36256 drv_info_t drv[NWD];
36257 struct proc_dir_entry *proc;
36258
36259 - struct access_method access;
36260 + struct access_method *access;
36261
36262 cmdlist_t *reqQ;
36263 cmdlist_t *cmpQ;
36264 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36265 index 2d7f608..11245fe 100644
36266 --- a/drivers/block/drbd/drbd_int.h
36267 +++ b/drivers/block/drbd/drbd_int.h
36268 @@ -582,7 +582,7 @@ struct drbd_epoch {
36269 struct drbd_tconn *tconn;
36270 struct list_head list;
36271 unsigned int barrier_nr;
36272 - atomic_t epoch_size; /* increased on every request added. */
36273 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36274 atomic_t active; /* increased on every req. added, and dec on every finished. */
36275 unsigned long flags;
36276 };
36277 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36278 unsigned int al_tr_number;
36279 int al_tr_cycle;
36280 wait_queue_head_t seq_wait;
36281 - atomic_t packet_seq;
36282 + atomic_unchecked_t packet_seq;
36283 unsigned int peer_seq;
36284 spinlock_t peer_seq_lock;
36285 unsigned int minor;
36286 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36287 char __user *uoptval;
36288 int err;
36289
36290 - uoptval = (char __user __force *)optval;
36291 + uoptval = (char __force_user *)optval;
36292
36293 set_fs(KERNEL_DS);
36294 if (level == SOL_SOCKET)
36295 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36296 index 55635ed..40e837c 100644
36297 --- a/drivers/block/drbd/drbd_main.c
36298 +++ b/drivers/block/drbd/drbd_main.c
36299 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36300 p->sector = sector;
36301 p->block_id = block_id;
36302 p->blksize = blksize;
36303 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36304 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36305 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36306 }
36307
36308 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36309 return -EIO;
36310 p->sector = cpu_to_be64(req->i.sector);
36311 p->block_id = (unsigned long)req;
36312 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36313 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36314 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36315 if (mdev->state.conn >= C_SYNC_SOURCE &&
36316 mdev->state.conn <= C_PAUSED_SYNC_T)
36317 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36318 {
36319 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36320
36321 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36322 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36323 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36324 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36325 kfree(tconn->current_epoch);
36326
36327 idr_destroy(&tconn->volumes);
36328 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36329 index 8cc1e64..ba7ffa9 100644
36330 --- a/drivers/block/drbd/drbd_nl.c
36331 +++ b/drivers/block/drbd/drbd_nl.c
36332 @@ -3440,7 +3440,7 @@ out:
36333
36334 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36335 {
36336 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36337 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36338 struct sk_buff *msg;
36339 struct drbd_genlmsghdr *d_out;
36340 unsigned seq;
36341 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36342 return;
36343 }
36344
36345 - seq = atomic_inc_return(&drbd_genl_seq);
36346 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36347 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36348 if (!msg)
36349 goto failed;
36350 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36351 index cc29cd3..d4b058b 100644
36352 --- a/drivers/block/drbd/drbd_receiver.c
36353 +++ b/drivers/block/drbd/drbd_receiver.c
36354 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36355 {
36356 int err;
36357
36358 - atomic_set(&mdev->packet_seq, 0);
36359 + atomic_set_unchecked(&mdev->packet_seq, 0);
36360 mdev->peer_seq = 0;
36361
36362 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36363 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36364 do {
36365 next_epoch = NULL;
36366
36367 - epoch_size = atomic_read(&epoch->epoch_size);
36368 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36369
36370 switch (ev & ~EV_CLEANUP) {
36371 case EV_PUT:
36372 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36373 rv = FE_DESTROYED;
36374 } else {
36375 epoch->flags = 0;
36376 - atomic_set(&epoch->epoch_size, 0);
36377 + atomic_set_unchecked(&epoch->epoch_size, 0);
36378 /* atomic_set(&epoch->active, 0); is already zero */
36379 if (rv == FE_STILL_LIVE)
36380 rv = FE_RECYCLED;
36381 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36382 conn_wait_active_ee_empty(tconn);
36383 drbd_flush(tconn);
36384
36385 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36386 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36387 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36388 if (epoch)
36389 break;
36390 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36391 }
36392
36393 epoch->flags = 0;
36394 - atomic_set(&epoch->epoch_size, 0);
36395 + atomic_set_unchecked(&epoch->epoch_size, 0);
36396 atomic_set(&epoch->active, 0);
36397
36398 spin_lock(&tconn->epoch_lock);
36399 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36400 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36401 list_add(&epoch->list, &tconn->current_epoch->list);
36402 tconn->current_epoch = epoch;
36403 tconn->epochs++;
36404 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36405
36406 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36407 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36408 - atomic_inc(&tconn->current_epoch->epoch_size);
36409 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36410 err2 = drbd_drain_block(mdev, pi->size);
36411 if (!err)
36412 err = err2;
36413 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36414
36415 spin_lock(&tconn->epoch_lock);
36416 peer_req->epoch = tconn->current_epoch;
36417 - atomic_inc(&peer_req->epoch->epoch_size);
36418 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36419 atomic_inc(&peer_req->epoch->active);
36420 spin_unlock(&tconn->epoch_lock);
36421
36422 @@ -4347,7 +4347,7 @@ struct data_cmd {
36423 int expect_payload;
36424 size_t pkt_size;
36425 int (*fn)(struct drbd_tconn *, struct packet_info *);
36426 -};
36427 +} __do_const;
36428
36429 static struct data_cmd drbd_cmd_handler[] = {
36430 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36431 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36432 if (!list_empty(&tconn->current_epoch->list))
36433 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36434 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36435 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36436 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36437 tconn->send.seen_any_write_yet = false;
36438
36439 conn_info(tconn, "Connection closed\n");
36440 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36441 struct asender_cmd {
36442 size_t pkt_size;
36443 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36444 -};
36445 +} __do_const;
36446
36447 static struct asender_cmd asender_tbl[] = {
36448 [P_PING] = { 0, got_Ping },
36449 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36450 index 40e7155..df5c79a 100644
36451 --- a/drivers/block/loop.c
36452 +++ b/drivers/block/loop.c
36453 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36454
36455 file_start_write(file);
36456 set_fs(get_ds());
36457 - bw = file->f_op->write(file, buf, len, &pos);
36458 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36459 set_fs(old_fs);
36460 file_end_write(file);
36461 if (likely(bw == len))
36462 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36463 index f5d0ea1..c62380a 100644
36464 --- a/drivers/block/pktcdvd.c
36465 +++ b/drivers/block/pktcdvd.c
36466 @@ -84,7 +84,7 @@
36467 #define MAX_SPEED 0xffff
36468
36469 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36470 - ~(sector_t)((pd)->settings.size - 1))
36471 + ~(sector_t)((pd)->settings.size - 1UL))
36472
36473 static DEFINE_MUTEX(pktcdvd_mutex);
36474 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36475 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36476 index 7332889..9ece19e 100644
36477 --- a/drivers/bus/arm-cci.c
36478 +++ b/drivers/bus/arm-cci.c
36479 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36480
36481 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36482
36483 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36484 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36485 if (!ports)
36486 return -ENOMEM;
36487
36488 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36489 index 8a3aff7..d7538c2 100644
36490 --- a/drivers/cdrom/cdrom.c
36491 +++ b/drivers/cdrom/cdrom.c
36492 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36493 ENSURE(reset, CDC_RESET);
36494 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36495 cdi->mc_flags = 0;
36496 - cdo->n_minors = 0;
36497 cdi->options = CDO_USE_FFLAGS;
36498
36499 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36500 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36501 else
36502 cdi->cdda_method = CDDA_OLD;
36503
36504 - if (!cdo->generic_packet)
36505 - cdo->generic_packet = cdrom_dummy_generic_packet;
36506 + if (!cdo->generic_packet) {
36507 + pax_open_kernel();
36508 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36509 + pax_close_kernel();
36510 + }
36511
36512 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36513 mutex_lock(&cdrom_mutex);
36514 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36515 if (cdi->exit)
36516 cdi->exit(cdi);
36517
36518 - cdi->ops->n_minors--;
36519 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36520 }
36521
36522 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36523 */
36524 nr = nframes;
36525 do {
36526 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36527 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36528 if (cgc.buffer)
36529 break;
36530
36531 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36532 struct cdrom_device_info *cdi;
36533 int ret;
36534
36535 - ret = scnprintf(info + *pos, max_size - *pos, header);
36536 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36537 if (!ret)
36538 return 1;
36539
36540 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36541 index 5980cb9..6d7bd7e 100644
36542 --- a/drivers/cdrom/gdrom.c
36543 +++ b/drivers/cdrom/gdrom.c
36544 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36545 .audio_ioctl = gdrom_audio_ioctl,
36546 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36547 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36548 - .n_minors = 1,
36549 };
36550
36551 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36552 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36553 index 1421997..33f5d6d 100644
36554 --- a/drivers/char/Kconfig
36555 +++ b/drivers/char/Kconfig
36556 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36557
36558 config DEVKMEM
36559 bool "/dev/kmem virtual device support"
36560 - default y
36561 + default n
36562 + depends on !GRKERNSEC_KMEM
36563 help
36564 Say Y here if you want to support the /dev/kmem device. The
36565 /dev/kmem device is rarely used, but can be used for certain
36566 @@ -570,6 +571,7 @@ config DEVPORT
36567 bool
36568 depends on !M68K
36569 depends on ISA || PCI
36570 + depends on !GRKERNSEC_KMEM
36571 default y
36572
36573 source "drivers/s390/char/Kconfig"
36574 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36575 index a48e05b..6bac831 100644
36576 --- a/drivers/char/agp/compat_ioctl.c
36577 +++ b/drivers/char/agp/compat_ioctl.c
36578 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36579 return -ENOMEM;
36580 }
36581
36582 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36583 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36584 sizeof(*usegment) * ureserve.seg_count)) {
36585 kfree(usegment);
36586 kfree(ksegment);
36587 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36588 index 1b19239..b87b143 100644
36589 --- a/drivers/char/agp/frontend.c
36590 +++ b/drivers/char/agp/frontend.c
36591 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36592 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36593 return -EFAULT;
36594
36595 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36596 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36597 return -EFAULT;
36598
36599 client = agp_find_client_by_pid(reserve.pid);
36600 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36601 if (segment == NULL)
36602 return -ENOMEM;
36603
36604 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36605 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36606 sizeof(struct agp_segment) * reserve.seg_count)) {
36607 kfree(segment);
36608 return -EFAULT;
36609 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36610 index 4f94375..413694e 100644
36611 --- a/drivers/char/genrtc.c
36612 +++ b/drivers/char/genrtc.c
36613 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36614 switch (cmd) {
36615
36616 case RTC_PLL_GET:
36617 + memset(&pll, 0, sizeof(pll));
36618 if (get_rtc_pll(&pll))
36619 return -EINVAL;
36620 else
36621 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36622 index 448ce5e..3a76625 100644
36623 --- a/drivers/char/hpet.c
36624 +++ b/drivers/char/hpet.c
36625 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36626 }
36627
36628 static int
36629 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36630 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36631 struct hpet_info *info)
36632 {
36633 struct hpet_timer __iomem *timer;
36634 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36635 index 86fe45c..c0ea948 100644
36636 --- a/drivers/char/hw_random/intel-rng.c
36637 +++ b/drivers/char/hw_random/intel-rng.c
36638 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36639
36640 if (no_fwh_detect)
36641 return -ENODEV;
36642 - printk(warning);
36643 + printk("%s", warning);
36644 return -EBUSY;
36645 }
36646
36647 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36648 index 4445fa1..7c6de37 100644
36649 --- a/drivers/char/ipmi/ipmi_msghandler.c
36650 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36651 @@ -420,7 +420,7 @@ struct ipmi_smi {
36652 struct proc_dir_entry *proc_dir;
36653 char proc_dir_name[10];
36654
36655 - atomic_t stats[IPMI_NUM_STATS];
36656 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36657
36658 /*
36659 * run_to_completion duplicate of smb_info, smi_info
36660 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36661
36662
36663 #define ipmi_inc_stat(intf, stat) \
36664 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36665 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36666 #define ipmi_get_stat(intf, stat) \
36667 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36668 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36669
36670 static int is_lan_addr(struct ipmi_addr *addr)
36671 {
36672 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36673 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36674 init_waitqueue_head(&intf->waitq);
36675 for (i = 0; i < IPMI_NUM_STATS; i++)
36676 - atomic_set(&intf->stats[i], 0);
36677 + atomic_set_unchecked(&intf->stats[i], 0);
36678
36679 intf->proc_dir = NULL;
36680
36681 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36682 index af4b23f..79806fc 100644
36683 --- a/drivers/char/ipmi/ipmi_si_intf.c
36684 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36685 @@ -275,7 +275,7 @@ struct smi_info {
36686 unsigned char slave_addr;
36687
36688 /* Counters and things for the proc filesystem. */
36689 - atomic_t stats[SI_NUM_STATS];
36690 + atomic_unchecked_t stats[SI_NUM_STATS];
36691
36692 struct task_struct *thread;
36693
36694 @@ -284,9 +284,9 @@ struct smi_info {
36695 };
36696
36697 #define smi_inc_stat(smi, stat) \
36698 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36699 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36700 #define smi_get_stat(smi, stat) \
36701 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36702 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36703
36704 #define SI_MAX_PARMS 4
36705
36706 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36707 atomic_set(&new_smi->req_events, 0);
36708 new_smi->run_to_completion = 0;
36709 for (i = 0; i < SI_NUM_STATS; i++)
36710 - atomic_set(&new_smi->stats[i], 0);
36711 + atomic_set_unchecked(&new_smi->stats[i], 0);
36712
36713 new_smi->interrupt_disabled = 1;
36714 atomic_set(&new_smi->stop_operation, 0);
36715 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36716 index f895a8c..2bc9147 100644
36717 --- a/drivers/char/mem.c
36718 +++ b/drivers/char/mem.c
36719 @@ -18,6 +18,7 @@
36720 #include <linux/raw.h>
36721 #include <linux/tty.h>
36722 #include <linux/capability.h>
36723 +#include <linux/security.h>
36724 #include <linux/ptrace.h>
36725 #include <linux/device.h>
36726 #include <linux/highmem.h>
36727 @@ -37,6 +38,10 @@
36728
36729 #define DEVPORT_MINOR 4
36730
36731 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36732 +extern const struct file_operations grsec_fops;
36733 +#endif
36734 +
36735 static inline unsigned long size_inside_page(unsigned long start,
36736 unsigned long size)
36737 {
36738 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36739
36740 while (cursor < to) {
36741 if (!devmem_is_allowed(pfn)) {
36742 +#ifdef CONFIG_GRKERNSEC_KMEM
36743 + gr_handle_mem_readwrite(from, to);
36744 +#else
36745 printk(KERN_INFO
36746 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36747 current->comm, from, to);
36748 +#endif
36749 return 0;
36750 }
36751 cursor += PAGE_SIZE;
36752 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36753 }
36754 return 1;
36755 }
36756 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36757 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36758 +{
36759 + return 0;
36760 +}
36761 #else
36762 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36763 {
36764 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36765
36766 while (count > 0) {
36767 unsigned long remaining;
36768 + char *temp;
36769
36770 sz = size_inside_page(p, count);
36771
36772 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36773 if (!ptr)
36774 return -EFAULT;
36775
36776 - remaining = copy_to_user(buf, ptr, sz);
36777 +#ifdef CONFIG_PAX_USERCOPY
36778 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36779 + if (!temp) {
36780 + unxlate_dev_mem_ptr(p, ptr);
36781 + return -ENOMEM;
36782 + }
36783 + memcpy(temp, ptr, sz);
36784 +#else
36785 + temp = ptr;
36786 +#endif
36787 +
36788 + remaining = copy_to_user(buf, temp, sz);
36789 +
36790 +#ifdef CONFIG_PAX_USERCOPY
36791 + kfree(temp);
36792 +#endif
36793 +
36794 unxlate_dev_mem_ptr(p, ptr);
36795 if (remaining)
36796 return -EFAULT;
36797 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36798 size_t count, loff_t *ppos)
36799 {
36800 unsigned long p = *ppos;
36801 - ssize_t low_count, read, sz;
36802 + ssize_t low_count, read, sz, err = 0;
36803 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36804 - int err = 0;
36805
36806 read = 0;
36807 if (p < (unsigned long) high_memory) {
36808 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36809 }
36810 #endif
36811 while (low_count > 0) {
36812 + char *temp;
36813 +
36814 sz = size_inside_page(p, low_count);
36815
36816 /*
36817 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36818 */
36819 kbuf = xlate_dev_kmem_ptr((char *)p);
36820
36821 - if (copy_to_user(buf, kbuf, sz))
36822 +#ifdef CONFIG_PAX_USERCOPY
36823 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36824 + if (!temp)
36825 + return -ENOMEM;
36826 + memcpy(temp, kbuf, sz);
36827 +#else
36828 + temp = kbuf;
36829 +#endif
36830 +
36831 + err = copy_to_user(buf, temp, sz);
36832 +
36833 +#ifdef CONFIG_PAX_USERCOPY
36834 + kfree(temp);
36835 +#endif
36836 +
36837 + if (err)
36838 return -EFAULT;
36839 buf += sz;
36840 p += sz;
36841 @@ -822,6 +869,9 @@ static const struct memdev {
36842 #ifdef CONFIG_PRINTK
36843 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36844 #endif
36845 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36846 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36847 +#endif
36848 };
36849
36850 static int memory_open(struct inode *inode, struct file *filp)
36851 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36852 continue;
36853
36854 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36855 - NULL, devlist[minor].name);
36856 + NULL, "%s", devlist[minor].name);
36857 }
36858
36859 return tty_init();
36860 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36861 index 9df78e2..01ba9ae 100644
36862 --- a/drivers/char/nvram.c
36863 +++ b/drivers/char/nvram.c
36864 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36865
36866 spin_unlock_irq(&rtc_lock);
36867
36868 - if (copy_to_user(buf, contents, tmp - contents))
36869 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36870 return -EFAULT;
36871
36872 *ppos = i;
36873 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36874 index 5c5cc00..ac9edb7 100644
36875 --- a/drivers/char/pcmcia/synclink_cs.c
36876 +++ b/drivers/char/pcmcia/synclink_cs.c
36877 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36878
36879 if (debug_level >= DEBUG_LEVEL_INFO)
36880 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36881 - __FILE__, __LINE__, info->device_name, port->count);
36882 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36883
36884 - WARN_ON(!port->count);
36885 + WARN_ON(!atomic_read(&port->count));
36886
36887 if (tty_port_close_start(port, tty, filp) == 0)
36888 goto cleanup;
36889 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36890 cleanup:
36891 if (debug_level >= DEBUG_LEVEL_INFO)
36892 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36893 - tty->driver->name, port->count);
36894 + tty->driver->name, atomic_read(&port->count));
36895 }
36896
36897 /* Wait until the transmitter is empty.
36898 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36899
36900 if (debug_level >= DEBUG_LEVEL_INFO)
36901 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36902 - __FILE__, __LINE__, tty->driver->name, port->count);
36903 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36904
36905 /* If port is closing, signal caller to try again */
36906 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36907 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36908 goto cleanup;
36909 }
36910 spin_lock(&port->lock);
36911 - port->count++;
36912 + atomic_inc(&port->count);
36913 spin_unlock(&port->lock);
36914 spin_unlock_irqrestore(&info->netlock, flags);
36915
36916 - if (port->count == 1) {
36917 + if (atomic_read(&port->count) == 1) {
36918 /* 1st open on this device, init hardware */
36919 retval = startup(info, tty);
36920 if (retval < 0)
36921 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36922 unsigned short new_crctype;
36923
36924 /* return error if TTY interface open */
36925 - if (info->port.count)
36926 + if (atomic_read(&info->port.count))
36927 return -EBUSY;
36928
36929 switch (encoding)
36930 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36931
36932 /* arbitrate between network and tty opens */
36933 spin_lock_irqsave(&info->netlock, flags);
36934 - if (info->port.count != 0 || info->netcount != 0) {
36935 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36936 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36937 spin_unlock_irqrestore(&info->netlock, flags);
36938 return -EBUSY;
36939 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36940 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36941
36942 /* return error if TTY interface open */
36943 - if (info->port.count)
36944 + if (atomic_read(&info->port.count))
36945 return -EBUSY;
36946
36947 if (cmd != SIOCWANDEV)
36948 diff --git a/drivers/char/random.c b/drivers/char/random.c
36949 index 0d91fe5..f8e37b0 100644
36950 --- a/drivers/char/random.c
36951 +++ b/drivers/char/random.c
36952 @@ -272,8 +272,13 @@
36953 /*
36954 * Configuration information
36955 */
36956 +#ifdef CONFIG_GRKERNSEC_RANDNET
36957 +#define INPUT_POOL_WORDS 512
36958 +#define OUTPUT_POOL_WORDS 128
36959 +#else
36960 #define INPUT_POOL_WORDS 128
36961 #define OUTPUT_POOL_WORDS 32
36962 +#endif
36963 #define SEC_XFER_SIZE 512
36964 #define EXTRACT_SIZE 10
36965
36966 @@ -313,10 +318,17 @@ static struct poolinfo {
36967 int poolwords;
36968 int tap1, tap2, tap3, tap4, tap5;
36969 } poolinfo_table[] = {
36970 +#ifdef CONFIG_GRKERNSEC_RANDNET
36971 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36972 + { 512, 411, 308, 208, 104, 1 },
36973 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36974 + { 128, 103, 76, 51, 25, 1 },
36975 +#else
36976 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36977 { 128, 103, 76, 51, 25, 1 },
36978 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36979 { 32, 26, 20, 14, 7, 1 },
36980 +#endif
36981 #if 0
36982 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36983 { 2048, 1638, 1231, 819, 411, 1 },
36984 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36985 input_rotate += i ? 7 : 14;
36986 }
36987
36988 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36989 - ACCESS_ONCE(r->add_ptr) = i;
36990 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36991 + ACCESS_ONCE_RW(r->add_ptr) = i;
36992 smp_wmb();
36993
36994 if (out)
36995 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36996
36997 extract_buf(r, tmp);
36998 i = min_t(int, nbytes, EXTRACT_SIZE);
36999 - if (copy_to_user(buf, tmp, i)) {
37000 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
37001 ret = -EFAULT;
37002 break;
37003 }
37004 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
37005 #include <linux/sysctl.h>
37006
37007 static int min_read_thresh = 8, min_write_thresh;
37008 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
37009 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
37010 static int max_write_thresh = INPUT_POOL_WORDS * 32;
37011 static char sysctl_bootid[16];
37012
37013 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
37014 static int proc_do_uuid(struct ctl_table *table, int write,
37015 void __user *buffer, size_t *lenp, loff_t *ppos)
37016 {
37017 - struct ctl_table fake_table;
37018 + ctl_table_no_const fake_table;
37019 unsigned char buf[64], tmp_uuid[16], *uuid;
37020
37021 uuid = table->data;
37022 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37023 index bf2349db..5456d53 100644
37024 --- a/drivers/char/sonypi.c
37025 +++ b/drivers/char/sonypi.c
37026 @@ -54,6 +54,7 @@
37027
37028 #include <asm/uaccess.h>
37029 #include <asm/io.h>
37030 +#include <asm/local.h>
37031
37032 #include <linux/sonypi.h>
37033
37034 @@ -490,7 +491,7 @@ static struct sonypi_device {
37035 spinlock_t fifo_lock;
37036 wait_queue_head_t fifo_proc_list;
37037 struct fasync_struct *fifo_async;
37038 - int open_count;
37039 + local_t open_count;
37040 int model;
37041 struct input_dev *input_jog_dev;
37042 struct input_dev *input_key_dev;
37043 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37044 static int sonypi_misc_release(struct inode *inode, struct file *file)
37045 {
37046 mutex_lock(&sonypi_device.lock);
37047 - sonypi_device.open_count--;
37048 + local_dec(&sonypi_device.open_count);
37049 mutex_unlock(&sonypi_device.lock);
37050 return 0;
37051 }
37052 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37053 {
37054 mutex_lock(&sonypi_device.lock);
37055 /* Flush input queue on first open */
37056 - if (!sonypi_device.open_count)
37057 + if (!local_read(&sonypi_device.open_count))
37058 kfifo_reset(&sonypi_device.fifo);
37059 - sonypi_device.open_count++;
37060 + local_inc(&sonypi_device.open_count);
37061 mutex_unlock(&sonypi_device.lock);
37062
37063 return 0;
37064 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37065 index 64420b3..5c40b56 100644
37066 --- a/drivers/char/tpm/tpm_acpi.c
37067 +++ b/drivers/char/tpm/tpm_acpi.c
37068 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37069 virt = acpi_os_map_memory(start, len);
37070 if (!virt) {
37071 kfree(log->bios_event_log);
37072 + log->bios_event_log = NULL;
37073 printk("%s: ERROR - Unable to map memory\n", __func__);
37074 return -EIO;
37075 }
37076
37077 - memcpy_fromio(log->bios_event_log, virt, len);
37078 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37079
37080 acpi_os_unmap_memory(virt, len);
37081 return 0;
37082 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37083 index 84ddc55..1d32f1e 100644
37084 --- a/drivers/char/tpm/tpm_eventlog.c
37085 +++ b/drivers/char/tpm/tpm_eventlog.c
37086 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37087 event = addr;
37088
37089 if ((event->event_type == 0 && event->event_size == 0) ||
37090 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37091 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37092 return NULL;
37093
37094 return addr;
37095 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37096 return NULL;
37097
37098 if ((event->event_type == 0 && event->event_size == 0) ||
37099 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37100 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37101 return NULL;
37102
37103 (*pos)++;
37104 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37105 int i;
37106
37107 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37108 - seq_putc(m, data[i]);
37109 + if (!seq_putc(m, data[i]))
37110 + return -EFAULT;
37111
37112 return 0;
37113 }
37114 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37115 index fc45567..fa2a590 100644
37116 --- a/drivers/char/virtio_console.c
37117 +++ b/drivers/char/virtio_console.c
37118 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37119 if (to_user) {
37120 ssize_t ret;
37121
37122 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37123 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37124 if (ret)
37125 return -EFAULT;
37126 } else {
37127 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37128 if (!port_has_data(port) && !port->host_connected)
37129 return 0;
37130
37131 - return fill_readbuf(port, ubuf, count, true);
37132 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37133 }
37134
37135 static int wait_port_writable(struct port *port, bool nonblock)
37136 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37137 index a33f46f..a720eed 100644
37138 --- a/drivers/clk/clk-composite.c
37139 +++ b/drivers/clk/clk-composite.c
37140 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37141 struct clk *clk;
37142 struct clk_init_data init;
37143 struct clk_composite *composite;
37144 - struct clk_ops *clk_composite_ops;
37145 + clk_ops_no_const *clk_composite_ops;
37146
37147 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37148 if (!composite) {
37149 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37150 index 5bb848c..f1d4fc9 100644
37151 --- a/drivers/clk/socfpga/clk.c
37152 +++ b/drivers/clk/socfpga/clk.c
37153 @@ -22,6 +22,7 @@
37154 #include <linux/clk-provider.h>
37155 #include <linux/io.h>
37156 #include <linux/of.h>
37157 +#include <asm/pgtable.h>
37158
37159 /* Clock Manager offsets */
37160 #define CLKMGR_CTRL 0x0
37161 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37162 streq(clk_name, "periph_pll") ||
37163 streq(clk_name, "sdram_pll")) {
37164 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37165 - clk_pll_ops.enable = clk_gate_ops.enable;
37166 - clk_pll_ops.disable = clk_gate_ops.disable;
37167 + pax_open_kernel();
37168 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37169 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37170 + pax_close_kernel();
37171 }
37172
37173 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37174 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37175 return parent_rate / div;
37176 }
37177
37178 -static struct clk_ops gateclk_ops = {
37179 +static clk_ops_no_const gateclk_ops __read_only = {
37180 .recalc_rate = socfpga_clk_recalc_rate,
37181 .get_parent = socfpga_clk_get_parent,
37182 .set_parent = socfpga_clk_set_parent,
37183 diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
37184 index 08ae128..c73fc2b 100644
37185 --- a/drivers/connector/cn_proc.c
37186 +++ b/drivers/connector/cn_proc.c
37187 @@ -65,6 +65,7 @@ void proc_fork_connector(struct task_struct *task)
37188
37189 msg = (struct cn_msg *)buffer;
37190 ev = (struct proc_event *)msg->data;
37191 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37192 get_seq(&msg->seq, &ev->cpu);
37193 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37194 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37195 @@ -80,6 +81,7 @@ void proc_fork_connector(struct task_struct *task)
37196 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37197 msg->ack = 0; /* not used */
37198 msg->len = sizeof(*ev);
37199 + msg->flags = 0; /* not used */
37200 /* If cn_netlink_send() failed, the data is not sent */
37201 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37202 }
37203 @@ -96,6 +98,7 @@ void proc_exec_connector(struct task_struct *task)
37204
37205 msg = (struct cn_msg *)buffer;
37206 ev = (struct proc_event *)msg->data;
37207 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37208 get_seq(&msg->seq, &ev->cpu);
37209 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37210 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37211 @@ -106,6 +109,7 @@ void proc_exec_connector(struct task_struct *task)
37212 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37213 msg->ack = 0; /* not used */
37214 msg->len = sizeof(*ev);
37215 + msg->flags = 0; /* not used */
37216 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37217 }
37218
37219 @@ -122,6 +126,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
37220
37221 msg = (struct cn_msg *)buffer;
37222 ev = (struct proc_event *)msg->data;
37223 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37224 ev->what = which_id;
37225 ev->event_data.id.process_pid = task->pid;
37226 ev->event_data.id.process_tgid = task->tgid;
37227 @@ -145,6 +150,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
37228 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37229 msg->ack = 0; /* not used */
37230 msg->len = sizeof(*ev);
37231 + msg->flags = 0; /* not used */
37232 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37233 }
37234
37235 @@ -160,6 +166,7 @@ void proc_sid_connector(struct task_struct *task)
37236
37237 msg = (struct cn_msg *)buffer;
37238 ev = (struct proc_event *)msg->data;
37239 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37240 get_seq(&msg->seq, &ev->cpu);
37241 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37242 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37243 @@ -170,6 +177,7 @@ void proc_sid_connector(struct task_struct *task)
37244 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37245 msg->ack = 0; /* not used */
37246 msg->len = sizeof(*ev);
37247 + msg->flags = 0; /* not used */
37248 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37249 }
37250
37251 @@ -185,6 +193,7 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
37252
37253 msg = (struct cn_msg *)buffer;
37254 ev = (struct proc_event *)msg->data;
37255 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37256 get_seq(&msg->seq, &ev->cpu);
37257 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37258 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37259 @@ -203,6 +212,7 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
37260 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37261 msg->ack = 0; /* not used */
37262 msg->len = sizeof(*ev);
37263 + msg->flags = 0; /* not used */
37264 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37265 }
37266
37267 @@ -218,6 +228,7 @@ void proc_comm_connector(struct task_struct *task)
37268
37269 msg = (struct cn_msg *)buffer;
37270 ev = (struct proc_event *)msg->data;
37271 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37272 get_seq(&msg->seq, &ev->cpu);
37273 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37274 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37275 @@ -229,6 +240,7 @@ void proc_comm_connector(struct task_struct *task)
37276 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37277 msg->ack = 0; /* not used */
37278 msg->len = sizeof(*ev);
37279 + msg->flags = 0; /* not used */
37280 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37281 }
37282
37283 @@ -244,6 +256,7 @@ void proc_coredump_connector(struct task_struct *task)
37284
37285 msg = (struct cn_msg *)buffer;
37286 ev = (struct proc_event *)msg->data;
37287 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37288 get_seq(&msg->seq, &ev->cpu);
37289 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37290 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37291 @@ -254,6 +267,7 @@ void proc_coredump_connector(struct task_struct *task)
37292 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37293 msg->ack = 0; /* not used */
37294 msg->len = sizeof(*ev);
37295 + msg->flags = 0; /* not used */
37296 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37297 }
37298
37299 @@ -269,6 +283,7 @@ void proc_exit_connector(struct task_struct *task)
37300
37301 msg = (struct cn_msg *)buffer;
37302 ev = (struct proc_event *)msg->data;
37303 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37304 get_seq(&msg->seq, &ev->cpu);
37305 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37306 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37307 @@ -281,6 +296,7 @@ void proc_exit_connector(struct task_struct *task)
37308 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37309 msg->ack = 0; /* not used */
37310 msg->len = sizeof(*ev);
37311 + msg->flags = 0; /* not used */
37312 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37313 }
37314
37315 @@ -304,6 +320,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
37316
37317 msg = (struct cn_msg *)buffer;
37318 ev = (struct proc_event *)msg->data;
37319 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37320 msg->seq = rcvd_seq;
37321 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37322 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37323 @@ -313,6 +330,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
37324 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37325 msg->ack = rcvd_ack + 1;
37326 msg->len = sizeof(*ev);
37327 + msg->flags = 0; /* not used */
37328 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37329 }
37330
37331 diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
37332 index 6ecfa75..0daa11e 100644
37333 --- a/drivers/connector/connector.c
37334 +++ b/drivers/connector/connector.c
37335 @@ -157,17 +157,18 @@ static int cn_call_callback(struct sk_buff *skb)
37336 static void cn_rx_skb(struct sk_buff *__skb)
37337 {
37338 struct nlmsghdr *nlh;
37339 - int err;
37340 struct sk_buff *skb;
37341 + int len, err;
37342
37343 skb = skb_get(__skb);
37344
37345 if (skb->len >= NLMSG_HDRLEN) {
37346 nlh = nlmsg_hdr(skb);
37347 + len = nlmsg_len(nlh);
37348
37349 - if (nlh->nlmsg_len < sizeof(struct cn_msg) ||
37350 + if (len < (int)sizeof(struct cn_msg) ||
37351 skb->len < nlh->nlmsg_len ||
37352 - nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {
37353 + len > CONNECTOR_MAX_MSG_SIZE) {
37354 kfree_skb(skb);
37355 return;
37356 }
37357 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37358 index 3926402..37b580d 100644
37359 --- a/drivers/cpufreq/acpi-cpufreq.c
37360 +++ b/drivers/cpufreq/acpi-cpufreq.c
37361 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37362 return sprintf(buf, "%u\n", boost_enabled);
37363 }
37364
37365 -static struct global_attr global_boost = __ATTR(boost, 0644,
37366 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37367 show_global_boost,
37368 store_global_boost);
37369
37370 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37371 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37372 per_cpu(acfreq_data, cpu) = data;
37373
37374 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37375 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37376 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37377 + pax_open_kernel();
37378 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37379 + pax_close_kernel();
37380 + }
37381
37382 result = acpi_processor_register_performance(data->acpi_data, cpu);
37383 if (result)
37384 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37385 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37386 break;
37387 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37388 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37389 + pax_open_kernel();
37390 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37391 + pax_close_kernel();
37392 policy->cur = get_cur_freq_on_cpu(cpu);
37393 break;
37394 default:
37395 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37396 acpi_processor_notify_smm(THIS_MODULE);
37397
37398 /* Check for APERF/MPERF support in hardware */
37399 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37400 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37401 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37402 + pax_open_kernel();
37403 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37404 + pax_close_kernel();
37405 + }
37406
37407 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37408 for (i = 0; i < perf->state_count; i++)
37409 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37410 index f0a5e2b..0a7ee46 100644
37411 --- a/drivers/cpufreq/cpufreq.c
37412 +++ b/drivers/cpufreq/cpufreq.c
37413 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37414 return NOTIFY_OK;
37415 }
37416
37417 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37418 +static struct notifier_block cpufreq_cpu_notifier = {
37419 .notifier_call = cpufreq_cpu_callback,
37420 };
37421
37422 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37423
37424 pr_debug("trying to register driver %s\n", driver_data->name);
37425
37426 - if (driver_data->setpolicy)
37427 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37428 + if (driver_data->setpolicy) {
37429 + pax_open_kernel();
37430 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37431 + pax_close_kernel();
37432 + }
37433
37434 write_lock_irqsave(&cpufreq_driver_lock, flags);
37435 if (cpufreq_driver) {
37436 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37437 index e59afaa..a53a3ff 100644
37438 --- a/drivers/cpufreq/cpufreq_governor.c
37439 +++ b/drivers/cpufreq/cpufreq_governor.c
37440 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37441 struct dbs_data *dbs_data;
37442 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37443 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37444 - struct od_ops *od_ops = NULL;
37445 + const struct od_ops *od_ops = NULL;
37446 struct od_dbs_tuners *od_tuners = NULL;
37447 struct cs_dbs_tuners *cs_tuners = NULL;
37448 struct cpu_dbs_common_info *cpu_cdbs;
37449 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37450
37451 if ((cdata->governor == GOV_CONSERVATIVE) &&
37452 (!policy->governor->initialized)) {
37453 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37454 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37455
37456 cpufreq_register_notifier(cs_ops->notifier_block,
37457 CPUFREQ_TRANSITION_NOTIFIER);
37458 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37459
37460 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37461 (policy->governor->initialized == 1)) {
37462 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37463 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37464
37465 cpufreq_unregister_notifier(cs_ops->notifier_block,
37466 CPUFREQ_TRANSITION_NOTIFIER);
37467 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37468 index d5f12b4..eb30af1 100644
37469 --- a/drivers/cpufreq/cpufreq_governor.h
37470 +++ b/drivers/cpufreq/cpufreq_governor.h
37471 @@ -204,7 +204,7 @@ struct common_dbs_data {
37472 void (*exit)(struct dbs_data *dbs_data);
37473
37474 /* Governor specific ops, see below */
37475 - void *gov_ops;
37476 + const void *gov_ops;
37477 };
37478
37479 /* Governer Per policy data */
37480 @@ -224,7 +224,7 @@ struct od_ops {
37481 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37482 unsigned int freq_next, unsigned int relation);
37483 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37484 -};
37485 +} __no_const;
37486
37487 struct cs_ops {
37488 struct notifier_block *notifier_block;
37489 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37490 index c087347..989aa2e 100644
37491 --- a/drivers/cpufreq/cpufreq_ondemand.c
37492 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37493 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37494
37495 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37496
37497 -static struct od_ops od_ops = {
37498 +static struct od_ops od_ops __read_only = {
37499 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37500 .powersave_bias_target = generic_powersave_bias_target,
37501 .freq_increase = dbs_freq_increase,
37502 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37503 (struct cpufreq_policy *, unsigned int, unsigned int),
37504 unsigned int powersave_bias)
37505 {
37506 - od_ops.powersave_bias_target = f;
37507 + pax_open_kernel();
37508 + *(void **)&od_ops.powersave_bias_target = f;
37509 + pax_close_kernel();
37510 od_set_powersave_bias(powersave_bias);
37511 }
37512 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37513
37514 void od_unregister_powersave_bias_handler(void)
37515 {
37516 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37517 + pax_open_kernel();
37518 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37519 + pax_close_kernel();
37520 od_set_powersave_bias(0);
37521 }
37522 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37523 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37524 index d37568c..fbb19a1 100644
37525 --- a/drivers/cpufreq/cpufreq_stats.c
37526 +++ b/drivers/cpufreq/cpufreq_stats.c
37527 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37528 }
37529
37530 /* priority=1 so this will get called before cpufreq_remove_dev */
37531 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37532 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37533 .notifier_call = cpufreq_stat_cpu_callback,
37534 .priority = 1,
37535 };
37536 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37537 index 9ee7817..17b658e 100644
37538 --- a/drivers/cpufreq/p4-clockmod.c
37539 +++ b/drivers/cpufreq/p4-clockmod.c
37540 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37541 case 0x0F: /* Core Duo */
37542 case 0x16: /* Celeron Core */
37543 case 0x1C: /* Atom */
37544 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37545 + pax_open_kernel();
37546 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37547 + pax_close_kernel();
37548 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37549 case 0x0D: /* Pentium M (Dothan) */
37550 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37551 + pax_open_kernel();
37552 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37553 + pax_close_kernel();
37554 /* fall through */
37555 case 0x09: /* Pentium M (Banias) */
37556 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37557 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37558
37559 /* on P-4s, the TSC runs with constant frequency independent whether
37560 * throttling is active or not. */
37561 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37562 + pax_open_kernel();
37563 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37564 + pax_close_kernel();
37565
37566 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37567 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37568 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37569 index 880ee29..2445bc6 100644
37570 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37571 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37572 @@ -18,14 +18,12 @@
37573 #include <asm/head.h>
37574 #include <asm/timer.h>
37575
37576 -static struct cpufreq_driver *cpufreq_us3_driver;
37577 -
37578 struct us3_freq_percpu_info {
37579 struct cpufreq_frequency_table table[4];
37580 };
37581
37582 /* Indexed by cpu number. */
37583 -static struct us3_freq_percpu_info *us3_freq_table;
37584 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37585
37586 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37587 * in the Safari config register.
37588 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37589
37590 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37591 {
37592 - if (cpufreq_us3_driver)
37593 - us3_set_cpu_divider_index(policy, 0);
37594 + us3_set_cpu_divider_index(policy->cpu, 0);
37595
37596 return 0;
37597 }
37598
37599 +static int __init us3_freq_init(void);
37600 +static void __exit us3_freq_exit(void);
37601 +
37602 +static struct cpufreq_driver cpufreq_us3_driver = {
37603 + .init = us3_freq_cpu_init,
37604 + .verify = us3_freq_verify,
37605 + .target = us3_freq_target,
37606 + .get = us3_freq_get,
37607 + .exit = us3_freq_cpu_exit,
37608 + .owner = THIS_MODULE,
37609 + .name = "UltraSPARC-III",
37610 +
37611 +};
37612 +
37613 static int __init us3_freq_init(void)
37614 {
37615 unsigned long manuf, impl, ver;
37616 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37617 (impl == CHEETAH_IMPL ||
37618 impl == CHEETAH_PLUS_IMPL ||
37619 impl == JAGUAR_IMPL ||
37620 - impl == PANTHER_IMPL)) {
37621 - struct cpufreq_driver *driver;
37622 -
37623 - ret = -ENOMEM;
37624 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37625 - if (!driver)
37626 - goto err_out;
37627 -
37628 - us3_freq_table = kzalloc(
37629 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37630 - GFP_KERNEL);
37631 - if (!us3_freq_table)
37632 - goto err_out;
37633 -
37634 - driver->init = us3_freq_cpu_init;
37635 - driver->verify = us3_freq_verify;
37636 - driver->target = us3_freq_target;
37637 - driver->get = us3_freq_get;
37638 - driver->exit = us3_freq_cpu_exit;
37639 - driver->owner = THIS_MODULE,
37640 - strcpy(driver->name, "UltraSPARC-III");
37641 -
37642 - cpufreq_us3_driver = driver;
37643 - ret = cpufreq_register_driver(driver);
37644 - if (ret)
37645 - goto err_out;
37646 -
37647 - return 0;
37648 -
37649 -err_out:
37650 - if (driver) {
37651 - kfree(driver);
37652 - cpufreq_us3_driver = NULL;
37653 - }
37654 - kfree(us3_freq_table);
37655 - us3_freq_table = NULL;
37656 - return ret;
37657 - }
37658 + impl == PANTHER_IMPL))
37659 + return cpufreq_register_driver(&cpufreq_us3_driver);
37660
37661 return -ENODEV;
37662 }
37663
37664 static void __exit us3_freq_exit(void)
37665 {
37666 - if (cpufreq_us3_driver) {
37667 - cpufreq_unregister_driver(cpufreq_us3_driver);
37668 - kfree(cpufreq_us3_driver);
37669 - cpufreq_us3_driver = NULL;
37670 - kfree(us3_freq_table);
37671 - us3_freq_table = NULL;
37672 - }
37673 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37674 }
37675
37676 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37677 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37678 index 0915e71..53376ed 100644
37679 --- a/drivers/cpufreq/speedstep-centrino.c
37680 +++ b/drivers/cpufreq/speedstep-centrino.c
37681 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37682 !cpu_has(cpu, X86_FEATURE_EST))
37683 return -ENODEV;
37684
37685 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37686 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37687 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37688 + pax_open_kernel();
37689 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37690 + pax_close_kernel();
37691 + }
37692
37693 if (policy->cpu != 0)
37694 return -ENODEV;
37695 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37696 index fdc432f..98e64e2 100644
37697 --- a/drivers/cpuidle/cpuidle.c
37698 +++ b/drivers/cpuidle/cpuidle.c
37699 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37700
37701 static void poll_idle_init(struct cpuidle_driver *drv)
37702 {
37703 - struct cpuidle_state *state = &drv->states[0];
37704 + cpuidle_state_no_const *state = &drv->states[0];
37705
37706 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37707 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37708 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37709 index ea2f8e7..70ac501 100644
37710 --- a/drivers/cpuidle/governor.c
37711 +++ b/drivers/cpuidle/governor.c
37712 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37713 mutex_lock(&cpuidle_lock);
37714 if (__cpuidle_find_governor(gov->name) == NULL) {
37715 ret = 0;
37716 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37717 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37718 if (!cpuidle_curr_governor ||
37719 cpuidle_curr_governor->rating < gov->rating)
37720 cpuidle_switch_governor(gov);
37721 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37722 new_gov = cpuidle_replace_governor(gov->rating);
37723 cpuidle_switch_governor(new_gov);
37724 }
37725 - list_del(&gov->governor_list);
37726 + pax_list_del((struct list_head *)&gov->governor_list);
37727 mutex_unlock(&cpuidle_lock);
37728 }
37729
37730 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37731 index 428754a..8bdf9cc 100644
37732 --- a/drivers/cpuidle/sysfs.c
37733 +++ b/drivers/cpuidle/sysfs.c
37734 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37735 NULL
37736 };
37737
37738 -static struct attribute_group cpuidle_attr_group = {
37739 +static attribute_group_no_const cpuidle_attr_group = {
37740 .attrs = cpuidle_default_attrs,
37741 .name = "cpuidle",
37742 };
37743 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37744 index 12fea3e..1e28f47 100644
37745 --- a/drivers/crypto/hifn_795x.c
37746 +++ b/drivers/crypto/hifn_795x.c
37747 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37748 MODULE_PARM_DESC(hifn_pll_ref,
37749 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37750
37751 -static atomic_t hifn_dev_number;
37752 +static atomic_unchecked_t hifn_dev_number;
37753
37754 #define ACRYPTO_OP_DECRYPT 0
37755 #define ACRYPTO_OP_ENCRYPT 1
37756 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37757 goto err_out_disable_pci_device;
37758
37759 snprintf(name, sizeof(name), "hifn%d",
37760 - atomic_inc_return(&hifn_dev_number)-1);
37761 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37762
37763 err = pci_request_regions(pdev, name);
37764 if (err)
37765 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37766 index e94e619..f7e249c 100644
37767 --- a/drivers/devfreq/devfreq.c
37768 +++ b/drivers/devfreq/devfreq.c
37769 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37770 goto err_out;
37771 }
37772
37773 - list_add(&governor->node, &devfreq_governor_list);
37774 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37775
37776 list_for_each_entry(devfreq, &devfreq_list, node) {
37777 int ret = 0;
37778 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37779 }
37780 }
37781
37782 - list_del(&governor->node);
37783 + pax_list_del((struct list_head *)&governor->node);
37784 err_out:
37785 mutex_unlock(&devfreq_list_lock);
37786
37787 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37788 index 5039fbc..841169f 100644
37789 --- a/drivers/dma/sh/shdma.c
37790 +++ b/drivers/dma/sh/shdma.c
37791 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37792 return ret;
37793 }
37794
37795 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37796 +static struct notifier_block sh_dmae_nmi_notifier = {
37797 .notifier_call = sh_dmae_nmi_handler,
37798
37799 /* Run before NMI debug handler and KGDB */
37800 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37801 index 211021d..201d47f 100644
37802 --- a/drivers/edac/edac_device.c
37803 +++ b/drivers/edac/edac_device.c
37804 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37805 */
37806 int edac_device_alloc_index(void)
37807 {
37808 - static atomic_t device_indexes = ATOMIC_INIT(0);
37809 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37810
37811 - return atomic_inc_return(&device_indexes) - 1;
37812 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37813 }
37814 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37815
37816 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37817 index e7c32c4..6397af1 100644
37818 --- a/drivers/edac/edac_mc_sysfs.c
37819 +++ b/drivers/edac/edac_mc_sysfs.c
37820 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37821 struct dev_ch_attribute {
37822 struct device_attribute attr;
37823 int channel;
37824 -};
37825 +} __do_const;
37826
37827 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37828 struct dev_ch_attribute dev_attr_legacy_##_name = \
37829 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37830 }
37831
37832 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37833 + pax_open_kernel();
37834 if (mci->get_sdram_scrub_rate) {
37835 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37836 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37837 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37838 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37839 }
37840 if (mci->set_sdram_scrub_rate) {
37841 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37842 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37843 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37844 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37845 }
37846 + pax_close_kernel();
37847 err = device_create_file(&mci->dev,
37848 &dev_attr_sdram_scrub_rate);
37849 if (err) {
37850 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37851 index dd370f9..0281629 100644
37852 --- a/drivers/edac/edac_pci.c
37853 +++ b/drivers/edac/edac_pci.c
37854 @@ -29,7 +29,7 @@
37855
37856 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37857 static LIST_HEAD(edac_pci_list);
37858 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37859 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37860
37861 /*
37862 * edac_pci_alloc_ctl_info
37863 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37864 */
37865 int edac_pci_alloc_index(void)
37866 {
37867 - return atomic_inc_return(&pci_indexes) - 1;
37868 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37869 }
37870 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37871
37872 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37873 index e8658e4..22746d6 100644
37874 --- a/drivers/edac/edac_pci_sysfs.c
37875 +++ b/drivers/edac/edac_pci_sysfs.c
37876 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37877 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37878 static int edac_pci_poll_msec = 1000; /* one second workq period */
37879
37880 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37881 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37882 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37883 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37884
37885 static struct kobject *edac_pci_top_main_kobj;
37886 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37887 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37888 void *value;
37889 ssize_t(*show) (void *, char *);
37890 ssize_t(*store) (void *, const char *, size_t);
37891 -};
37892 +} __do_const;
37893
37894 /* Set of show/store abstract level functions for PCI Parity object */
37895 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37896 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37897 edac_printk(KERN_CRIT, EDAC_PCI,
37898 "Signaled System Error on %s\n",
37899 pci_name(dev));
37900 - atomic_inc(&pci_nonparity_count);
37901 + atomic_inc_unchecked(&pci_nonparity_count);
37902 }
37903
37904 if (status & (PCI_STATUS_PARITY)) {
37905 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37906 "Master Data Parity Error on %s\n",
37907 pci_name(dev));
37908
37909 - atomic_inc(&pci_parity_count);
37910 + atomic_inc_unchecked(&pci_parity_count);
37911 }
37912
37913 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37914 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37915 "Detected Parity Error on %s\n",
37916 pci_name(dev));
37917
37918 - atomic_inc(&pci_parity_count);
37919 + atomic_inc_unchecked(&pci_parity_count);
37920 }
37921 }
37922
37923 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37924 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37925 "Signaled System Error on %s\n",
37926 pci_name(dev));
37927 - atomic_inc(&pci_nonparity_count);
37928 + atomic_inc_unchecked(&pci_nonparity_count);
37929 }
37930
37931 if (status & (PCI_STATUS_PARITY)) {
37932 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37933 "Master Data Parity Error on "
37934 "%s\n", pci_name(dev));
37935
37936 - atomic_inc(&pci_parity_count);
37937 + atomic_inc_unchecked(&pci_parity_count);
37938 }
37939
37940 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37941 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37942 "Detected Parity Error on %s\n",
37943 pci_name(dev));
37944
37945 - atomic_inc(&pci_parity_count);
37946 + atomic_inc_unchecked(&pci_parity_count);
37947 }
37948 }
37949 }
37950 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37951 if (!check_pci_errors)
37952 return;
37953
37954 - before_count = atomic_read(&pci_parity_count);
37955 + before_count = atomic_read_unchecked(&pci_parity_count);
37956
37957 /* scan all PCI devices looking for a Parity Error on devices and
37958 * bridges.
37959 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37960 /* Only if operator has selected panic on PCI Error */
37961 if (edac_pci_get_panic_on_pe()) {
37962 /* If the count is different 'after' from 'before' */
37963 - if (before_count != atomic_read(&pci_parity_count))
37964 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37965 panic("EDAC: PCI Parity Error");
37966 }
37967 }
37968 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37969 index 51b7e3a..aa8a3e8 100644
37970 --- a/drivers/edac/mce_amd.h
37971 +++ b/drivers/edac/mce_amd.h
37972 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37973 bool (*mc0_mce)(u16, u8);
37974 bool (*mc1_mce)(u16, u8);
37975 bool (*mc2_mce)(u16, u8);
37976 -};
37977 +} __no_const;
37978
37979 void amd_report_gart_errors(bool);
37980 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37981 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37982 index 57ea7f4..af06b76 100644
37983 --- a/drivers/firewire/core-card.c
37984 +++ b/drivers/firewire/core-card.c
37985 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37986 const struct fw_card_driver *driver,
37987 struct device *device)
37988 {
37989 - static atomic_t index = ATOMIC_INIT(-1);
37990 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37991
37992 - card->index = atomic_inc_return(&index);
37993 + card->index = atomic_inc_return_unchecked(&index);
37994 card->driver = driver;
37995 card->device = device;
37996 card->current_tlabel = 0;
37997 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37998
37999 void fw_core_remove_card(struct fw_card *card)
38000 {
38001 - struct fw_card_driver dummy_driver = dummy_driver_template;
38002 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
38003
38004 card->driver->update_phy_reg(card, 4,
38005 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
38006 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
38007 index de4aa40..49ab1f2 100644
38008 --- a/drivers/firewire/core-device.c
38009 +++ b/drivers/firewire/core-device.c
38010 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
38011 struct config_rom_attribute {
38012 struct device_attribute attr;
38013 u32 key;
38014 -};
38015 +} __do_const;
38016
38017 static ssize_t show_immediate(struct device *dev,
38018 struct device_attribute *dattr, char *buf)
38019 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
38020 index 28a94c7..58da63a 100644
38021 --- a/drivers/firewire/core-transaction.c
38022 +++ b/drivers/firewire/core-transaction.c
38023 @@ -38,6 +38,7 @@
38024 #include <linux/timer.h>
38025 #include <linux/types.h>
38026 #include <linux/workqueue.h>
38027 +#include <linux/sched.h>
38028
38029 #include <asm/byteorder.h>
38030
38031 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
38032 index 515a42c..5ecf3ba 100644
38033 --- a/drivers/firewire/core.h
38034 +++ b/drivers/firewire/core.h
38035 @@ -111,6 +111,7 @@ struct fw_card_driver {
38036
38037 int (*stop_iso)(struct fw_iso_context *ctx);
38038 };
38039 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
38040
38041 void fw_card_initialize(struct fw_card *card,
38042 const struct fw_card_driver *driver, struct device *device);
38043 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
38044 index 94a58a0..f5eba42 100644
38045 --- a/drivers/firmware/dmi-id.c
38046 +++ b/drivers/firmware/dmi-id.c
38047 @@ -16,7 +16,7 @@
38048 struct dmi_device_attribute{
38049 struct device_attribute dev_attr;
38050 int field;
38051 -};
38052 +} __do_const;
38053 #define to_dmi_dev_attr(_dev_attr) \
38054 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
38055
38056 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
38057 index 232fa8f..386c255 100644
38058 --- a/drivers/firmware/dmi_scan.c
38059 +++ b/drivers/firmware/dmi_scan.c
38060 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
38061 }
38062 }
38063 else {
38064 - /*
38065 - * no iounmap() for that ioremap(); it would be a no-op, but
38066 - * it's so early in setup that sucker gets confused into doing
38067 - * what it shouldn't if we actually call it.
38068 - */
38069 p = dmi_ioremap(0xF0000, 0x10000);
38070 if (p == NULL)
38071 goto error;
38072 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
38073 if (buf == NULL)
38074 return -1;
38075
38076 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
38077 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
38078
38079 iounmap(buf);
38080 return 0;
38081 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
38082 index 5145fa3..0d3babd 100644
38083 --- a/drivers/firmware/efi/efi.c
38084 +++ b/drivers/firmware/efi/efi.c
38085 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
38086 };
38087
38088 static struct efivars generic_efivars;
38089 -static struct efivar_operations generic_ops;
38090 +static efivar_operations_no_const generic_ops __read_only;
38091
38092 static int generic_ops_register(void)
38093 {
38094 - generic_ops.get_variable = efi.get_variable;
38095 - generic_ops.set_variable = efi.set_variable;
38096 - generic_ops.get_next_variable = efi.get_next_variable;
38097 - generic_ops.query_variable_store = efi_query_variable_store;
38098 + pax_open_kernel();
38099 + *(void **)&generic_ops.get_variable = efi.get_variable;
38100 + *(void **)&generic_ops.set_variable = efi.set_variable;
38101 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
38102 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
38103 + pax_close_kernel();
38104
38105 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
38106 }
38107 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
38108 index 8a7432a..28fb839 100644
38109 --- a/drivers/firmware/efi/efivars.c
38110 +++ b/drivers/firmware/efi/efivars.c
38111 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
38112 static int
38113 create_efivars_bin_attributes(void)
38114 {
38115 - struct bin_attribute *attr;
38116 + bin_attribute_no_const *attr;
38117 int error;
38118
38119 /* new_var */
38120 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
38121 index 2a90ba6..07f3733 100644
38122 --- a/drivers/firmware/google/memconsole.c
38123 +++ b/drivers/firmware/google/memconsole.c
38124 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38125 if (!found_memconsole())
38126 return -ENODEV;
38127
38128 - memconsole_bin_attr.size = memconsole_length;
38129 + pax_open_kernel();
38130 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38131 + pax_close_kernel();
38132
38133 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38134
38135 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38136 index 2729e3d..f9deca1 100644
38137 --- a/drivers/gpio/gpio-ich.c
38138 +++ b/drivers/gpio/gpio-ich.c
38139 @@ -71,7 +71,7 @@ struct ichx_desc {
38140 /* Some chipsets have quirks, let these use their own request/get */
38141 int (*request)(struct gpio_chip *chip, unsigned offset);
38142 int (*get)(struct gpio_chip *chip, unsigned offset);
38143 -};
38144 +} __do_const;
38145
38146 static struct {
38147 spinlock_t lock;
38148 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38149 index 9902732..64b62dd 100644
38150 --- a/drivers/gpio/gpio-vr41xx.c
38151 +++ b/drivers/gpio/gpio-vr41xx.c
38152 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38153 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38154 maskl, pendl, maskh, pendh);
38155
38156 - atomic_inc(&irq_err_count);
38157 + atomic_inc_unchecked(&irq_err_count);
38158
38159 return -EINVAL;
38160 }
38161 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38162 index 6a64749..0767a9f 100644
38163 --- a/drivers/gpu/drm/drm_crtc_helper.c
38164 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38165 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38166 struct drm_crtc *tmp;
38167 int crtc_mask = 1;
38168
38169 - WARN(!crtc, "checking null crtc?\n");
38170 + BUG_ON(!crtc);
38171
38172 dev = crtc->dev;
38173
38174 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38175 index 99fcd7c..13cf6c5 100644
38176 --- a/drivers/gpu/drm/drm_drv.c
38177 +++ b/drivers/gpu/drm/drm_drv.c
38178 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
38179 /**
38180 * Copy and IOCTL return string to user space
38181 */
38182 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38183 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38184 {
38185 int len;
38186
38187 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
38188 struct drm_file *file_priv = filp->private_data;
38189 struct drm_device *dev;
38190 const struct drm_ioctl_desc *ioctl = NULL;
38191 - drm_ioctl_t *func;
38192 + drm_ioctl_no_const_t func;
38193 unsigned int nr = DRM_IOCTL_NR(cmd);
38194 int retcode = -EINVAL;
38195 char stack_kdata[128];
38196 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
38197 return -ENODEV;
38198
38199 atomic_inc(&dev->ioctl_count);
38200 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38201 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38202 ++file_priv->ioctl_count;
38203
38204 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38205 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38206 index 3a24385..4e426e0 100644
38207 --- a/drivers/gpu/drm/drm_fops.c
38208 +++ b/drivers/gpu/drm/drm_fops.c
38209 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
38210 }
38211
38212 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38213 - atomic_set(&dev->counts[i], 0);
38214 + atomic_set_unchecked(&dev->counts[i], 0);
38215
38216 dev->sigdata.lock = NULL;
38217
38218 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
38219 if (drm_device_is_unplugged(dev))
38220 return -ENODEV;
38221
38222 - if (!dev->open_count++)
38223 + if (local_inc_return(&dev->open_count) == 1)
38224 need_setup = 1;
38225 mutex_lock(&dev->struct_mutex);
38226 old_imapping = inode->i_mapping;
38227 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38228 retcode = drm_open_helper(inode, filp, dev);
38229 if (retcode)
38230 goto err_undo;
38231 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38232 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38233 if (need_setup) {
38234 retcode = drm_setup(dev);
38235 if (retcode)
38236 @@ -166,7 +166,7 @@ err_undo:
38237 iput(container_of(dev->dev_mapping, struct inode, i_data));
38238 dev->dev_mapping = old_mapping;
38239 mutex_unlock(&dev->struct_mutex);
38240 - dev->open_count--;
38241 + local_dec(&dev->open_count);
38242 return retcode;
38243 }
38244 EXPORT_SYMBOL(drm_open);
38245 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38246
38247 mutex_lock(&drm_global_mutex);
38248
38249 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38250 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38251
38252 if (dev->driver->preclose)
38253 dev->driver->preclose(dev, file_priv);
38254 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38255 * Begin inline drm_release
38256 */
38257
38258 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38259 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38260 task_pid_nr(current),
38261 (long)old_encode_dev(file_priv->minor->device),
38262 - dev->open_count);
38263 + local_read(&dev->open_count));
38264
38265 /* Release any auth tokens that might point to this file_priv,
38266 (do that under the drm_global_mutex) */
38267 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38268 * End inline drm_release
38269 */
38270
38271 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38272 - if (!--dev->open_count) {
38273 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38274 + if (local_dec_and_test(&dev->open_count)) {
38275 if (atomic_read(&dev->ioctl_count)) {
38276 DRM_ERROR("Device busy: %d\n",
38277 atomic_read(&dev->ioctl_count));
38278 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38279 index f731116..629842c 100644
38280 --- a/drivers/gpu/drm/drm_global.c
38281 +++ b/drivers/gpu/drm/drm_global.c
38282 @@ -36,7 +36,7 @@
38283 struct drm_global_item {
38284 struct mutex mutex;
38285 void *object;
38286 - int refcount;
38287 + atomic_t refcount;
38288 };
38289
38290 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38291 @@ -49,7 +49,7 @@ void drm_global_init(void)
38292 struct drm_global_item *item = &glob[i];
38293 mutex_init(&item->mutex);
38294 item->object = NULL;
38295 - item->refcount = 0;
38296 + atomic_set(&item->refcount, 0);
38297 }
38298 }
38299
38300 @@ -59,7 +59,7 @@ void drm_global_release(void)
38301 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38302 struct drm_global_item *item = &glob[i];
38303 BUG_ON(item->object != NULL);
38304 - BUG_ON(item->refcount != 0);
38305 + BUG_ON(atomic_read(&item->refcount) != 0);
38306 }
38307 }
38308
38309 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38310 void *object;
38311
38312 mutex_lock(&item->mutex);
38313 - if (item->refcount == 0) {
38314 + if (atomic_read(&item->refcount) == 0) {
38315 item->object = kzalloc(ref->size, GFP_KERNEL);
38316 if (unlikely(item->object == NULL)) {
38317 ret = -ENOMEM;
38318 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38319 goto out_err;
38320
38321 }
38322 - ++item->refcount;
38323 + atomic_inc(&item->refcount);
38324 ref->object = item->object;
38325 object = item->object;
38326 mutex_unlock(&item->mutex);
38327 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38328 struct drm_global_item *item = &glob[ref->global_type];
38329
38330 mutex_lock(&item->mutex);
38331 - BUG_ON(item->refcount == 0);
38332 + BUG_ON(atomic_read(&item->refcount) == 0);
38333 BUG_ON(ref->object != item->object);
38334 - if (--item->refcount == 0) {
38335 + if (atomic_dec_and_test(&item->refcount)) {
38336 ref->release(ref);
38337 item->object = NULL;
38338 }
38339 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38340 index d4b20ce..77a8d41 100644
38341 --- a/drivers/gpu/drm/drm_info.c
38342 +++ b/drivers/gpu/drm/drm_info.c
38343 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38344 struct drm_local_map *map;
38345 struct drm_map_list *r_list;
38346
38347 - /* Hardcoded from _DRM_FRAME_BUFFER,
38348 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38349 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38350 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38351 + static const char * const types[] = {
38352 + [_DRM_FRAME_BUFFER] = "FB",
38353 + [_DRM_REGISTERS] = "REG",
38354 + [_DRM_SHM] = "SHM",
38355 + [_DRM_AGP] = "AGP",
38356 + [_DRM_SCATTER_GATHER] = "SG",
38357 + [_DRM_CONSISTENT] = "PCI",
38358 + [_DRM_GEM] = "GEM" };
38359 const char *type;
38360 int i;
38361
38362 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38363 map = r_list->map;
38364 if (!map)
38365 continue;
38366 - if (map->type < 0 || map->type > 5)
38367 + if (map->type >= ARRAY_SIZE(types))
38368 type = "??";
38369 else
38370 type = types[map->type];
38371 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38372 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38373 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38374 vma->vm_flags & VM_IO ? 'i' : '-',
38375 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38376 + 0);
38377 +#else
38378 vma->vm_pgoff);
38379 +#endif
38380
38381 #if defined(__i386__)
38382 pgprot = pgprot_val(vma->vm_page_prot);
38383 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38384 index 2f4c434..dd12cd2 100644
38385 --- a/drivers/gpu/drm/drm_ioc32.c
38386 +++ b/drivers/gpu/drm/drm_ioc32.c
38387 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38388 request = compat_alloc_user_space(nbytes);
38389 if (!access_ok(VERIFY_WRITE, request, nbytes))
38390 return -EFAULT;
38391 - list = (struct drm_buf_desc *) (request + 1);
38392 + list = (struct drm_buf_desc __user *) (request + 1);
38393
38394 if (__put_user(count, &request->count)
38395 || __put_user(list, &request->list))
38396 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38397 request = compat_alloc_user_space(nbytes);
38398 if (!access_ok(VERIFY_WRITE, request, nbytes))
38399 return -EFAULT;
38400 - list = (struct drm_buf_pub *) (request + 1);
38401 + list = (struct drm_buf_pub __user *) (request + 1);
38402
38403 if (__put_user(count, &request->count)
38404 || __put_user(list, &request->list))
38405 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38406 return 0;
38407 }
38408
38409 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38410 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38411 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38412 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38413 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38414 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38415 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38416 {
38417 unsigned int nr = DRM_IOCTL_NR(cmd);
38418 - drm_ioctl_compat_t *fn;
38419 int ret;
38420
38421 /* Assume that ioctls without an explicit compat routine will just
38422 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38423 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38424 return drm_ioctl(filp, cmd, arg);
38425
38426 - fn = drm_compat_ioctls[nr];
38427 -
38428 - if (fn != NULL)
38429 - ret = (*fn) (filp, cmd, arg);
38430 + if (drm_compat_ioctls[nr] != NULL)
38431 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38432 else
38433 ret = drm_ioctl(filp, cmd, arg);
38434
38435 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38436 index ffd7a7b..a64643e 100644
38437 --- a/drivers/gpu/drm/drm_ioctl.c
38438 +++ b/drivers/gpu/drm/drm_ioctl.c
38439 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38440 stats->data[i].value =
38441 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38442 else
38443 - stats->data[i].value = atomic_read(&dev->counts[i]);
38444 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38445 stats->data[i].type = dev->types[i];
38446 }
38447
38448 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38449 index d752c96..fe08455 100644
38450 --- a/drivers/gpu/drm/drm_lock.c
38451 +++ b/drivers/gpu/drm/drm_lock.c
38452 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38453 if (drm_lock_take(&master->lock, lock->context)) {
38454 master->lock.file_priv = file_priv;
38455 master->lock.lock_time = jiffies;
38456 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38457 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38458 break; /* Got lock */
38459 }
38460
38461 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38462 return -EINVAL;
38463 }
38464
38465 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38466 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38467
38468 if (drm_lock_free(&master->lock, lock->context)) {
38469 /* FIXME: Should really bail out here. */
38470 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38471 index 327ca19..684d3c0 100644
38472 --- a/drivers/gpu/drm/drm_stub.c
38473 +++ b/drivers/gpu/drm/drm_stub.c
38474 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38475
38476 drm_device_set_unplugged(dev);
38477
38478 - if (dev->open_count == 0) {
38479 + if (local_read(&dev->open_count) == 0) {
38480 drm_put_dev(dev);
38481 }
38482 mutex_unlock(&drm_global_mutex);
38483 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38484 index 2290b3b..22056a1 100644
38485 --- a/drivers/gpu/drm/drm_sysfs.c
38486 +++ b/drivers/gpu/drm/drm_sysfs.c
38487 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38488 int drm_sysfs_device_add(struct drm_minor *minor)
38489 {
38490 int err;
38491 - char *minor_str;
38492 + const char *minor_str;
38493
38494 minor->kdev.parent = minor->dev->dev;
38495
38496 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38497 index ada49ed..29275a0 100644
38498 --- a/drivers/gpu/drm/i810/i810_dma.c
38499 +++ b/drivers/gpu/drm/i810/i810_dma.c
38500 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38501 dma->buflist[vertex->idx],
38502 vertex->discard, vertex->used);
38503
38504 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38505 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38506 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38507 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38508 sarea_priv->last_enqueue = dev_priv->counter - 1;
38509 sarea_priv->last_dispatch = (int)hw_status[5];
38510
38511 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38512 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38513 mc->last_render);
38514
38515 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38516 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38517 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38518 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38519 sarea_priv->last_enqueue = dev_priv->counter - 1;
38520 sarea_priv->last_dispatch = (int)hw_status[5];
38521
38522 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38523 index 6e0acad..93c8289 100644
38524 --- a/drivers/gpu/drm/i810/i810_drv.h
38525 +++ b/drivers/gpu/drm/i810/i810_drv.h
38526 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38527 int page_flipping;
38528
38529 wait_queue_head_t irq_queue;
38530 - atomic_t irq_received;
38531 - atomic_t irq_emitted;
38532 + atomic_unchecked_t irq_received;
38533 + atomic_unchecked_t irq_emitted;
38534
38535 int front_offset;
38536 } drm_i810_private_t;
38537 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38538 index 47d6c74..279123f 100644
38539 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38540 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38541 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38542 I915_READ(GTIMR));
38543 }
38544 seq_printf(m, "Interrupts received: %d\n",
38545 - atomic_read(&dev_priv->irq_received));
38546 + atomic_read_unchecked(&dev_priv->irq_received));
38547 for_each_ring(ring, dev_priv, i) {
38548 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38549 seq_printf(m,
38550 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38551 index f466980..8f2883f 100644
38552 --- a/drivers/gpu/drm/i915/i915_dma.c
38553 +++ b/drivers/gpu/drm/i915/i915_dma.c
38554 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38555 bool can_switch;
38556
38557 spin_lock(&dev->count_lock);
38558 - can_switch = (dev->open_count == 0);
38559 + can_switch = (local_read(&dev->open_count) == 0);
38560 spin_unlock(&dev->count_lock);
38561 return can_switch;
38562 }
38563 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38564 index 2f09e80..077876d 100644
38565 --- a/drivers/gpu/drm/i915/i915_drv.h
38566 +++ b/drivers/gpu/drm/i915/i915_drv.h
38567 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38568 drm_dma_handle_t *status_page_dmah;
38569 struct resource mch_res;
38570
38571 - atomic_t irq_received;
38572 + atomic_unchecked_t irq_received;
38573
38574 /* protects the irq masks */
38575 spinlock_t irq_lock;
38576 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38577 index 87a3227..cd13d8f 100644
38578 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38579 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38580 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38581
38582 static int
38583 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38584 - int count)
38585 + unsigned int count)
38586 {
38587 - int i;
38588 + unsigned int i;
38589 int relocs_total = 0;
38590 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38591
38592 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38593 index 3c59584..500f2e9 100644
38594 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38595 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38596 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38597 (unsigned long)request);
38598 }
38599
38600 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38601 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38602 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38603 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38604 [DRM_I915_GETPARAM] = compat_i915_getparam,
38605 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38606 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38607 {
38608 unsigned int nr = DRM_IOCTL_NR(cmd);
38609 - drm_ioctl_compat_t *fn = NULL;
38610 int ret;
38611
38612 if (nr < DRM_COMMAND_BASE)
38613 return drm_compat_ioctl(filp, cmd, arg);
38614
38615 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38616 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38617 -
38618 - if (fn != NULL)
38619 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38620 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38621 ret = (*fn) (filp, cmd, arg);
38622 - else
38623 + } else
38624 ret = drm_ioctl(filp, cmd, arg);
38625
38626 return ret;
38627 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38628 index 46d46ba..6e49848 100644
38629 --- a/drivers/gpu/drm/i915/i915_irq.c
38630 +++ b/drivers/gpu/drm/i915/i915_irq.c
38631 @@ -975,7 +975,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38632 int pipe;
38633 u32 pipe_stats[I915_MAX_PIPES];
38634
38635 - atomic_inc(&dev_priv->irq_received);
38636 + atomic_inc_unchecked(&dev_priv->irq_received);
38637
38638 while (true) {
38639 iir = I915_READ(VLV_IIR);
38640 @@ -1192,7 +1192,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38641 irqreturn_t ret = IRQ_NONE;
38642 int i;
38643
38644 - atomic_inc(&dev_priv->irq_received);
38645 + atomic_inc_unchecked(&dev_priv->irq_received);
38646
38647 /* We get interrupts on unclaimed registers, so check for this before we
38648 * do any I915_{READ,WRITE}. */
38649 @@ -1312,7 +1312,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38650 int ret = IRQ_NONE;
38651 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38652
38653 - atomic_inc(&dev_priv->irq_received);
38654 + atomic_inc_unchecked(&dev_priv->irq_received);
38655
38656 /* disable master interrupt before clearing iir */
38657 de_ier = I915_READ(DEIER);
38658 @@ -2617,7 +2617,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38659 {
38660 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38661
38662 - atomic_set(&dev_priv->irq_received, 0);
38663 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38664
38665 I915_WRITE(HWSTAM, 0xeffe);
38666
38667 @@ -2639,7 +2639,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38668 {
38669 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38670
38671 - atomic_set(&dev_priv->irq_received, 0);
38672 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38673
38674 I915_WRITE(HWSTAM, 0xeffe);
38675
38676 @@ -2667,7 +2667,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38677 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38678 int pipe;
38679
38680 - atomic_set(&dev_priv->irq_received, 0);
38681 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38682
38683 /* VLV magic */
38684 I915_WRITE(VLV_IMR, 0);
38685 @@ -2979,7 +2979,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38686 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38687 int pipe;
38688
38689 - atomic_set(&dev_priv->irq_received, 0);
38690 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38691
38692 for_each_pipe(pipe)
38693 I915_WRITE(PIPESTAT(pipe), 0);
38694 @@ -3058,7 +3058,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38695 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38696 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38697
38698 - atomic_inc(&dev_priv->irq_received);
38699 + atomic_inc_unchecked(&dev_priv->irq_received);
38700
38701 iir = I915_READ16(IIR);
38702 if (iir == 0)
38703 @@ -3133,7 +3133,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38704 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38705 int pipe;
38706
38707 - atomic_set(&dev_priv->irq_received, 0);
38708 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38709
38710 if (I915_HAS_HOTPLUG(dev)) {
38711 I915_WRITE(PORT_HOTPLUG_EN, 0);
38712 @@ -3232,7 +3232,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38713 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38714 int pipe, ret = IRQ_NONE;
38715
38716 - atomic_inc(&dev_priv->irq_received);
38717 + atomic_inc_unchecked(&dev_priv->irq_received);
38718
38719 iir = I915_READ(IIR);
38720 do {
38721 @@ -3356,7 +3356,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38722 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38723 int pipe;
38724
38725 - atomic_set(&dev_priv->irq_received, 0);
38726 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38727
38728 I915_WRITE(PORT_HOTPLUG_EN, 0);
38729 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38730 @@ -3465,7 +3465,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38731 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38732 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38733
38734 - atomic_inc(&dev_priv->irq_received);
38735 + atomic_inc_unchecked(&dev_priv->irq_received);
38736
38737 iir = I915_READ(IIR);
38738
38739 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38740 index 7fc8a76..95672c0 100644
38741 --- a/drivers/gpu/drm/i915/intel_display.c
38742 +++ b/drivers/gpu/drm/i915/intel_display.c
38743 @@ -9428,13 +9428,13 @@ struct intel_quirk {
38744 int subsystem_vendor;
38745 int subsystem_device;
38746 void (*hook)(struct drm_device *dev);
38747 -};
38748 +} __do_const;
38749
38750 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38751 struct intel_dmi_quirk {
38752 void (*hook)(struct drm_device *dev);
38753 const struct dmi_system_id (*dmi_id_list)[];
38754 -};
38755 +} __do_const;
38756
38757 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38758 {
38759 @@ -9442,18 +9442,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38760 return 1;
38761 }
38762
38763 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38764 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38765 {
38766 - .dmi_id_list = &(const struct dmi_system_id[]) {
38767 - {
38768 - .callback = intel_dmi_reverse_brightness,
38769 - .ident = "NCR Corporation",
38770 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38771 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38772 - },
38773 - },
38774 - { } /* terminating entry */
38775 + .callback = intel_dmi_reverse_brightness,
38776 + .ident = "NCR Corporation",
38777 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38778 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38779 },
38780 + },
38781 + { } /* terminating entry */
38782 +};
38783 +
38784 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38785 + {
38786 + .dmi_id_list = &intel_dmi_quirks_table,
38787 .hook = quirk_invert_brightness,
38788 },
38789 };
38790 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38791 index 54558a0..2d97005 100644
38792 --- a/drivers/gpu/drm/mga/mga_drv.h
38793 +++ b/drivers/gpu/drm/mga/mga_drv.h
38794 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38795 u32 clear_cmd;
38796 u32 maccess;
38797
38798 - atomic_t vbl_received; /**< Number of vblanks received. */
38799 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38800 wait_queue_head_t fence_queue;
38801 - atomic_t last_fence_retired;
38802 + atomic_unchecked_t last_fence_retired;
38803 u32 next_fence_to_post;
38804
38805 unsigned int fb_cpp;
38806 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38807 index 709e90d..89a1c0d 100644
38808 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38809 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38810 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38811 return 0;
38812 }
38813
38814 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38815 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38816 [DRM_MGA_INIT] = compat_mga_init,
38817 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38818 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38819 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38820 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38821 {
38822 unsigned int nr = DRM_IOCTL_NR(cmd);
38823 - drm_ioctl_compat_t *fn = NULL;
38824 int ret;
38825
38826 if (nr < DRM_COMMAND_BASE)
38827 return drm_compat_ioctl(filp, cmd, arg);
38828
38829 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38830 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38831 -
38832 - if (fn != NULL)
38833 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38834 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38835 ret = (*fn) (filp, cmd, arg);
38836 - else
38837 + } else
38838 ret = drm_ioctl(filp, cmd, arg);
38839
38840 return ret;
38841 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38842 index 598c281..60d590e 100644
38843 --- a/drivers/gpu/drm/mga/mga_irq.c
38844 +++ b/drivers/gpu/drm/mga/mga_irq.c
38845 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38846 if (crtc != 0)
38847 return 0;
38848
38849 - return atomic_read(&dev_priv->vbl_received);
38850 + return atomic_read_unchecked(&dev_priv->vbl_received);
38851 }
38852
38853
38854 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38855 /* VBLANK interrupt */
38856 if (status & MGA_VLINEPEN) {
38857 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38858 - atomic_inc(&dev_priv->vbl_received);
38859 + atomic_inc_unchecked(&dev_priv->vbl_received);
38860 drm_handle_vblank(dev, 0);
38861 handled = 1;
38862 }
38863 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38864 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38865 MGA_WRITE(MGA_PRIMEND, prim_end);
38866
38867 - atomic_inc(&dev_priv->last_fence_retired);
38868 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38869 DRM_WAKEUP(&dev_priv->fence_queue);
38870 handled = 1;
38871 }
38872 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38873 * using fences.
38874 */
38875 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38876 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38877 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38878 - *sequence) <= (1 << 23)));
38879
38880 *sequence = cur_fence;
38881 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38882 index 3e72876..d1c15ad 100644
38883 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38884 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38885 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38886 struct bit_table {
38887 const char id;
38888 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38889 -};
38890 +} __no_const;
38891
38892 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38893
38894 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38895 index 41ff7e0..fa854ef 100644
38896 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38897 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38898 @@ -92,7 +92,6 @@ struct nouveau_drm {
38899 struct drm_global_reference mem_global_ref;
38900 struct ttm_bo_global_ref bo_global_ref;
38901 struct ttm_bo_device bdev;
38902 - atomic_t validate_sequence;
38903 int (*move)(struct nouveau_channel *,
38904 struct ttm_buffer_object *,
38905 struct ttm_mem_reg *, struct ttm_mem_reg *);
38906 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38907 index 08214bc..9208577 100644
38908 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38909 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38910 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38911 unsigned long arg)
38912 {
38913 unsigned int nr = DRM_IOCTL_NR(cmd);
38914 - drm_ioctl_compat_t *fn = NULL;
38915 + drm_ioctl_compat_t fn = NULL;
38916 int ret;
38917
38918 if (nr < DRM_COMMAND_BASE)
38919 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38920 index 25d3495..d81aaf6 100644
38921 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38922 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38923 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38924 bool can_switch;
38925
38926 spin_lock(&dev->count_lock);
38927 - can_switch = (dev->open_count == 0);
38928 + can_switch = (local_read(&dev->open_count) == 0);
38929 spin_unlock(&dev->count_lock);
38930 return can_switch;
38931 }
38932 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38933 index 1dfd84c..104896c 100644
38934 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38935 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38936 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38937 }
38938 }
38939
38940 -static struct vm_operations_struct qxl_ttm_vm_ops;
38941 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38942 static const struct vm_operations_struct *ttm_vm_ops;
38943
38944 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38945 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38946 return r;
38947 if (unlikely(ttm_vm_ops == NULL)) {
38948 ttm_vm_ops = vma->vm_ops;
38949 + pax_open_kernel();
38950 qxl_ttm_vm_ops = *ttm_vm_ops;
38951 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38952 + pax_close_kernel();
38953 }
38954 vma->vm_ops = &qxl_ttm_vm_ops;
38955 return 0;
38956 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38957 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38958 {
38959 #if defined(CONFIG_DEBUG_FS)
38960 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38961 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38962 - unsigned i;
38963 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38964 + {
38965 + .name = "qxl_mem_mm",
38966 + .show = &qxl_mm_dump_table,
38967 + },
38968 + {
38969 + .name = "qxl_surf_mm",
38970 + .show = &qxl_mm_dump_table,
38971 + }
38972 + };
38973
38974 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38975 - if (i == 0)
38976 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38977 - else
38978 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38979 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38980 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38981 - qxl_mem_types_list[i].driver_features = 0;
38982 - if (i == 0)
38983 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38984 - else
38985 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38986 + pax_open_kernel();
38987 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38988 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38989 + pax_close_kernel();
38990
38991 - }
38992 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38993 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38994 #else
38995 return 0;
38996 #endif
38997 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38998 index d4660cf..70dbe65 100644
38999 --- a/drivers/gpu/drm/r128/r128_cce.c
39000 +++ b/drivers/gpu/drm/r128/r128_cce.c
39001 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
39002
39003 /* GH: Simple idle check.
39004 */
39005 - atomic_set(&dev_priv->idle_count, 0);
39006 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39007
39008 /* We don't support anything other than bus-mastering ring mode,
39009 * but the ring can be in either AGP or PCI space for the ring
39010 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
39011 index 930c71b..499aded 100644
39012 --- a/drivers/gpu/drm/r128/r128_drv.h
39013 +++ b/drivers/gpu/drm/r128/r128_drv.h
39014 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
39015 int is_pci;
39016 unsigned long cce_buffers_offset;
39017
39018 - atomic_t idle_count;
39019 + atomic_unchecked_t idle_count;
39020
39021 int page_flipping;
39022 int current_page;
39023 u32 crtc_offset;
39024 u32 crtc_offset_cntl;
39025
39026 - atomic_t vbl_received;
39027 + atomic_unchecked_t vbl_received;
39028
39029 u32 color_fmt;
39030 unsigned int front_offset;
39031 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
39032 index a954c54..9cc595c 100644
39033 --- a/drivers/gpu/drm/r128/r128_ioc32.c
39034 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
39035 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
39036 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
39037 }
39038
39039 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
39040 +drm_ioctl_compat_t r128_compat_ioctls[] = {
39041 [DRM_R128_INIT] = compat_r128_init,
39042 [DRM_R128_DEPTH] = compat_r128_depth,
39043 [DRM_R128_STIPPLE] = compat_r128_stipple,
39044 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39045 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39046 {
39047 unsigned int nr = DRM_IOCTL_NR(cmd);
39048 - drm_ioctl_compat_t *fn = NULL;
39049 int ret;
39050
39051 if (nr < DRM_COMMAND_BASE)
39052 return drm_compat_ioctl(filp, cmd, arg);
39053
39054 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39055 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39056 -
39057 - if (fn != NULL)
39058 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39059 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39060 ret = (*fn) (filp, cmd, arg);
39061 - else
39062 + } else
39063 ret = drm_ioctl(filp, cmd, arg);
39064
39065 return ret;
39066 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39067 index 2ea4f09..d391371 100644
39068 --- a/drivers/gpu/drm/r128/r128_irq.c
39069 +++ b/drivers/gpu/drm/r128/r128_irq.c
39070 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39071 if (crtc != 0)
39072 return 0;
39073
39074 - return atomic_read(&dev_priv->vbl_received);
39075 + return atomic_read_unchecked(&dev_priv->vbl_received);
39076 }
39077
39078 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39079 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39080 /* VBLANK interrupt */
39081 if (status & R128_CRTC_VBLANK_INT) {
39082 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39083 - atomic_inc(&dev_priv->vbl_received);
39084 + atomic_inc_unchecked(&dev_priv->vbl_received);
39085 drm_handle_vblank(dev, 0);
39086 return IRQ_HANDLED;
39087 }
39088 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39089 index 19bb7e6..de7e2a2 100644
39090 --- a/drivers/gpu/drm/r128/r128_state.c
39091 +++ b/drivers/gpu/drm/r128/r128_state.c
39092 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39093
39094 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39095 {
39096 - if (atomic_read(&dev_priv->idle_count) == 0)
39097 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39098 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39099 else
39100 - atomic_set(&dev_priv->idle_count, 0);
39101 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39102 }
39103
39104 #endif
39105 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39106 index af85299..ed9ac8d 100644
39107 --- a/drivers/gpu/drm/radeon/mkregtable.c
39108 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39109 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
39110 regex_t mask_rex;
39111 regmatch_t match[4];
39112 char buf[1024];
39113 - size_t end;
39114 + long end;
39115 int len;
39116 int done = 0;
39117 int r;
39118 unsigned o;
39119 struct offset *offset;
39120 char last_reg_s[10];
39121 - int last_reg;
39122 + unsigned long last_reg;
39123
39124 if (regcomp
39125 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39126 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39127 index d15f27e..ef11ffc 100644
39128 --- a/drivers/gpu/drm/radeon/radeon_device.c
39129 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39130 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39131 bool can_switch;
39132
39133 spin_lock(&dev->count_lock);
39134 - can_switch = (dev->open_count == 0);
39135 + can_switch = (local_read(&dev->open_count) == 0);
39136 spin_unlock(&dev->count_lock);
39137 return can_switch;
39138 }
39139 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39140 index b369d42..8dd04eb 100644
39141 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39142 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39143 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39144
39145 /* SW interrupt */
39146 wait_queue_head_t swi_queue;
39147 - atomic_t swi_emitted;
39148 + atomic_unchecked_t swi_emitted;
39149 int vblank_crtc;
39150 uint32_t irq_enable_reg;
39151 uint32_t r500_disp_irq_reg;
39152 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39153 index c180df8..5fd8186 100644
39154 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39155 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39156 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39157 request = compat_alloc_user_space(sizeof(*request));
39158 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39159 || __put_user(req32.param, &request->param)
39160 - || __put_user((void __user *)(unsigned long)req32.value,
39161 + || __put_user((unsigned long)req32.value,
39162 &request->value))
39163 return -EFAULT;
39164
39165 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39166 #define compat_radeon_cp_setparam NULL
39167 #endif /* X86_64 || IA64 */
39168
39169 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39170 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39171 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39172 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39173 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39174 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39175 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39176 {
39177 unsigned int nr = DRM_IOCTL_NR(cmd);
39178 - drm_ioctl_compat_t *fn = NULL;
39179 int ret;
39180
39181 if (nr < DRM_COMMAND_BASE)
39182 return drm_compat_ioctl(filp, cmd, arg);
39183
39184 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39185 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39186 -
39187 - if (fn != NULL)
39188 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39189 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39190 ret = (*fn) (filp, cmd, arg);
39191 - else
39192 + } else
39193 ret = drm_ioctl(filp, cmd, arg);
39194
39195 return ret;
39196 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39197 index 8d68e97..9dcfed8 100644
39198 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39199 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39200 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39201 unsigned int ret;
39202 RING_LOCALS;
39203
39204 - atomic_inc(&dev_priv->swi_emitted);
39205 - ret = atomic_read(&dev_priv->swi_emitted);
39206 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39207 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39208
39209 BEGIN_RING(4);
39210 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39211 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39212 drm_radeon_private_t *dev_priv =
39213 (drm_radeon_private_t *) dev->dev_private;
39214
39215 - atomic_set(&dev_priv->swi_emitted, 0);
39216 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39217 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39218
39219 dev->max_vblank_count = 0x001fffff;
39220 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39221 index 4d20910..6726b6d 100644
39222 --- a/drivers/gpu/drm/radeon/radeon_state.c
39223 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39224 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39225 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39226 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39227
39228 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39229 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39230 sarea_priv->nbox * sizeof(depth_boxes[0])))
39231 return -EFAULT;
39232
39233 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39234 {
39235 drm_radeon_private_t *dev_priv = dev->dev_private;
39236 drm_radeon_getparam_t *param = data;
39237 - int value;
39238 + int value = 0;
39239
39240 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39241
39242 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39243 index 6c0ce89..57a2529 100644
39244 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39245 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39246 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39247 man->size = size >> PAGE_SHIFT;
39248 }
39249
39250 -static struct vm_operations_struct radeon_ttm_vm_ops;
39251 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39252 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39253
39254 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39255 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39256 }
39257 if (unlikely(ttm_vm_ops == NULL)) {
39258 ttm_vm_ops = vma->vm_ops;
39259 + pax_open_kernel();
39260 radeon_ttm_vm_ops = *ttm_vm_ops;
39261 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39262 + pax_close_kernel();
39263 }
39264 vma->vm_ops = &radeon_ttm_vm_ops;
39265 return 0;
39266 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39267 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39268 {
39269 #if defined(CONFIG_DEBUG_FS)
39270 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39271 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39272 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39273 + {
39274 + .name = "radeon_vram_mm",
39275 + .show = &radeon_mm_dump_table,
39276 + },
39277 + {
39278 + .name = "radeon_gtt_mm",
39279 + .show = &radeon_mm_dump_table,
39280 + },
39281 + {
39282 + .name = "ttm_page_pool",
39283 + .show = &ttm_page_alloc_debugfs,
39284 + },
39285 + {
39286 + .name = "ttm_dma_page_pool",
39287 + .show = &ttm_dma_page_alloc_debugfs,
39288 + },
39289 + };
39290 unsigned i;
39291
39292 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39293 - if (i == 0)
39294 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39295 - else
39296 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39297 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39298 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39299 - radeon_mem_types_list[i].driver_features = 0;
39300 - if (i == 0)
39301 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39302 - else
39303 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39304 -
39305 - }
39306 - /* Add ttm page pool to debugfs */
39307 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39308 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39309 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39310 - radeon_mem_types_list[i].driver_features = 0;
39311 - radeon_mem_types_list[i++].data = NULL;
39312 + pax_open_kernel();
39313 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39314 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39315 + pax_close_kernel();
39316 #ifdef CONFIG_SWIOTLB
39317 - if (swiotlb_nr_tbl()) {
39318 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39319 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39320 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39321 - radeon_mem_types_list[i].driver_features = 0;
39322 - radeon_mem_types_list[i++].data = NULL;
39323 - }
39324 + if (swiotlb_nr_tbl())
39325 + i++;
39326 #endif
39327 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39328
39329 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39330 index d8ddfb3..609de1d 100644
39331 --- a/drivers/gpu/drm/radeon/rs690.c
39332 +++ b/drivers/gpu/drm/radeon/rs690.c
39333 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39334 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39335 rdev->pm.sideport_bandwidth.full)
39336 max_bandwidth = rdev->pm.sideport_bandwidth;
39337 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39338 + read_delay_latency.full = dfixed_const(800 * 1000);
39339 read_delay_latency.full = dfixed_div(read_delay_latency,
39340 rdev->pm.igp_sideport_mclk);
39341 + a.full = dfixed_const(370);
39342 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39343 } else {
39344 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39345 rdev->pm.k8_bandwidth.full)
39346 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39347 index dbc2def..0a9f710 100644
39348 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39349 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39350 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39351 zone->glob = glob;
39352 glob->zone_kernel = zone;
39353 ret = kobject_init_and_add(
39354 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39355 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39356 if (unlikely(ret != 0)) {
39357 kobject_put(&zone->kobj);
39358 return ret;
39359 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39360 zone->glob = glob;
39361 glob->zone_dma32 = zone;
39362 ret = kobject_init_and_add(
39363 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39364 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39365 if (unlikely(ret != 0)) {
39366 kobject_put(&zone->kobj);
39367 return ret;
39368 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39369 index bd2a3b4..122d9ad 100644
39370 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39371 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39372 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39373 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39374 struct shrink_control *sc)
39375 {
39376 - static atomic_t start_pool = ATOMIC_INIT(0);
39377 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39378 unsigned i;
39379 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39380 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39381 struct ttm_page_pool *pool;
39382 int shrink_pages = sc->nr_to_scan;
39383
39384 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39385 index 97e9d61..bf23c461 100644
39386 --- a/drivers/gpu/drm/udl/udl_fb.c
39387 +++ b/drivers/gpu/drm/udl/udl_fb.c
39388 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39389 fb_deferred_io_cleanup(info);
39390 kfree(info->fbdefio);
39391 info->fbdefio = NULL;
39392 - info->fbops->fb_mmap = udl_fb_mmap;
39393 }
39394
39395 pr_warn("released /dev/fb%d user=%d count=%d\n",
39396 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39397 index 893a650..6190d3b 100644
39398 --- a/drivers/gpu/drm/via/via_drv.h
39399 +++ b/drivers/gpu/drm/via/via_drv.h
39400 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39401 typedef uint32_t maskarray_t[5];
39402
39403 typedef struct drm_via_irq {
39404 - atomic_t irq_received;
39405 + atomic_unchecked_t irq_received;
39406 uint32_t pending_mask;
39407 uint32_t enable_mask;
39408 wait_queue_head_t irq_queue;
39409 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39410 struct timeval last_vblank;
39411 int last_vblank_valid;
39412 unsigned usec_per_vblank;
39413 - atomic_t vbl_received;
39414 + atomic_unchecked_t vbl_received;
39415 drm_via_state_t hc_state;
39416 char pci_buf[VIA_PCI_BUF_SIZE];
39417 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39418 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39419 index ac98964..5dbf512 100644
39420 --- a/drivers/gpu/drm/via/via_irq.c
39421 +++ b/drivers/gpu/drm/via/via_irq.c
39422 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39423 if (crtc != 0)
39424 return 0;
39425
39426 - return atomic_read(&dev_priv->vbl_received);
39427 + return atomic_read_unchecked(&dev_priv->vbl_received);
39428 }
39429
39430 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39431 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39432
39433 status = VIA_READ(VIA_REG_INTERRUPT);
39434 if (status & VIA_IRQ_VBLANK_PENDING) {
39435 - atomic_inc(&dev_priv->vbl_received);
39436 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39437 + atomic_inc_unchecked(&dev_priv->vbl_received);
39438 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39439 do_gettimeofday(&cur_vblank);
39440 if (dev_priv->last_vblank_valid) {
39441 dev_priv->usec_per_vblank =
39442 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39443 dev_priv->last_vblank = cur_vblank;
39444 dev_priv->last_vblank_valid = 1;
39445 }
39446 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39447 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39448 DRM_DEBUG("US per vblank is: %u\n",
39449 dev_priv->usec_per_vblank);
39450 }
39451 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39452
39453 for (i = 0; i < dev_priv->num_irqs; ++i) {
39454 if (status & cur_irq->pending_mask) {
39455 - atomic_inc(&cur_irq->irq_received);
39456 + atomic_inc_unchecked(&cur_irq->irq_received);
39457 DRM_WAKEUP(&cur_irq->irq_queue);
39458 handled = 1;
39459 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39460 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39461 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39462 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39463 masks[irq][4]));
39464 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39465 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39466 } else {
39467 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39468 (((cur_irq_sequence =
39469 - atomic_read(&cur_irq->irq_received)) -
39470 + atomic_read_unchecked(&cur_irq->irq_received)) -
39471 *sequence) <= (1 << 23)));
39472 }
39473 *sequence = cur_irq_sequence;
39474 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39475 }
39476
39477 for (i = 0; i < dev_priv->num_irqs; ++i) {
39478 - atomic_set(&cur_irq->irq_received, 0);
39479 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39480 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39481 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39482 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39483 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39484 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39485 case VIA_IRQ_RELATIVE:
39486 irqwait->request.sequence +=
39487 - atomic_read(&cur_irq->irq_received);
39488 + atomic_read_unchecked(&cur_irq->irq_received);
39489 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39490 case VIA_IRQ_ABSOLUTE:
39491 break;
39492 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39493 index 13aeda7..4a952d1 100644
39494 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39495 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39496 @@ -290,7 +290,7 @@ struct vmw_private {
39497 * Fencing and IRQs.
39498 */
39499
39500 - atomic_t marker_seq;
39501 + atomic_unchecked_t marker_seq;
39502 wait_queue_head_t fence_queue;
39503 wait_queue_head_t fifo_queue;
39504 int fence_queue_waiters; /* Protected by hw_mutex */
39505 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39506 index 3eb1486..0a47ee9 100644
39507 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39508 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39509 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39510 (unsigned int) min,
39511 (unsigned int) fifo->capabilities);
39512
39513 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39514 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39515 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39516 vmw_marker_queue_init(&fifo->marker_queue);
39517 return vmw_fifo_send_fence(dev_priv, &dummy);
39518 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39519 if (reserveable)
39520 iowrite32(bytes, fifo_mem +
39521 SVGA_FIFO_RESERVED);
39522 - return fifo_mem + (next_cmd >> 2);
39523 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39524 } else {
39525 need_bounce = true;
39526 }
39527 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39528
39529 fm = vmw_fifo_reserve(dev_priv, bytes);
39530 if (unlikely(fm == NULL)) {
39531 - *seqno = atomic_read(&dev_priv->marker_seq);
39532 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39533 ret = -ENOMEM;
39534 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39535 false, 3*HZ);
39536 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39537 }
39538
39539 do {
39540 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39541 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39542 } while (*seqno == 0);
39543
39544 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39545 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39546 index c509d40..3b640c3 100644
39547 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39548 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39549 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39550 int ret;
39551
39552 num_clips = arg->num_clips;
39553 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39554 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39555
39556 if (unlikely(num_clips == 0))
39557 return 0;
39558 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39559 int ret;
39560
39561 num_clips = arg->num_clips;
39562 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39563 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39564
39565 if (unlikely(num_clips == 0))
39566 return 0;
39567 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39568 index 4640adb..e1384ed 100644
39569 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39570 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39571 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39572 * emitted. Then the fence is stale and signaled.
39573 */
39574
39575 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39576 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39577 > VMW_FENCE_WRAP);
39578
39579 return ret;
39580 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39581
39582 if (fifo_idle)
39583 down_read(&fifo_state->rwsem);
39584 - signal_seq = atomic_read(&dev_priv->marker_seq);
39585 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39586 ret = 0;
39587
39588 for (;;) {
39589 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39590 index 8a8725c2..afed796 100644
39591 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39592 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39593 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39594 while (!vmw_lag_lt(queue, us)) {
39595 spin_lock(&queue->lock);
39596 if (list_empty(&queue->head))
39597 - seqno = atomic_read(&dev_priv->marker_seq);
39598 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39599 else {
39600 marker = list_first_entry(&queue->head,
39601 struct vmw_marker, head);
39602 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39603 index 5360e5a..c2c0d26 100644
39604 --- a/drivers/gpu/host1x/drm/dc.c
39605 +++ b/drivers/gpu/host1x/drm/dc.c
39606 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39607 }
39608
39609 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39610 - dc->debugfs_files[i].data = dc;
39611 + *(void **)&dc->debugfs_files[i].data = dc;
39612
39613 err = drm_debugfs_create_files(dc->debugfs_files,
39614 ARRAY_SIZE(debugfs_files),
39615 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39616 index 9f60d63..c89e0b7 100644
39617 --- a/drivers/hid/hid-core.c
39618 +++ b/drivers/hid/hid-core.c
39619 @@ -2370,7 +2370,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39620
39621 int hid_add_device(struct hid_device *hdev)
39622 {
39623 - static atomic_t id = ATOMIC_INIT(0);
39624 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39625 int ret;
39626
39627 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39628 @@ -2404,7 +2404,7 @@ int hid_add_device(struct hid_device *hdev)
39629 /* XXX hack, any other cleaner solution after the driver core
39630 * is converted to allow more than 20 bytes as the device name? */
39631 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39632 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39633 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39634
39635 hid_debug_register(hdev, dev_name(&hdev->dev));
39636 ret = device_add(&hdev->dev);
39637 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39638 index c13fb5b..55a3802 100644
39639 --- a/drivers/hid/hid-wiimote-debug.c
39640 +++ b/drivers/hid/hid-wiimote-debug.c
39641 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39642 else if (size == 0)
39643 return -EIO;
39644
39645 - if (copy_to_user(u, buf, size))
39646 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39647 return -EFAULT;
39648
39649 *off += size;
39650 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39651 index 145a4cb..2353a3e 100644
39652 --- a/drivers/hid/uhid.c
39653 +++ b/drivers/hid/uhid.c
39654 @@ -47,7 +47,7 @@ struct uhid_device {
39655 struct mutex report_lock;
39656 wait_queue_head_t report_wait;
39657 atomic_t report_done;
39658 - atomic_t report_id;
39659 + atomic_unchecked_t report_id;
39660 struct uhid_event report_buf;
39661 };
39662
39663 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39664
39665 spin_lock_irqsave(&uhid->qlock, flags);
39666 ev->type = UHID_FEATURE;
39667 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39668 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39669 ev->u.feature.rnum = rnum;
39670 ev->u.feature.rtype = report_type;
39671
39672 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39673 spin_lock_irqsave(&uhid->qlock, flags);
39674
39675 /* id for old report; drop it silently */
39676 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39677 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39678 goto unlock;
39679 if (atomic_read(&uhid->report_done))
39680 goto unlock;
39681 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39682 index 6de6c98..18319e9 100644
39683 --- a/drivers/hv/channel.c
39684 +++ b/drivers/hv/channel.c
39685 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39686 int ret = 0;
39687 int t;
39688
39689 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39690 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39691 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39692 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39693
39694 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39695 if (ret)
39696 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39697 index 88f4096..e50452e 100644
39698 --- a/drivers/hv/hv.c
39699 +++ b/drivers/hv/hv.c
39700 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39701 u64 output_address = (output) ? virt_to_phys(output) : 0;
39702 u32 output_address_hi = output_address >> 32;
39703 u32 output_address_lo = output_address & 0xFFFFFFFF;
39704 - void *hypercall_page = hv_context.hypercall_page;
39705 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39706
39707 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39708 "=a"(hv_status_lo) : "d" (control_hi),
39709 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39710 index deb5c25..ed2d4fd 100644
39711 --- a/drivers/hv/hv_balloon.c
39712 +++ b/drivers/hv/hv_balloon.c
39713 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39714
39715 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39716 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39717 -static atomic_t trans_id = ATOMIC_INIT(0);
39718 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39719
39720 static int dm_ring_size = (5 * PAGE_SIZE);
39721
39722 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39723 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39724 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39725 resp.hdr.size = sizeof(struct dm_hot_add_response);
39726 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39727 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39728
39729 #ifdef CONFIG_MEMORY_HOTPLUG
39730 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39731 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39732 memset(&status, 0, sizeof(struct dm_status));
39733 status.hdr.type = DM_STATUS_REPORT;
39734 status.hdr.size = sizeof(struct dm_status);
39735 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39736 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39737
39738 /*
39739 * The host expects the guest to report free memory.
39740 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39741 * send the status. This can happen if we were interrupted
39742 * after we picked our transaction ID.
39743 */
39744 - if (status.hdr.trans_id != atomic_read(&trans_id))
39745 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39746 return;
39747
39748 vmbus_sendpacket(dm->dev->channel, &status,
39749 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39750 bl_resp = (struct dm_balloon_response *)send_buffer;
39751 memset(send_buffer, 0, PAGE_SIZE);
39752 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39753 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39754 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39755 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39756 bl_resp->more_pages = 1;
39757
39758 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39759
39760 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39761 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39762 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39763 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39764 resp.hdr.size = sizeof(struct dm_unballoon_response);
39765
39766 vmbus_sendpacket(dm_device.dev->channel, &resp,
39767 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39768 memset(&version_req, 0, sizeof(struct dm_version_request));
39769 version_req.hdr.type = DM_VERSION_REQUEST;
39770 version_req.hdr.size = sizeof(struct dm_version_request);
39771 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39772 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39773 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39774 version_req.is_last_attempt = 1;
39775
39776 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39777 memset(&version_req, 0, sizeof(struct dm_version_request));
39778 version_req.hdr.type = DM_VERSION_REQUEST;
39779 version_req.hdr.size = sizeof(struct dm_version_request);
39780 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39781 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39782 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39783 version_req.is_last_attempt = 0;
39784
39785 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39786 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39787 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39788 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39789 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39790 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39791
39792 cap_msg.caps.cap_bits.balloon = 1;
39793 cap_msg.caps.cap_bits.hot_add = 1;
39794 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39795 index d84918f..7f38f9f 100644
39796 --- a/drivers/hv/hyperv_vmbus.h
39797 +++ b/drivers/hv/hyperv_vmbus.h
39798 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39799 struct vmbus_connection {
39800 enum vmbus_connect_state conn_state;
39801
39802 - atomic_t next_gpadl_handle;
39803 + atomic_unchecked_t next_gpadl_handle;
39804
39805 /*
39806 * Represents channel interrupts. Each bit position represents a
39807 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39808 index e8e071f..5b4b245 100644
39809 --- a/drivers/hv/vmbus_drv.c
39810 +++ b/drivers/hv/vmbus_drv.c
39811 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39812 {
39813 int ret = 0;
39814
39815 - static atomic_t device_num = ATOMIC_INIT(0);
39816 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39817
39818 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39819 - atomic_inc_return(&device_num));
39820 + atomic_inc_return_unchecked(&device_num));
39821
39822 child_device_obj->device.bus = &hv_bus;
39823 child_device_obj->device.parent = &hv_acpi_dev->dev;
39824 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39825 index 6351aba..dc4aaf4 100644
39826 --- a/drivers/hwmon/acpi_power_meter.c
39827 +++ b/drivers/hwmon/acpi_power_meter.c
39828 @@ -117,7 +117,7 @@ struct sensor_template {
39829 struct device_attribute *devattr,
39830 const char *buf, size_t count);
39831 int index;
39832 -};
39833 +} __do_const;
39834
39835 /* Averaging interval */
39836 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39837 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39838 struct sensor_template *attrs)
39839 {
39840 struct device *dev = &resource->acpi_dev->dev;
39841 - struct sensor_device_attribute *sensors =
39842 + sensor_device_attribute_no_const *sensors =
39843 &resource->sensors[resource->num_sensors];
39844 int res = 0;
39845
39846 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39847 index 98814d1..9435d05 100644
39848 --- a/drivers/hwmon/applesmc.c
39849 +++ b/drivers/hwmon/applesmc.c
39850 @@ -1093,7 +1093,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39851 {
39852 struct applesmc_node_group *grp;
39853 struct applesmc_dev_attr *node;
39854 - struct attribute *attr;
39855 + attribute_no_const *attr;
39856 int ret, i;
39857
39858 for (grp = groups; grp->format; grp++) {
39859 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39860 index b25c643..a13460d 100644
39861 --- a/drivers/hwmon/asus_atk0110.c
39862 +++ b/drivers/hwmon/asus_atk0110.c
39863 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39864 struct atk_sensor_data {
39865 struct list_head list;
39866 struct atk_data *data;
39867 - struct device_attribute label_attr;
39868 - struct device_attribute input_attr;
39869 - struct device_attribute limit1_attr;
39870 - struct device_attribute limit2_attr;
39871 + device_attribute_no_const label_attr;
39872 + device_attribute_no_const input_attr;
39873 + device_attribute_no_const limit1_attr;
39874 + device_attribute_no_const limit2_attr;
39875 char label_attr_name[ATTR_NAME_SIZE];
39876 char input_attr_name[ATTR_NAME_SIZE];
39877 char limit1_attr_name[ATTR_NAME_SIZE];
39878 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39879 static struct device_attribute atk_name_attr =
39880 __ATTR(name, 0444, atk_name_show, NULL);
39881
39882 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39883 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39884 sysfs_show_func show)
39885 {
39886 sysfs_attr_init(&attr->attr);
39887 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39888 index 2e5e2dc..5208b31 100644
39889 --- a/drivers/hwmon/coretemp.c
39890 +++ b/drivers/hwmon/coretemp.c
39891 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39892 return NOTIFY_OK;
39893 }
39894
39895 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39896 +static struct notifier_block coretemp_cpu_notifier = {
39897 .notifier_call = coretemp_cpu_callback,
39898 };
39899
39900 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39901 index 1429f6e..ee03d59 100644
39902 --- a/drivers/hwmon/ibmaem.c
39903 +++ b/drivers/hwmon/ibmaem.c
39904 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39905 struct aem_rw_sensor_template *rw)
39906 {
39907 struct device *dev = &data->pdev->dev;
39908 - struct sensor_device_attribute *sensors = data->sensors;
39909 + sensor_device_attribute_no_const *sensors = data->sensors;
39910 int err;
39911
39912 /* Set up read-only sensors */
39913 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39914 index 708081b..fe2d4ab 100644
39915 --- a/drivers/hwmon/iio_hwmon.c
39916 +++ b/drivers/hwmon/iio_hwmon.c
39917 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39918 {
39919 struct device *dev = &pdev->dev;
39920 struct iio_hwmon_state *st;
39921 - struct sensor_device_attribute *a;
39922 + sensor_device_attribute_no_const *a;
39923 int ret, i;
39924 int in_i = 1, temp_i = 1, curr_i = 1;
39925 enum iio_chan_type type;
39926 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39927 index 9add6092..ee7ba3f 100644
39928 --- a/drivers/hwmon/pmbus/pmbus_core.c
39929 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39930 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39931 return 0;
39932 }
39933
39934 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39935 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39936 const char *name,
39937 umode_t mode,
39938 ssize_t (*show)(struct device *dev,
39939 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39940 dev_attr->store = store;
39941 }
39942
39943 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39944 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39945 const char *name,
39946 umode_t mode,
39947 ssize_t (*show)(struct device *dev,
39948 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39949 u16 reg, u8 mask)
39950 {
39951 struct pmbus_boolean *boolean;
39952 - struct sensor_device_attribute *a;
39953 + sensor_device_attribute_no_const *a;
39954
39955 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39956 if (!boolean)
39957 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39958 bool update, bool readonly)
39959 {
39960 struct pmbus_sensor *sensor;
39961 - struct device_attribute *a;
39962 + device_attribute_no_const *a;
39963
39964 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39965 if (!sensor)
39966 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39967 const char *lstring, int index)
39968 {
39969 struct pmbus_label *label;
39970 - struct device_attribute *a;
39971 + device_attribute_no_const *a;
39972
39973 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39974 if (!label)
39975 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39976 index 2507f90..1645765 100644
39977 --- a/drivers/hwmon/sht15.c
39978 +++ b/drivers/hwmon/sht15.c
39979 @@ -169,7 +169,7 @@ struct sht15_data {
39980 int supply_uv;
39981 bool supply_uv_valid;
39982 struct work_struct update_supply_work;
39983 - atomic_t interrupt_handled;
39984 + atomic_unchecked_t interrupt_handled;
39985 };
39986
39987 /**
39988 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39989 ret = gpio_direction_input(data->pdata->gpio_data);
39990 if (ret)
39991 return ret;
39992 - atomic_set(&data->interrupt_handled, 0);
39993 + atomic_set_unchecked(&data->interrupt_handled, 0);
39994
39995 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39996 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39997 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39998 /* Only relevant if the interrupt hasn't occurred. */
39999 - if (!atomic_read(&data->interrupt_handled))
40000 + if (!atomic_read_unchecked(&data->interrupt_handled))
40001 schedule_work(&data->read_work);
40002 }
40003 ret = wait_event_timeout(data->wait_queue,
40004 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40005
40006 /* First disable the interrupt */
40007 disable_irq_nosync(irq);
40008 - atomic_inc(&data->interrupt_handled);
40009 + atomic_inc_unchecked(&data->interrupt_handled);
40010 /* Then schedule a reading work struct */
40011 if (data->state != SHT15_READING_NOTHING)
40012 schedule_work(&data->read_work);
40013 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40014 * If not, then start the interrupt again - care here as could
40015 * have gone low in meantime so verify it hasn't!
40016 */
40017 - atomic_set(&data->interrupt_handled, 0);
40018 + atomic_set_unchecked(&data->interrupt_handled, 0);
40019 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40020 /* If still not occurred or another handler was scheduled */
40021 if (gpio_get_value(data->pdata->gpio_data)
40022 - || atomic_read(&data->interrupt_handled))
40023 + || atomic_read_unchecked(&data->interrupt_handled))
40024 return;
40025 }
40026
40027 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40028 index 38944e9..ae9e5ed 100644
40029 --- a/drivers/hwmon/via-cputemp.c
40030 +++ b/drivers/hwmon/via-cputemp.c
40031 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
40032 return NOTIFY_OK;
40033 }
40034
40035 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40036 +static struct notifier_block via_cputemp_cpu_notifier = {
40037 .notifier_call = via_cputemp_cpu_callback,
40038 };
40039
40040 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40041 index 07f01ac..d79ad3d 100644
40042 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40043 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40044 @@ -43,7 +43,7 @@
40045 extern struct i2c_adapter amd756_smbus;
40046
40047 static struct i2c_adapter *s4882_adapter;
40048 -static struct i2c_algorithm *s4882_algo;
40049 +static i2c_algorithm_no_const *s4882_algo;
40050
40051 /* Wrapper access functions for multiplexed SMBus */
40052 static DEFINE_MUTEX(amd756_lock);
40053 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40054 index 2ca268d..c6acbdf 100644
40055 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40056 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40057 @@ -41,7 +41,7 @@
40058 extern struct i2c_adapter *nforce2_smbus;
40059
40060 static struct i2c_adapter *s4985_adapter;
40061 -static struct i2c_algorithm *s4985_algo;
40062 +static i2c_algorithm_no_const *s4985_algo;
40063
40064 /* Wrapper access functions for multiplexed SMBus */
40065 static DEFINE_MUTEX(nforce2_lock);
40066 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40067 index c3ccdea..5b3dc1a 100644
40068 --- a/drivers/i2c/i2c-dev.c
40069 +++ b/drivers/i2c/i2c-dev.c
40070 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40071 break;
40072 }
40073
40074 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40075 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40076 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40077 if (IS_ERR(rdwr_pa[i].buf)) {
40078 res = PTR_ERR(rdwr_pa[i].buf);
40079 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40080 index 0b510ba..4fbb5085 100644
40081 --- a/drivers/ide/ide-cd.c
40082 +++ b/drivers/ide/ide-cd.c
40083 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40084 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40085 if ((unsigned long)buf & alignment
40086 || blk_rq_bytes(rq) & q->dma_pad_mask
40087 - || object_is_on_stack(buf))
40088 + || object_starts_on_stack(buf))
40089 drive->dma = 0;
40090 }
40091 }
40092 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40093 index e145931..08bfc59 100644
40094 --- a/drivers/iio/industrialio-core.c
40095 +++ b/drivers/iio/industrialio-core.c
40096 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40097 }
40098
40099 static
40100 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40101 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40102 const char *postfix,
40103 struct iio_chan_spec const *chan,
40104 ssize_t (*readfunc)(struct device *dev,
40105 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40106 index 784b97c..c9ceadf 100644
40107 --- a/drivers/infiniband/core/cm.c
40108 +++ b/drivers/infiniband/core/cm.c
40109 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40110
40111 struct cm_counter_group {
40112 struct kobject obj;
40113 - atomic_long_t counter[CM_ATTR_COUNT];
40114 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40115 };
40116
40117 struct cm_counter_attribute {
40118 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40119 struct ib_mad_send_buf *msg = NULL;
40120 int ret;
40121
40122 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40123 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40124 counter[CM_REQ_COUNTER]);
40125
40126 /* Quick state check to discard duplicate REQs. */
40127 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40128 if (!cm_id_priv)
40129 return;
40130
40131 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40132 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40133 counter[CM_REP_COUNTER]);
40134 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40135 if (ret)
40136 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40137 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40138 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40139 spin_unlock_irq(&cm_id_priv->lock);
40140 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40141 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40142 counter[CM_RTU_COUNTER]);
40143 goto out;
40144 }
40145 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40146 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40147 dreq_msg->local_comm_id);
40148 if (!cm_id_priv) {
40149 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40150 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40151 counter[CM_DREQ_COUNTER]);
40152 cm_issue_drep(work->port, work->mad_recv_wc);
40153 return -EINVAL;
40154 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40155 case IB_CM_MRA_REP_RCVD:
40156 break;
40157 case IB_CM_TIMEWAIT:
40158 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40159 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40160 counter[CM_DREQ_COUNTER]);
40161 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40162 goto unlock;
40163 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40164 cm_free_msg(msg);
40165 goto deref;
40166 case IB_CM_DREQ_RCVD:
40167 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40168 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40169 counter[CM_DREQ_COUNTER]);
40170 goto unlock;
40171 default:
40172 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40173 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40174 cm_id_priv->msg, timeout)) {
40175 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40176 - atomic_long_inc(&work->port->
40177 + atomic_long_inc_unchecked(&work->port->
40178 counter_group[CM_RECV_DUPLICATES].
40179 counter[CM_MRA_COUNTER]);
40180 goto out;
40181 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40182 break;
40183 case IB_CM_MRA_REQ_RCVD:
40184 case IB_CM_MRA_REP_RCVD:
40185 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40186 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40187 counter[CM_MRA_COUNTER]);
40188 /* fall through */
40189 default:
40190 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40191 case IB_CM_LAP_IDLE:
40192 break;
40193 case IB_CM_MRA_LAP_SENT:
40194 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40195 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40196 counter[CM_LAP_COUNTER]);
40197 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40198 goto unlock;
40199 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40200 cm_free_msg(msg);
40201 goto deref;
40202 case IB_CM_LAP_RCVD:
40203 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40204 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40205 counter[CM_LAP_COUNTER]);
40206 goto unlock;
40207 default:
40208 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40209 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40210 if (cur_cm_id_priv) {
40211 spin_unlock_irq(&cm.lock);
40212 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40213 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40214 counter[CM_SIDR_REQ_COUNTER]);
40215 goto out; /* Duplicate message. */
40216 }
40217 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40218 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40219 msg->retries = 1;
40220
40221 - atomic_long_add(1 + msg->retries,
40222 + atomic_long_add_unchecked(1 + msg->retries,
40223 &port->counter_group[CM_XMIT].counter[attr_index]);
40224 if (msg->retries)
40225 - atomic_long_add(msg->retries,
40226 + atomic_long_add_unchecked(msg->retries,
40227 &port->counter_group[CM_XMIT_RETRIES].
40228 counter[attr_index]);
40229
40230 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40231 }
40232
40233 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40234 - atomic_long_inc(&port->counter_group[CM_RECV].
40235 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40236 counter[attr_id - CM_ATTR_ID_OFFSET]);
40237
40238 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40239 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40240 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40241
40242 return sprintf(buf, "%ld\n",
40243 - atomic_long_read(&group->counter[cm_attr->index]));
40244 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40245 }
40246
40247 static const struct sysfs_ops cm_counter_ops = {
40248 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40249 index 9f5ad7c..588cd84 100644
40250 --- a/drivers/infiniband/core/fmr_pool.c
40251 +++ b/drivers/infiniband/core/fmr_pool.c
40252 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40253
40254 struct task_struct *thread;
40255
40256 - atomic_t req_ser;
40257 - atomic_t flush_ser;
40258 + atomic_unchecked_t req_ser;
40259 + atomic_unchecked_t flush_ser;
40260
40261 wait_queue_head_t force_wait;
40262 };
40263 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40264 struct ib_fmr_pool *pool = pool_ptr;
40265
40266 do {
40267 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40268 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40269 ib_fmr_batch_release(pool);
40270
40271 - atomic_inc(&pool->flush_ser);
40272 + atomic_inc_unchecked(&pool->flush_ser);
40273 wake_up_interruptible(&pool->force_wait);
40274
40275 if (pool->flush_function)
40276 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40277 }
40278
40279 set_current_state(TASK_INTERRUPTIBLE);
40280 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40281 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40282 !kthread_should_stop())
40283 schedule();
40284 __set_current_state(TASK_RUNNING);
40285 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40286 pool->dirty_watermark = params->dirty_watermark;
40287 pool->dirty_len = 0;
40288 spin_lock_init(&pool->pool_lock);
40289 - atomic_set(&pool->req_ser, 0);
40290 - atomic_set(&pool->flush_ser, 0);
40291 + atomic_set_unchecked(&pool->req_ser, 0);
40292 + atomic_set_unchecked(&pool->flush_ser, 0);
40293 init_waitqueue_head(&pool->force_wait);
40294
40295 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40296 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40297 }
40298 spin_unlock_irq(&pool->pool_lock);
40299
40300 - serial = atomic_inc_return(&pool->req_ser);
40301 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40302 wake_up_process(pool->thread);
40303
40304 if (wait_event_interruptible(pool->force_wait,
40305 - atomic_read(&pool->flush_ser) - serial >= 0))
40306 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40307 return -EINTR;
40308
40309 return 0;
40310 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40311 } else {
40312 list_add_tail(&fmr->list, &pool->dirty_list);
40313 if (++pool->dirty_len >= pool->dirty_watermark) {
40314 - atomic_inc(&pool->req_ser);
40315 + atomic_inc_unchecked(&pool->req_ser);
40316 wake_up_process(pool->thread);
40317 }
40318 }
40319 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40320 index 4cb8eb2..146bf60 100644
40321 --- a/drivers/infiniband/hw/cxgb4/mem.c
40322 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40323 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40324 int err;
40325 struct fw_ri_tpte tpt;
40326 u32 stag_idx;
40327 - static atomic_t key;
40328 + static atomic_unchecked_t key;
40329
40330 if (c4iw_fatal_error(rdev))
40331 return -EIO;
40332 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40333 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40334 rdev->stats.stag.max = rdev->stats.stag.cur;
40335 mutex_unlock(&rdev->stats.lock);
40336 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40337 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40338 }
40339 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40340 __func__, stag_state, type, pdid, stag_idx);
40341 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40342 index 79b3dbc..96e5fcc 100644
40343 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40344 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40345 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40346 struct ib_atomic_eth *ateth;
40347 struct ipath_ack_entry *e;
40348 u64 vaddr;
40349 - atomic64_t *maddr;
40350 + atomic64_unchecked_t *maddr;
40351 u64 sdata;
40352 u32 rkey;
40353 u8 next;
40354 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40355 IB_ACCESS_REMOTE_ATOMIC)))
40356 goto nack_acc_unlck;
40357 /* Perform atomic OP and save result. */
40358 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40359 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40360 sdata = be64_to_cpu(ateth->swap_data);
40361 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40362 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40363 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40364 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40365 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40366 be64_to_cpu(ateth->compare_data),
40367 sdata);
40368 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40369 index 1f95bba..9530f87 100644
40370 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40371 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40372 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40373 unsigned long flags;
40374 struct ib_wc wc;
40375 u64 sdata;
40376 - atomic64_t *maddr;
40377 + atomic64_unchecked_t *maddr;
40378 enum ib_wc_status send_status;
40379
40380 /*
40381 @@ -382,11 +382,11 @@ again:
40382 IB_ACCESS_REMOTE_ATOMIC)))
40383 goto acc_err;
40384 /* Perform atomic OP and save result. */
40385 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40386 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40387 sdata = wqe->wr.wr.atomic.compare_add;
40388 *(u64 *) sqp->s_sge.sge.vaddr =
40389 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40390 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40391 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40392 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40393 sdata, wqe->wr.wr.atomic.swap);
40394 goto send_comp;
40395 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40396 index f2a3f48..673ec79 100644
40397 --- a/drivers/infiniband/hw/mlx4/mad.c
40398 +++ b/drivers/infiniband/hw/mlx4/mad.c
40399 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40400
40401 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40402 {
40403 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40404 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40405 cpu_to_be64(0xff00000000000000LL);
40406 }
40407
40408 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40409 index 25b2cdf..099ff97 100644
40410 --- a/drivers/infiniband/hw/mlx4/mcg.c
40411 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40412 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40413 {
40414 char name[20];
40415
40416 - atomic_set(&ctx->tid, 0);
40417 + atomic_set_unchecked(&ctx->tid, 0);
40418 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40419 ctx->mcg_wq = create_singlethread_workqueue(name);
40420 if (!ctx->mcg_wq)
40421 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40422 index f61ec26..ebf72cf 100644
40423 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40424 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40425 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40426 struct list_head mcg_mgid0_list;
40427 struct workqueue_struct *mcg_wq;
40428 struct mlx4_ib_demux_pv_ctx **tun;
40429 - atomic_t tid;
40430 + atomic_unchecked_t tid;
40431 int flushing; /* flushing the work queue */
40432 };
40433
40434 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40435 index 9d3e5c1..d9afe4a 100644
40436 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40437 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40438 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40439 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40440 }
40441
40442 -int mthca_QUERY_FW(struct mthca_dev *dev)
40443 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40444 {
40445 struct mthca_mailbox *mailbox;
40446 u32 *outbox;
40447 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40448 index ed9a989..e0c5871 100644
40449 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40450 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40451 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40452 return key;
40453 }
40454
40455 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40456 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40457 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40458 {
40459 struct mthca_mailbox *mailbox;
40460 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40461 index 4291410..d2ab1fb 100644
40462 --- a/drivers/infiniband/hw/nes/nes.c
40463 +++ b/drivers/infiniband/hw/nes/nes.c
40464 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40465 LIST_HEAD(nes_adapter_list);
40466 static LIST_HEAD(nes_dev_list);
40467
40468 -atomic_t qps_destroyed;
40469 +atomic_unchecked_t qps_destroyed;
40470
40471 static unsigned int ee_flsh_adapter;
40472 static unsigned int sysfs_nonidx_addr;
40473 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40474 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40475 struct nes_adapter *nesadapter = nesdev->nesadapter;
40476
40477 - atomic_inc(&qps_destroyed);
40478 + atomic_inc_unchecked(&qps_destroyed);
40479
40480 /* Free the control structures */
40481
40482 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40483 index 33cc589..3bd6538 100644
40484 --- a/drivers/infiniband/hw/nes/nes.h
40485 +++ b/drivers/infiniband/hw/nes/nes.h
40486 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40487 extern unsigned int wqm_quanta;
40488 extern struct list_head nes_adapter_list;
40489
40490 -extern atomic_t cm_connects;
40491 -extern atomic_t cm_accepts;
40492 -extern atomic_t cm_disconnects;
40493 -extern atomic_t cm_closes;
40494 -extern atomic_t cm_connecteds;
40495 -extern atomic_t cm_connect_reqs;
40496 -extern atomic_t cm_rejects;
40497 -extern atomic_t mod_qp_timouts;
40498 -extern atomic_t qps_created;
40499 -extern atomic_t qps_destroyed;
40500 -extern atomic_t sw_qps_destroyed;
40501 +extern atomic_unchecked_t cm_connects;
40502 +extern atomic_unchecked_t cm_accepts;
40503 +extern atomic_unchecked_t cm_disconnects;
40504 +extern atomic_unchecked_t cm_closes;
40505 +extern atomic_unchecked_t cm_connecteds;
40506 +extern atomic_unchecked_t cm_connect_reqs;
40507 +extern atomic_unchecked_t cm_rejects;
40508 +extern atomic_unchecked_t mod_qp_timouts;
40509 +extern atomic_unchecked_t qps_created;
40510 +extern atomic_unchecked_t qps_destroyed;
40511 +extern atomic_unchecked_t sw_qps_destroyed;
40512 extern u32 mh_detected;
40513 extern u32 mh_pauses_sent;
40514 extern u32 cm_packets_sent;
40515 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40516 extern u32 cm_packets_received;
40517 extern u32 cm_packets_dropped;
40518 extern u32 cm_packets_retrans;
40519 -extern atomic_t cm_listens_created;
40520 -extern atomic_t cm_listens_destroyed;
40521 +extern atomic_unchecked_t cm_listens_created;
40522 +extern atomic_unchecked_t cm_listens_destroyed;
40523 extern u32 cm_backlog_drops;
40524 -extern atomic_t cm_loopbacks;
40525 -extern atomic_t cm_nodes_created;
40526 -extern atomic_t cm_nodes_destroyed;
40527 -extern atomic_t cm_accel_dropped_pkts;
40528 -extern atomic_t cm_resets_recvd;
40529 -extern atomic_t pau_qps_created;
40530 -extern atomic_t pau_qps_destroyed;
40531 +extern atomic_unchecked_t cm_loopbacks;
40532 +extern atomic_unchecked_t cm_nodes_created;
40533 +extern atomic_unchecked_t cm_nodes_destroyed;
40534 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40535 +extern atomic_unchecked_t cm_resets_recvd;
40536 +extern atomic_unchecked_t pau_qps_created;
40537 +extern atomic_unchecked_t pau_qps_destroyed;
40538
40539 extern u32 int_mod_timer_init;
40540 extern u32 int_mod_cq_depth_256;
40541 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40542 index 24b9f1a..00fd004 100644
40543 --- a/drivers/infiniband/hw/nes/nes_cm.c
40544 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40545 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40546 u32 cm_packets_retrans;
40547 u32 cm_packets_created;
40548 u32 cm_packets_received;
40549 -atomic_t cm_listens_created;
40550 -atomic_t cm_listens_destroyed;
40551 +atomic_unchecked_t cm_listens_created;
40552 +atomic_unchecked_t cm_listens_destroyed;
40553 u32 cm_backlog_drops;
40554 -atomic_t cm_loopbacks;
40555 -atomic_t cm_nodes_created;
40556 -atomic_t cm_nodes_destroyed;
40557 -atomic_t cm_accel_dropped_pkts;
40558 -atomic_t cm_resets_recvd;
40559 +atomic_unchecked_t cm_loopbacks;
40560 +atomic_unchecked_t cm_nodes_created;
40561 +atomic_unchecked_t cm_nodes_destroyed;
40562 +atomic_unchecked_t cm_accel_dropped_pkts;
40563 +atomic_unchecked_t cm_resets_recvd;
40564
40565 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40566 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40567 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40568
40569 static struct nes_cm_core *g_cm_core;
40570
40571 -atomic_t cm_connects;
40572 -atomic_t cm_accepts;
40573 -atomic_t cm_disconnects;
40574 -atomic_t cm_closes;
40575 -atomic_t cm_connecteds;
40576 -atomic_t cm_connect_reqs;
40577 -atomic_t cm_rejects;
40578 +atomic_unchecked_t cm_connects;
40579 +atomic_unchecked_t cm_accepts;
40580 +atomic_unchecked_t cm_disconnects;
40581 +atomic_unchecked_t cm_closes;
40582 +atomic_unchecked_t cm_connecteds;
40583 +atomic_unchecked_t cm_connect_reqs;
40584 +atomic_unchecked_t cm_rejects;
40585
40586 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40587 {
40588 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40589 kfree(listener);
40590 listener = NULL;
40591 ret = 0;
40592 - atomic_inc(&cm_listens_destroyed);
40593 + atomic_inc_unchecked(&cm_listens_destroyed);
40594 } else {
40595 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40596 }
40597 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40598 cm_node->rem_mac);
40599
40600 add_hte_node(cm_core, cm_node);
40601 - atomic_inc(&cm_nodes_created);
40602 + atomic_inc_unchecked(&cm_nodes_created);
40603
40604 return cm_node;
40605 }
40606 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40607 }
40608
40609 atomic_dec(&cm_core->node_cnt);
40610 - atomic_inc(&cm_nodes_destroyed);
40611 + atomic_inc_unchecked(&cm_nodes_destroyed);
40612 nesqp = cm_node->nesqp;
40613 if (nesqp) {
40614 nesqp->cm_node = NULL;
40615 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40616
40617 static void drop_packet(struct sk_buff *skb)
40618 {
40619 - atomic_inc(&cm_accel_dropped_pkts);
40620 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40621 dev_kfree_skb_any(skb);
40622 }
40623
40624 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40625 {
40626
40627 int reset = 0; /* whether to send reset in case of err.. */
40628 - atomic_inc(&cm_resets_recvd);
40629 + atomic_inc_unchecked(&cm_resets_recvd);
40630 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40631 " refcnt=%d\n", cm_node, cm_node->state,
40632 atomic_read(&cm_node->ref_count));
40633 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40634 rem_ref_cm_node(cm_node->cm_core, cm_node);
40635 return NULL;
40636 }
40637 - atomic_inc(&cm_loopbacks);
40638 + atomic_inc_unchecked(&cm_loopbacks);
40639 loopbackremotenode->loopbackpartner = cm_node;
40640 loopbackremotenode->tcp_cntxt.rcv_wscale =
40641 NES_CM_DEFAULT_RCV_WND_SCALE;
40642 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40643 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40644 else {
40645 rem_ref_cm_node(cm_core, cm_node);
40646 - atomic_inc(&cm_accel_dropped_pkts);
40647 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40648 dev_kfree_skb_any(skb);
40649 }
40650 break;
40651 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40652
40653 if ((cm_id) && (cm_id->event_handler)) {
40654 if (issue_disconn) {
40655 - atomic_inc(&cm_disconnects);
40656 + atomic_inc_unchecked(&cm_disconnects);
40657 cm_event.event = IW_CM_EVENT_DISCONNECT;
40658 cm_event.status = disconn_status;
40659 cm_event.local_addr = cm_id->local_addr;
40660 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40661 }
40662
40663 if (issue_close) {
40664 - atomic_inc(&cm_closes);
40665 + atomic_inc_unchecked(&cm_closes);
40666 nes_disconnect(nesqp, 1);
40667
40668 cm_id->provider_data = nesqp;
40669 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40670
40671 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40672 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40673 - atomic_inc(&cm_accepts);
40674 + atomic_inc_unchecked(&cm_accepts);
40675
40676 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40677 netdev_refcnt_read(nesvnic->netdev));
40678 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40679 struct nes_cm_core *cm_core;
40680 u8 *start_buff;
40681
40682 - atomic_inc(&cm_rejects);
40683 + atomic_inc_unchecked(&cm_rejects);
40684 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40685 loopback = cm_node->loopbackpartner;
40686 cm_core = cm_node->cm_core;
40687 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40688 ntohl(cm_id->local_addr.sin_addr.s_addr),
40689 ntohs(cm_id->local_addr.sin_port));
40690
40691 - atomic_inc(&cm_connects);
40692 + atomic_inc_unchecked(&cm_connects);
40693 nesqp->active_conn = 1;
40694
40695 /* cache the cm_id in the qp */
40696 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40697 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40698 return err;
40699 }
40700 - atomic_inc(&cm_listens_created);
40701 + atomic_inc_unchecked(&cm_listens_created);
40702 }
40703
40704 cm_id->add_ref(cm_id);
40705 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40706
40707 if (nesqp->destroyed)
40708 return;
40709 - atomic_inc(&cm_connecteds);
40710 + atomic_inc_unchecked(&cm_connecteds);
40711 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40712 " local port 0x%04X. jiffies = %lu.\n",
40713 nesqp->hwqp.qp_id,
40714 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40715
40716 cm_id->add_ref(cm_id);
40717 ret = cm_id->event_handler(cm_id, &cm_event);
40718 - atomic_inc(&cm_closes);
40719 + atomic_inc_unchecked(&cm_closes);
40720 cm_event.event = IW_CM_EVENT_CLOSE;
40721 cm_event.status = 0;
40722 cm_event.provider_data = cm_id->provider_data;
40723 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40724 return;
40725 cm_id = cm_node->cm_id;
40726
40727 - atomic_inc(&cm_connect_reqs);
40728 + atomic_inc_unchecked(&cm_connect_reqs);
40729 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40730 cm_node, cm_id, jiffies);
40731
40732 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40733 return;
40734 cm_id = cm_node->cm_id;
40735
40736 - atomic_inc(&cm_connect_reqs);
40737 + atomic_inc_unchecked(&cm_connect_reqs);
40738 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40739 cm_node, cm_id, jiffies);
40740
40741 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40742 index 4166452..fc952c3 100644
40743 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40744 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40745 @@ -40,8 +40,8 @@
40746 #include "nes.h"
40747 #include "nes_mgt.h"
40748
40749 -atomic_t pau_qps_created;
40750 -atomic_t pau_qps_destroyed;
40751 +atomic_unchecked_t pau_qps_created;
40752 +atomic_unchecked_t pau_qps_destroyed;
40753
40754 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40755 {
40756 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40757 {
40758 struct sk_buff *skb;
40759 unsigned long flags;
40760 - atomic_inc(&pau_qps_destroyed);
40761 + atomic_inc_unchecked(&pau_qps_destroyed);
40762
40763 /* Free packets that have not yet been forwarded */
40764 /* Lock is acquired by skb_dequeue when removing the skb */
40765 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40766 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40767 skb_queue_head_init(&nesqp->pau_list);
40768 spin_lock_init(&nesqp->pau_lock);
40769 - atomic_inc(&pau_qps_created);
40770 + atomic_inc_unchecked(&pau_qps_created);
40771 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40772 }
40773
40774 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40775 index 49eb511..a774366 100644
40776 --- a/drivers/infiniband/hw/nes/nes_nic.c
40777 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40778 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40779 target_stat_values[++index] = mh_detected;
40780 target_stat_values[++index] = mh_pauses_sent;
40781 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40782 - target_stat_values[++index] = atomic_read(&cm_connects);
40783 - target_stat_values[++index] = atomic_read(&cm_accepts);
40784 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40785 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40786 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40787 - target_stat_values[++index] = atomic_read(&cm_rejects);
40788 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40789 - target_stat_values[++index] = atomic_read(&qps_created);
40790 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40791 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40792 - target_stat_values[++index] = atomic_read(&cm_closes);
40793 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40794 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40795 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40796 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40797 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40798 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40799 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40800 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40801 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40802 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40803 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40804 target_stat_values[++index] = cm_packets_sent;
40805 target_stat_values[++index] = cm_packets_bounced;
40806 target_stat_values[++index] = cm_packets_created;
40807 target_stat_values[++index] = cm_packets_received;
40808 target_stat_values[++index] = cm_packets_dropped;
40809 target_stat_values[++index] = cm_packets_retrans;
40810 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40811 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40812 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40813 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40814 target_stat_values[++index] = cm_backlog_drops;
40815 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40816 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40817 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40818 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40819 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40820 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40821 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40822 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40823 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40824 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40825 target_stat_values[++index] = nesadapter->free_4kpbl;
40826 target_stat_values[++index] = nesadapter->free_256pbl;
40827 target_stat_values[++index] = int_mod_timer_init;
40828 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40829 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40830 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40831 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40832 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40833 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40834 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40835 }
40836
40837 /**
40838 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40839 index 5b53ca5..443da3c 100644
40840 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40841 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40842 @@ -46,9 +46,9 @@
40843
40844 #include <rdma/ib_umem.h>
40845
40846 -atomic_t mod_qp_timouts;
40847 -atomic_t qps_created;
40848 -atomic_t sw_qps_destroyed;
40849 +atomic_unchecked_t mod_qp_timouts;
40850 +atomic_unchecked_t qps_created;
40851 +atomic_unchecked_t sw_qps_destroyed;
40852
40853 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40854
40855 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40856 if (init_attr->create_flags)
40857 return ERR_PTR(-EINVAL);
40858
40859 - atomic_inc(&qps_created);
40860 + atomic_inc_unchecked(&qps_created);
40861 switch (init_attr->qp_type) {
40862 case IB_QPT_RC:
40863 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40864 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40865 struct iw_cm_event cm_event;
40866 int ret = 0;
40867
40868 - atomic_inc(&sw_qps_destroyed);
40869 + atomic_inc_unchecked(&sw_qps_destroyed);
40870 nesqp->destroyed = 1;
40871
40872 /* Blow away the connection if it exists. */
40873 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40874 index 4a9af79..b993f75 100644
40875 --- a/drivers/infiniband/hw/qib/qib.h
40876 +++ b/drivers/infiniband/hw/qib/qib.h
40877 @@ -52,6 +52,7 @@
40878 #include <linux/kref.h>
40879 #include <linux/sched.h>
40880 #include <linux/kthread.h>
40881 +#include <linux/slab.h>
40882
40883 #include "qib_common.h"
40884 #include "qib_verbs.h"
40885 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40886 index da739d9..da1c7f4 100644
40887 --- a/drivers/input/gameport/gameport.c
40888 +++ b/drivers/input/gameport/gameport.c
40889 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40890 */
40891 static void gameport_init_port(struct gameport *gameport)
40892 {
40893 - static atomic_t gameport_no = ATOMIC_INIT(0);
40894 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40895
40896 __module_get(THIS_MODULE);
40897
40898 mutex_init(&gameport->drv_mutex);
40899 device_initialize(&gameport->dev);
40900 dev_set_name(&gameport->dev, "gameport%lu",
40901 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40902 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40903 gameport->dev.bus = &gameport_bus;
40904 gameport->dev.release = gameport_release_port;
40905 if (gameport->parent)
40906 diff --git a/drivers/input/input.c b/drivers/input/input.c
40907 index c044699..174d71a 100644
40908 --- a/drivers/input/input.c
40909 +++ b/drivers/input/input.c
40910 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
40911 */
40912 int input_register_device(struct input_dev *dev)
40913 {
40914 - static atomic_t input_no = ATOMIC_INIT(0);
40915 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40916 struct input_devres *devres = NULL;
40917 struct input_handler *handler;
40918 unsigned int packet_size;
40919 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
40920 dev->setkeycode = input_default_setkeycode;
40921
40922 dev_set_name(&dev->dev, "input%ld",
40923 - (unsigned long) atomic_inc_return(&input_no) - 1);
40924 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40925
40926 error = device_add(&dev->dev);
40927 if (error)
40928 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40929 index 04c69af..5f92d00 100644
40930 --- a/drivers/input/joystick/sidewinder.c
40931 +++ b/drivers/input/joystick/sidewinder.c
40932 @@ -30,6 +30,7 @@
40933 #include <linux/kernel.h>
40934 #include <linux/module.h>
40935 #include <linux/slab.h>
40936 +#include <linux/sched.h>
40937 #include <linux/init.h>
40938 #include <linux/input.h>
40939 #include <linux/gameport.h>
40940 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40941 index 75e3b10..fb390fd 100644
40942 --- a/drivers/input/joystick/xpad.c
40943 +++ b/drivers/input/joystick/xpad.c
40944 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40945
40946 static int xpad_led_probe(struct usb_xpad *xpad)
40947 {
40948 - static atomic_t led_seq = ATOMIC_INIT(0);
40949 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40950 long led_no;
40951 struct xpad_led *led;
40952 struct led_classdev *led_cdev;
40953 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40954 if (!led)
40955 return -ENOMEM;
40956
40957 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40958 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40959
40960 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40961 led->xpad = xpad;
40962 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40963 index e204f26..8459f15 100644
40964 --- a/drivers/input/misc/ims-pcu.c
40965 +++ b/drivers/input/misc/ims-pcu.c
40966 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40967
40968 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40969 {
40970 - static atomic_t device_no = ATOMIC_INIT(0);
40971 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40972
40973 const struct ims_pcu_device_info *info;
40974 u8 device_id;
40975 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40976 }
40977
40978 /* Device appears to be operable, complete initialization */
40979 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40980 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40981
40982 error = ims_pcu_setup_backlight(pcu);
40983 if (error)
40984 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40985 index 2f0b39d..7370f13 100644
40986 --- a/drivers/input/mouse/psmouse.h
40987 +++ b/drivers/input/mouse/psmouse.h
40988 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40989 ssize_t (*set)(struct psmouse *psmouse, void *data,
40990 const char *buf, size_t count);
40991 bool protect;
40992 -};
40993 +} __do_const;
40994 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40995
40996 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40997 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40998 index 4c842c3..590b0bf 100644
40999 --- a/drivers/input/mousedev.c
41000 +++ b/drivers/input/mousedev.c
41001 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41002
41003 spin_unlock_irq(&client->packet_lock);
41004
41005 - if (copy_to_user(buffer, data, count))
41006 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41007 return -EFAULT;
41008
41009 return count;
41010 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41011 index 25fc597..558bf3b3 100644
41012 --- a/drivers/input/serio/serio.c
41013 +++ b/drivers/input/serio/serio.c
41014 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41015 */
41016 static void serio_init_port(struct serio *serio)
41017 {
41018 - static atomic_t serio_no = ATOMIC_INIT(0);
41019 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41020
41021 __module_get(THIS_MODULE);
41022
41023 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41024 mutex_init(&serio->drv_mutex);
41025 device_initialize(&serio->dev);
41026 dev_set_name(&serio->dev, "serio%ld",
41027 - (long)atomic_inc_return(&serio_no) - 1);
41028 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41029 serio->dev.bus = &serio_bus;
41030 serio->dev.release = serio_release_port;
41031 serio->dev.groups = serio_device_attr_groups;
41032 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41033 index 59df2e7..8f1cafb 100644
41034 --- a/drivers/input/serio/serio_raw.c
41035 +++ b/drivers/input/serio/serio_raw.c
41036 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41037
41038 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41039 {
41040 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41041 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41042 struct serio_raw *serio_raw;
41043 int err;
41044
41045 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41046 }
41047
41048 snprintf(serio_raw->name, sizeof(serio_raw->name),
41049 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41050 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41051 kref_init(&serio_raw->kref);
41052 INIT_LIST_HEAD(&serio_raw->client_list);
41053 init_waitqueue_head(&serio_raw->wait);
41054 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41055 index fbe9ca7..dbee61d 100644
41056 --- a/drivers/iommu/iommu.c
41057 +++ b/drivers/iommu/iommu.c
41058 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41059 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41060 {
41061 bus_register_notifier(bus, &iommu_bus_nb);
41062 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41063 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41064 }
41065
41066 /**
41067 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41068 index 39f81ae..2660096 100644
41069 --- a/drivers/iommu/irq_remapping.c
41070 +++ b/drivers/iommu/irq_remapping.c
41071 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41072 void panic_if_irq_remap(const char *msg)
41073 {
41074 if (irq_remapping_enabled)
41075 - panic(msg);
41076 + panic("%s", msg);
41077 }
41078
41079 static void ir_ack_apic_edge(struct irq_data *data)
41080 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41081
41082 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41083 {
41084 - chip->irq_print_chip = ir_print_prefix;
41085 - chip->irq_ack = ir_ack_apic_edge;
41086 - chip->irq_eoi = ir_ack_apic_level;
41087 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41088 + pax_open_kernel();
41089 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41090 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41091 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41092 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41093 + pax_close_kernel();
41094 }
41095
41096 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41097 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41098 index ee7c503..5d4ce08 100644
41099 --- a/drivers/irqchip/irq-gic.c
41100 +++ b/drivers/irqchip/irq-gic.c
41101 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41102 * Supported arch specific GIC irq extension.
41103 * Default make them NULL.
41104 */
41105 -struct irq_chip gic_arch_extn = {
41106 +irq_chip_no_const gic_arch_extn = {
41107 .irq_eoi = NULL,
41108 .irq_mask = NULL,
41109 .irq_unmask = NULL,
41110 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41111 chained_irq_exit(chip, desc);
41112 }
41113
41114 -static struct irq_chip gic_chip = {
41115 +static irq_chip_no_const gic_chip __read_only = {
41116 .name = "GIC",
41117 .irq_mask = gic_mask_irq,
41118 .irq_unmask = gic_unmask_irq,
41119 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41120 index ac6f72b..81150f2 100644
41121 --- a/drivers/isdn/capi/capi.c
41122 +++ b/drivers/isdn/capi/capi.c
41123 @@ -81,8 +81,8 @@ struct capiminor {
41124
41125 struct capi20_appl *ap;
41126 u32 ncci;
41127 - atomic_t datahandle;
41128 - atomic_t msgid;
41129 + atomic_unchecked_t datahandle;
41130 + atomic_unchecked_t msgid;
41131
41132 struct tty_port port;
41133 int ttyinstop;
41134 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41135 capimsg_setu16(s, 2, mp->ap->applid);
41136 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41137 capimsg_setu8 (s, 5, CAPI_RESP);
41138 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41139 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41140 capimsg_setu32(s, 8, mp->ncci);
41141 capimsg_setu16(s, 12, datahandle);
41142 }
41143 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41144 mp->outbytes -= len;
41145 spin_unlock_bh(&mp->outlock);
41146
41147 - datahandle = atomic_inc_return(&mp->datahandle);
41148 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41149 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41150 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41151 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41152 capimsg_setu16(skb->data, 2, mp->ap->applid);
41153 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41154 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41155 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41156 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41157 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41158 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41159 capimsg_setu16(skb->data, 16, len); /* Data length */
41160 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41161 index 600c79b..3752bab 100644
41162 --- a/drivers/isdn/gigaset/interface.c
41163 +++ b/drivers/isdn/gigaset/interface.c
41164 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41165 }
41166 tty->driver_data = cs;
41167
41168 - ++cs->port.count;
41169 + atomic_inc(&cs->port.count);
41170
41171 - if (cs->port.count == 1) {
41172 + if (atomic_read(&cs->port.count) == 1) {
41173 tty_port_tty_set(&cs->port, tty);
41174 cs->port.low_latency = 1;
41175 }
41176 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41177
41178 if (!cs->connected)
41179 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41180 - else if (!cs->port.count)
41181 + else if (!atomic_read(&cs->port.count))
41182 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41183 - else if (!--cs->port.count)
41184 + else if (!atomic_dec_return(&cs->port.count))
41185 tty_port_tty_set(&cs->port, NULL);
41186
41187 mutex_unlock(&cs->mutex);
41188 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41189 index d0a41cb..f0cdb8c 100644
41190 --- a/drivers/isdn/gigaset/usb-gigaset.c
41191 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41192 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41193 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41194 memcpy(cs->hw.usb->bchars, buf, 6);
41195 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41196 - 0, 0, &buf, 6, 2000);
41197 + 0, 0, buf, 6, 2000);
41198 }
41199
41200 static void gigaset_freebcshw(struct bc_state *bcs)
41201 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41202 index 4d9b195..455075c 100644
41203 --- a/drivers/isdn/hardware/avm/b1.c
41204 +++ b/drivers/isdn/hardware/avm/b1.c
41205 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41206 }
41207 if (left) {
41208 if (t4file->user) {
41209 - if (copy_from_user(buf, dp, left))
41210 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41211 return -EFAULT;
41212 } else {
41213 memcpy(buf, dp, left);
41214 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41215 }
41216 if (left) {
41217 if (config->user) {
41218 - if (copy_from_user(buf, dp, left))
41219 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41220 return -EFAULT;
41221 } else {
41222 memcpy(buf, dp, left);
41223 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
41224 index 1063bab..36817e0 100644
41225 --- a/drivers/isdn/hisax/amd7930_fn.c
41226 +++ b/drivers/isdn/hisax/amd7930_fn.c
41227 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41228
41229 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41230 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41231 - debugl1(cs, cs->dlog);
41232 + debugl1(cs, "%s", cs->dlog);
41233 }
41234 /* moves received data in sk-buffer */
41235 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41236 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41237
41238 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41239 QuickHex(t, deb_ptr, count);
41240 - debugl1(cs, cs->dlog);
41241 + debugl1(cs, "%s", cs->dlog);
41242 }
41243 /* AMD interrupts on */
41244 AmdIrqOn(cs);
41245 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41246 index ee9b9a0..d1427bd 100644
41247 --- a/drivers/isdn/hisax/avm_pci.c
41248 +++ b/drivers/isdn/hisax/avm_pci.c
41249 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41250 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41251 bcs->channel ? 'B' : 'A', count);
41252 QuickHex(t, p, count);
41253 - debugl1(cs, bcs->blog);
41254 + debugl1(cs, "%s", bcs->blog);
41255 }
41256 }
41257
41258 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41259 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41260 bcs->channel ? 'B' : 'A', count);
41261 QuickHex(t, p, count);
41262 - debugl1(cs, bcs->blog);
41263 + debugl1(cs, "%s", bcs->blog);
41264 }
41265 }
41266
41267 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41268 index bf04d2a..b33f53b 100644
41269 --- a/drivers/isdn/hisax/config.c
41270 +++ b/drivers/isdn/hisax/config.c
41271 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41272 ptr--;
41273 *ptr++ = '\n';
41274 *ptr = 0;
41275 - HiSax_putstatus(cs, NULL, cs->dlog);
41276 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41277 } else
41278 HiSax_putstatus(cs, "LogEcho: ",
41279 "warning Frame too big (%d)",
41280 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41281 index 8d0cf6e..4fc90de 100644
41282 --- a/drivers/isdn/hisax/diva.c
41283 +++ b/drivers/isdn/hisax/diva.c
41284 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41285 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41286 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41287 QuickHex(t, ptr, count);
41288 - debugl1(cs, bcs->blog);
41289 + debugl1(cs, "%s", bcs->blog);
41290 }
41291 }
41292
41293 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41294 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41295 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41296 QuickHex(t, ptr, count);
41297 - debugl1(cs, bcs->blog);
41298 + debugl1(cs, "%s", bcs->blog);
41299 }
41300 }
41301
41302 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41303 index 1df6f9a..2be1c8a 100644
41304 --- a/drivers/isdn/hisax/elsa.c
41305 +++ b/drivers/isdn/hisax/elsa.c
41306 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41307 t = tmp;
41308 t += sprintf(tmp, "Arcofi data");
41309 QuickHex(t, p, cs->dc.isac.mon_rxp);
41310 - debugl1(cs, tmp);
41311 + debugl1(cs, "%s", tmp);
41312 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41313 switch (cs->dc.isac.mon_rx[1]) {
41314 case 0x80:
41315 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41316 index d4c98d3..3f84dd8 100644
41317 --- a/drivers/isdn/hisax/elsa_ser.c
41318 +++ b/drivers/isdn/hisax/elsa_ser.c
41319 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41320
41321 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41322 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41323 - debugl1(cs, tmp);
41324 + debugl1(cs, "%s", tmp);
41325 }
41326 cs->hw.elsa.rcvcnt = 0;
41327 }
41328 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41329 index 3ccd724..497bd02 100644
41330 --- a/drivers/isdn/hisax/hfc_pci.c
41331 +++ b/drivers/isdn/hisax/hfc_pci.c
41332 @@ -901,7 +901,7 @@ Begin:
41333 ptr--;
41334 *ptr++ = '\n';
41335 *ptr = 0;
41336 - HiSax_putstatus(cs, NULL, cs->dlog);
41337 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41338 } else
41339 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41340 }
41341 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41342 index dc4574f..fa1fefd 100644
41343 --- a/drivers/isdn/hisax/hfc_sx.c
41344 +++ b/drivers/isdn/hisax/hfc_sx.c
41345 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41346 ptr--;
41347 *ptr++ = '\n';
41348 *ptr = 0;
41349 - HiSax_putstatus(cs, NULL, cs->dlog);
41350 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41351 } else
41352 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41353 }
41354 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41355 index f398d48..a8d6188 100644
41356 --- a/drivers/isdn/hisax/hscx_irq.c
41357 +++ b/drivers/isdn/hisax/hscx_irq.c
41358 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41359 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41360 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41361 QuickHex(t, ptr, count);
41362 - debugl1(cs, bcs->blog);
41363 + debugl1(cs, "%s", bcs->blog);
41364 }
41365 }
41366
41367 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41368 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41369 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41370 QuickHex(t, ptr, count);
41371 - debugl1(cs, bcs->blog);
41372 + debugl1(cs, "%s", bcs->blog);
41373 }
41374 }
41375
41376 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41377 index db5321f..51dae91 100644
41378 --- a/drivers/isdn/hisax/icc.c
41379 +++ b/drivers/isdn/hisax/icc.c
41380 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41381
41382 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41383 QuickHex(t, ptr, count);
41384 - debugl1(cs, cs->dlog);
41385 + debugl1(cs, "%s", cs->dlog);
41386 }
41387 }
41388
41389 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41390
41391 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41392 QuickHex(t, ptr, count);
41393 - debugl1(cs, cs->dlog);
41394 + debugl1(cs, "%s", cs->dlog);
41395 }
41396 }
41397
41398 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41399 index 74feb5c..5faa5de 100644
41400 --- a/drivers/isdn/hisax/ipacx.c
41401 +++ b/drivers/isdn/hisax/ipacx.c
41402 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41403
41404 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41405 QuickHex(t, ptr, count);
41406 - debugl1(cs, cs->dlog);
41407 + debugl1(cs, "%s", cs->dlog);
41408 }
41409 }
41410
41411 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41412
41413 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41414 QuickHex(t, ptr, count);
41415 - debugl1(cs, cs->dlog);
41416 + debugl1(cs, "%s", cs->dlog);
41417 }
41418 }
41419
41420 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41421
41422 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41423 QuickHex(t, ptr, count);
41424 - debugl1(cs, bcs->blog);
41425 + debugl1(cs, "%s", bcs->blog);
41426 }
41427 }
41428
41429 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41430
41431 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41432 QuickHex(t, ptr, count);
41433 - debugl1(cs, bcs->blog);
41434 + debugl1(cs, "%s", bcs->blog);
41435 }
41436 }
41437
41438 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41439 index a365ccc..7fdf78f 100644
41440 --- a/drivers/isdn/hisax/isac.c
41441 +++ b/drivers/isdn/hisax/isac.c
41442 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41443
41444 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41445 QuickHex(t, ptr, count);
41446 - debugl1(cs, cs->dlog);
41447 + debugl1(cs, "%s", cs->dlog);
41448 }
41449 }
41450
41451 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41452
41453 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41454 QuickHex(t, ptr, count);
41455 - debugl1(cs, cs->dlog);
41456 + debugl1(cs, "%s", cs->dlog);
41457 }
41458 }
41459
41460 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41461 index 7fdf347..f4956c7 100644
41462 --- a/drivers/isdn/hisax/isar.c
41463 +++ b/drivers/isdn/hisax/isar.c
41464 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41465 t = tmp;
41466 t += sprintf(t, "sendmbox cnt %d", len);
41467 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41468 - debugl1(cs, tmp);
41469 + debugl1(cs, "%s", tmp);
41470 i -= 64;
41471 }
41472 }
41473 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41474 t = tmp;
41475 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41476 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41477 - debugl1(cs, tmp);
41478 + debugl1(cs, "%s", tmp);
41479 i -= 64;
41480 }
41481 }
41482 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41483 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41484 ireg->iis, ireg->cmsb);
41485 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41486 - debugl1(cs, debbuf);
41487 + debugl1(cs, "%s", debbuf);
41488 }
41489 break;
41490 case ISAR_IIS_INVMSG:
41491 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41492 index f946c58..e2ae787 100644
41493 --- a/drivers/isdn/hisax/jade.c
41494 +++ b/drivers/isdn/hisax/jade.c
41495 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41496 int jade = bcs->hw.hscx.hscx;
41497
41498 if (cs->debug & L1_DEB_HSCX) {
41499 - char tmp[40];
41500 - sprintf(tmp, "jade %c mode %d ichan %d",
41501 - 'A' + jade, mode, bc);
41502 - debugl1(cs, tmp);
41503 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41504 }
41505 bcs->mode = mode;
41506 bcs->channel = bc;
41507 @@ -257,23 +254,18 @@ void
41508 clear_pending_jade_ints(struct IsdnCardState *cs)
41509 {
41510 int val;
41511 - char tmp[64];
41512
41513 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41514 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41515
41516 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41517 - sprintf(tmp, "jade B ISTA %x", val);
41518 - debugl1(cs, tmp);
41519 + debugl1(cs, "jade B ISTA %x", val);
41520 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41521 - sprintf(tmp, "jade A ISTA %x", val);
41522 - debugl1(cs, tmp);
41523 + debugl1(cs, "jade A ISTA %x", val);
41524 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41525 - sprintf(tmp, "jade B STAR %x", val);
41526 - debugl1(cs, tmp);
41527 + debugl1(cs, "jade B STAR %x", val);
41528 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41529 - sprintf(tmp, "jade A STAR %x", val);
41530 - debugl1(cs, tmp);
41531 + debugl1(cs, "jade A STAR %x", val);
41532 /* Unmask ints */
41533 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41534 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41535 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41536 index f521fc8..b930da9 100644
41537 --- a/drivers/isdn/hisax/jade_irq.c
41538 +++ b/drivers/isdn/hisax/jade_irq.c
41539 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41540 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41541 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41542 QuickHex(t, ptr, count);
41543 - debugl1(cs, bcs->blog);
41544 + debugl1(cs, "%s", bcs->blog);
41545 }
41546 }
41547
41548 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41549 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41550 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41551 QuickHex(t, ptr, count);
41552 - debugl1(cs, bcs->blog);
41553 + debugl1(cs, "%s", bcs->blog);
41554 }
41555 }
41556
41557 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41558 index 4c1bca5..875402e 100644
41559 --- a/drivers/isdn/hisax/l3_1tr6.c
41560 +++ b/drivers/isdn/hisax/l3_1tr6.c
41561 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41562 {
41563 dev_kfree_skb(skb);
41564 if (pc->st->l3.debug & L3_DEB_WARN)
41565 - l3_debug(pc->st, msg);
41566 + l3_debug(pc->st, "%s", msg);
41567 l3_1tr6_release_req(pc, 0, NULL);
41568 }
41569
41570 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41571 {
41572 u_char *p;
41573 int bcfound = 0;
41574 - char tmp[80];
41575 struct sk_buff *skb = arg;
41576
41577 /* Channel Identification */
41578 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41579 /* Signal all services, linklevel takes care of Service-Indicator */
41580 if (bcfound) {
41581 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41582 - sprintf(tmp, "non-digital call: %s -> %s",
41583 + l3_debug(pc->st, "non-digital call: %s -> %s",
41584 pc->para.setup.phone,
41585 pc->para.setup.eazmsn);
41586 - l3_debug(pc->st, tmp);
41587 }
41588 newl3state(pc, 6);
41589 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41590 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41591 {
41592 u_char *p;
41593 int i, tmpcharge = 0;
41594 - char a_charge[8], tmp[32];
41595 + char a_charge[8];
41596 struct sk_buff *skb = arg;
41597
41598 p = skb->data;
41599 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41600 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41601 }
41602 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41603 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41604 - l3_debug(pc->st, tmp);
41605 + l3_debug(pc->st, "charging info %d",
41606 + pc->para.chargeinfo);
41607 }
41608 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41609 l3_debug(pc->st, "charging info not found");
41610 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41611 struct sk_buff *skb = arg;
41612 u_char *p;
41613 int i, tmpcharge = 0;
41614 - char a_charge[8], tmp[32];
41615 + char a_charge[8];
41616
41617 StopAllL3Timer(pc);
41618 p = skb->data;
41619 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41620 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41621 }
41622 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41623 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41624 - l3_debug(pc->st, tmp);
41625 + l3_debug(pc->st, "charging info %d",
41626 + pc->para.chargeinfo);
41627 }
41628 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41629 l3_debug(pc->st, "charging info not found");
41630 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41631 int i, mt, cr;
41632 struct l3_process *proc;
41633 struct sk_buff *skb = arg;
41634 - char tmp[80];
41635
41636 switch (pr) {
41637 case (DL_DATA | INDICATION):
41638 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41639 }
41640 if (skb->len < 4) {
41641 if (st->l3.debug & L3_DEB_PROTERR) {
41642 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41643 - l3_debug(st, tmp);
41644 + l3_debug(st, "up1tr6 len only %d", skb->len);
41645 }
41646 dev_kfree_skb(skb);
41647 return;
41648 }
41649 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41650 if (st->l3.debug & L3_DEB_PROTERR) {
41651 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41652 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41653 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41654 skb->data[0], skb->len);
41655 - l3_debug(st, tmp);
41656 }
41657 dev_kfree_skb(skb);
41658 return;
41659 }
41660 if (skb->data[1] != 1) {
41661 if (st->l3.debug & L3_DEB_PROTERR) {
41662 - sprintf(tmp, "up1tr6 CR len not 1");
41663 - l3_debug(st, tmp);
41664 + l3_debug(st, "up1tr6 CR len not 1");
41665 }
41666 dev_kfree_skb(skb);
41667 return;
41668 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41669 if (skb->data[0] == PROTO_DIS_N0) {
41670 dev_kfree_skb(skb);
41671 if (st->l3.debug & L3_DEB_STATE) {
41672 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41673 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41674 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41675 - l3_debug(st, tmp);
41676 }
41677 } else if (skb->data[0] == PROTO_DIS_N1) {
41678 if (!(proc = getl3proc(st, cr))) {
41679 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41680 if (cr < 128) {
41681 if (!(proc = new_l3_process(st, cr))) {
41682 if (st->l3.debug & L3_DEB_PROTERR) {
41683 - sprintf(tmp, "up1tr6 no roc mem");
41684 - l3_debug(st, tmp);
41685 + l3_debug(st, "up1tr6 no roc mem");
41686 }
41687 dev_kfree_skb(skb);
41688 return;
41689 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41690 } else {
41691 if (!(proc = new_l3_process(st, cr))) {
41692 if (st->l3.debug & L3_DEB_PROTERR) {
41693 - sprintf(tmp, "up1tr6 no roc mem");
41694 - l3_debug(st, tmp);
41695 + l3_debug(st, "up1tr6 no roc mem");
41696 }
41697 dev_kfree_skb(skb);
41698 return;
41699 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41700 if (i == ARRAY_SIZE(datastln1)) {
41701 dev_kfree_skb(skb);
41702 if (st->l3.debug & L3_DEB_STATE) {
41703 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41704 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41705 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41706 proc->state, mt);
41707 - l3_debug(st, tmp);
41708 }
41709 return;
41710 } else {
41711 if (st->l3.debug & L3_DEB_STATE) {
41712 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41713 + l3_debug(st, "up1tr6%sstate %d mt %x",
41714 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41715 proc->state, mt);
41716 - l3_debug(st, tmp);
41717 }
41718 datastln1[i].rout(proc, pr, skb);
41719 }
41720 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41721 int i, cr;
41722 struct l3_process *proc;
41723 struct Channel *chan;
41724 - char tmp[80];
41725
41726 if ((DL_ESTABLISH | REQUEST) == pr) {
41727 l3_msg(st, pr, NULL);
41728 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41729 break;
41730 if (i == ARRAY_SIZE(downstl)) {
41731 if (st->l3.debug & L3_DEB_STATE) {
41732 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41733 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41734 proc->state, pr);
41735 - l3_debug(st, tmp);
41736 }
41737 } else {
41738 if (st->l3.debug & L3_DEB_STATE) {
41739 - sprintf(tmp, "down1tr6 state %d prim %d",
41740 + l3_debug(st, "down1tr6 state %d prim %d",
41741 proc->state, pr);
41742 - l3_debug(st, tmp);
41743 }
41744 downstl[i].rout(proc, pr, arg);
41745 }
41746 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41747 index b646eed..233e432 100644
41748 --- a/drivers/isdn/hisax/netjet.c
41749 +++ b/drivers/isdn/hisax/netjet.c
41750 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41751 else
41752 j = i;
41753 QuickHex(t, p, j);
41754 - debugl1(cs, tmp);
41755 + debugl1(cs, "%s", tmp);
41756 p += j;
41757 i -= j;
41758 t = tmp;
41759 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41760 index 041bf52..af1b020 100644
41761 --- a/drivers/isdn/hisax/q931.c
41762 +++ b/drivers/isdn/hisax/q931.c
41763 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41764 dp--;
41765 *dp++ = '\n';
41766 *dp = 0;
41767 - HiSax_putstatus(cs, NULL, cs->dlog);
41768 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41769 } else
41770 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41771 }
41772 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41773 }
41774 if (finish) {
41775 *dp = 0;
41776 - HiSax_putstatus(cs, NULL, cs->dlog);
41777 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41778 return;
41779 }
41780 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41781 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41782 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41783 }
41784 *dp = 0;
41785 - HiSax_putstatus(cs, NULL, cs->dlog);
41786 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41787 }
41788 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41789 index d8cac69..a858955 100644
41790 --- a/drivers/isdn/hisax/w6692.c
41791 +++ b/drivers/isdn/hisax/w6692.c
41792 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41793
41794 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41795 QuickHex(t, ptr, count);
41796 - debugl1(cs, cs->dlog);
41797 + debugl1(cs, "%s", cs->dlog);
41798 }
41799 }
41800
41801 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41802
41803 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41804 QuickHex(t, ptr, count);
41805 - debugl1(cs, cs->dlog);
41806 + debugl1(cs, "%s", cs->dlog);
41807 }
41808 }
41809
41810 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41811 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41812 bcs->channel + '1', count);
41813 QuickHex(t, ptr, count);
41814 - debugl1(cs, bcs->blog);
41815 + debugl1(cs, "%s", bcs->blog);
41816 }
41817 }
41818
41819 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41820 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41821 bcs->channel + '1', count);
41822 QuickHex(t, ptr, count);
41823 - debugl1(cs, bcs->blog);
41824 + debugl1(cs, "%s", bcs->blog);
41825 }
41826 }
41827
41828 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41829 index 9bb12ba..d4262f7 100644
41830 --- a/drivers/isdn/i4l/isdn_common.c
41831 +++ b/drivers/isdn/i4l/isdn_common.c
41832 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41833 } else
41834 return -EINVAL;
41835 case IIOCDBGVAR:
41836 + if (!capable(CAP_SYS_RAWIO))
41837 + return -EPERM;
41838 if (arg) {
41839 if (copy_to_user(argp, &dev, sizeof(ulong)))
41840 return -EFAULT;
41841 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41842 index 3c5f249..5fac4d0 100644
41843 --- a/drivers/isdn/i4l/isdn_tty.c
41844 +++ b/drivers/isdn/i4l/isdn_tty.c
41845 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41846
41847 #ifdef ISDN_DEBUG_MODEM_OPEN
41848 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41849 - port->count);
41850 + atomic_read(&port->count));
41851 #endif
41852 - port->count++;
41853 + atomic_inc(&port->count);
41854 port->tty = tty;
41855 /*
41856 * Start up serial port
41857 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41858 #endif
41859 return;
41860 }
41861 - if ((tty->count == 1) && (port->count != 1)) {
41862 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41863 /*
41864 * Uh, oh. tty->count is 1, which means that the tty
41865 * structure will be freed. Info->count should always
41866 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41867 * serial port won't be shutdown.
41868 */
41869 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41870 - "info->count is %d\n", port->count);
41871 - port->count = 1;
41872 + "info->count is %d\n", atomic_read(&port->count));
41873 + atomic_set(&port->count, 1);
41874 }
41875 - if (--port->count < 0) {
41876 + if (atomic_dec_return(&port->count) < 0) {
41877 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41878 - info->line, port->count);
41879 - port->count = 0;
41880 + info->line, atomic_read(&port->count));
41881 + atomic_set(&port->count, 0);
41882 }
41883 - if (port->count) {
41884 + if (atomic_read(&port->count)) {
41885 #ifdef ISDN_DEBUG_MODEM_OPEN
41886 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41887 #endif
41888 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41889 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41890 return;
41891 isdn_tty_shutdown(info);
41892 - port->count = 0;
41893 + atomic_set(&port->count, 0);
41894 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41895 port->tty = NULL;
41896 wake_up_interruptible(&port->open_wait);
41897 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41898 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41899 modem_info *info = &dev->mdm.info[i];
41900
41901 - if (info->port.count == 0)
41902 + if (atomic_read(&info->port.count) == 0)
41903 continue;
41904 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41905 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41906 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41907 index e74df7c..03a03ba 100644
41908 --- a/drivers/isdn/icn/icn.c
41909 +++ b/drivers/isdn/icn/icn.c
41910 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41911 if (count > len)
41912 count = len;
41913 if (user) {
41914 - if (copy_from_user(msg, buf, count))
41915 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41916 return -EFAULT;
41917 } else
41918 memcpy(msg, buf, count);
41919 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41920 index 6a8405d..0bd1c7e 100644
41921 --- a/drivers/leds/leds-clevo-mail.c
41922 +++ b/drivers/leds/leds-clevo-mail.c
41923 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41924 * detected as working, but in reality it is not) as low as
41925 * possible.
41926 */
41927 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
41928 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
41929 {
41930 .callback = clevo_mail_led_dmi_callback,
41931 .ident = "Clevo D410J",
41932 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41933 index 64e204e..c6bf189 100644
41934 --- a/drivers/leds/leds-ss4200.c
41935 +++ b/drivers/leds/leds-ss4200.c
41936 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41937 * detected as working, but in reality it is not) as low as
41938 * possible.
41939 */
41940 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
41941 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
41942 {
41943 .callback = ss4200_led_dmi_callback,
41944 .ident = "Intel SS4200-E",
41945 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41946 index 0bf1e4e..b4bf44e 100644
41947 --- a/drivers/lguest/core.c
41948 +++ b/drivers/lguest/core.c
41949 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41950 * The end address needs +1 because __get_vm_area allocates an
41951 * extra guard page, so we need space for that.
41952 */
41953 +
41954 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41955 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41956 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41957 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41958 +#else
41959 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41960 VM_ALLOC, switcher_addr, switcher_addr
41961 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41962 +#endif
41963 +
41964 if (!switcher_vma) {
41965 err = -ENOMEM;
41966 printk("lguest: could not map switcher pages high\n");
41967 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41968 * Now the Switcher is mapped at the right address, we can't fail!
41969 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41970 */
41971 - memcpy(switcher_vma->addr, start_switcher_text,
41972 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41973 end_switcher_text - start_switcher_text);
41974
41975 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41976 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41977 index a35d8d1..59fb772 100644
41978 --- a/drivers/lguest/page_tables.c
41979 +++ b/drivers/lguest/page_tables.c
41980 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41981 /*:*/
41982
41983 #ifdef CONFIG_X86_PAE
41984 -static void release_pmd(pmd_t *spmd)
41985 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41986 {
41987 /* If the entry's not present, there's nothing to release. */
41988 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41989 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41990 index 5169239..47cb4db 100644
41991 --- a/drivers/lguest/x86/core.c
41992 +++ b/drivers/lguest/x86/core.c
41993 @@ -59,7 +59,7 @@ static struct {
41994 /* Offset from where switcher.S was compiled to where we've copied it */
41995 static unsigned long switcher_offset(void)
41996 {
41997 - return switcher_addr - (unsigned long)start_switcher_text;
41998 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41999 }
42000
42001 /* This cpu's struct lguest_pages (after the Switcher text page) */
42002 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42003 * These copies are pretty cheap, so we do them unconditionally: */
42004 /* Save the current Host top-level page directory.
42005 */
42006 +
42007 +#ifdef CONFIG_PAX_PER_CPU_PGD
42008 + pages->state.host_cr3 = read_cr3();
42009 +#else
42010 pages->state.host_cr3 = __pa(current->mm->pgd);
42011 +#endif
42012 +
42013 /*
42014 * Set up the Guest's page tables to see this CPU's pages (and no
42015 * other CPU's pages).
42016 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42017 * compiled-in switcher code and the high-mapped copy we just made.
42018 */
42019 for (i = 0; i < IDT_ENTRIES; i++)
42020 - default_idt_entries[i] += switcher_offset();
42021 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42022
42023 /*
42024 * Set up the Switcher's per-cpu areas.
42025 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42026 * it will be undisturbed when we switch. To change %cs and jump we
42027 * need this structure to feed to Intel's "lcall" instruction.
42028 */
42029 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42030 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42031 lguest_entry.segment = LGUEST_CS;
42032
42033 /*
42034 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42035 index 40634b0..4f5855e 100644
42036 --- a/drivers/lguest/x86/switcher_32.S
42037 +++ b/drivers/lguest/x86/switcher_32.S
42038 @@ -87,6 +87,7 @@
42039 #include <asm/page.h>
42040 #include <asm/segment.h>
42041 #include <asm/lguest.h>
42042 +#include <asm/processor-flags.h>
42043
42044 // We mark the start of the code to copy
42045 // It's placed in .text tho it's never run here
42046 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42047 // Changes type when we load it: damn Intel!
42048 // For after we switch over our page tables
42049 // That entry will be read-only: we'd crash.
42050 +
42051 +#ifdef CONFIG_PAX_KERNEXEC
42052 + mov %cr0, %edx
42053 + xor $X86_CR0_WP, %edx
42054 + mov %edx, %cr0
42055 +#endif
42056 +
42057 movl $(GDT_ENTRY_TSS*8), %edx
42058 ltr %dx
42059
42060 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42061 // Let's clear it again for our return.
42062 // The GDT descriptor of the Host
42063 // Points to the table after two "size" bytes
42064 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42065 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42066 // Clear "used" from type field (byte 5, bit 2)
42067 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42068 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42069 +
42070 +#ifdef CONFIG_PAX_KERNEXEC
42071 + mov %cr0, %eax
42072 + xor $X86_CR0_WP, %eax
42073 + mov %eax, %cr0
42074 +#endif
42075
42076 // Once our page table's switched, the Guest is live!
42077 // The Host fades as we run this final step.
42078 @@ -295,13 +309,12 @@ deliver_to_host:
42079 // I consulted gcc, and it gave
42080 // These instructions, which I gladly credit:
42081 leal (%edx,%ebx,8), %eax
42082 - movzwl (%eax),%edx
42083 - movl 4(%eax), %eax
42084 - xorw %ax, %ax
42085 - orl %eax, %edx
42086 + movl 4(%eax), %edx
42087 + movw (%eax), %dx
42088 // Now the address of the handler's in %edx
42089 // We call it now: its "iret" drops us home.
42090 - jmp *%edx
42091 + ljmp $__KERNEL_CS, $1f
42092 +1: jmp *%edx
42093
42094 // Every interrupt can come to us here
42095 // But we must truly tell each apart.
42096 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42097 index 0003992..854bbce 100644
42098 --- a/drivers/md/bcache/closure.h
42099 +++ b/drivers/md/bcache/closure.h
42100 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42101 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42102 struct workqueue_struct *wq)
42103 {
42104 - BUG_ON(object_is_on_stack(cl));
42105 + BUG_ON(object_starts_on_stack(cl));
42106 closure_set_ip(cl);
42107 cl->fn = fn;
42108 cl->wq = wq;
42109 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42110 index 547c4c5..5be1de4 100644
42111 --- a/drivers/md/bcache/super.c
42112 +++ b/drivers/md/bcache/super.c
42113 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42114 err:
42115 closure_sync(&op.cl);
42116 /* XXX: test this, it's broken */
42117 - bch_cache_set_error(c, err);
42118 + bch_cache_set_error(c, "%s", err);
42119 }
42120
42121 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42122 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42123 index a7fd821..9dcf6c3 100644
42124 --- a/drivers/md/bitmap.c
42125 +++ b/drivers/md/bitmap.c
42126 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42127 chunk_kb ? "KB" : "B");
42128 if (bitmap->storage.file) {
42129 seq_printf(seq, ", file: ");
42130 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42131 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42132 }
42133
42134 seq_printf(seq, "\n");
42135 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42136 index f1b7586..a49c4bd 100644
42137 --- a/drivers/md/dm-ioctl.c
42138 +++ b/drivers/md/dm-ioctl.c
42139 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42140 cmd == DM_LIST_VERSIONS_CMD)
42141 return 0;
42142
42143 - if ((cmd == DM_DEV_CREATE_CMD)) {
42144 + if (cmd == DM_DEV_CREATE_CMD) {
42145 if (!*param->name) {
42146 DMWARN("name not supplied when creating device");
42147 return -EINVAL;
42148 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42149 index 699b5be..eac0a15 100644
42150 --- a/drivers/md/dm-raid1.c
42151 +++ b/drivers/md/dm-raid1.c
42152 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42153
42154 struct mirror {
42155 struct mirror_set *ms;
42156 - atomic_t error_count;
42157 + atomic_unchecked_t error_count;
42158 unsigned long error_type;
42159 struct dm_dev *dev;
42160 sector_t offset;
42161 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42162 struct mirror *m;
42163
42164 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42165 - if (!atomic_read(&m->error_count))
42166 + if (!atomic_read_unchecked(&m->error_count))
42167 return m;
42168
42169 return NULL;
42170 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42171 * simple way to tell if a device has encountered
42172 * errors.
42173 */
42174 - atomic_inc(&m->error_count);
42175 + atomic_inc_unchecked(&m->error_count);
42176
42177 if (test_and_set_bit(error_type, &m->error_type))
42178 return;
42179 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42180 struct mirror *m = get_default_mirror(ms);
42181
42182 do {
42183 - if (likely(!atomic_read(&m->error_count)))
42184 + if (likely(!atomic_read_unchecked(&m->error_count)))
42185 return m;
42186
42187 if (m-- == ms->mirror)
42188 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42189 {
42190 struct mirror *default_mirror = get_default_mirror(m->ms);
42191
42192 - return !atomic_read(&default_mirror->error_count);
42193 + return !atomic_read_unchecked(&default_mirror->error_count);
42194 }
42195
42196 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42197 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42198 */
42199 if (likely(region_in_sync(ms, region, 1)))
42200 m = choose_mirror(ms, bio->bi_sector);
42201 - else if (m && atomic_read(&m->error_count))
42202 + else if (m && atomic_read_unchecked(&m->error_count))
42203 m = NULL;
42204
42205 if (likely(m))
42206 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42207 }
42208
42209 ms->mirror[mirror].ms = ms;
42210 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42211 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42212 ms->mirror[mirror].error_type = 0;
42213 ms->mirror[mirror].offset = offset;
42214
42215 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42216 */
42217 static char device_status_char(struct mirror *m)
42218 {
42219 - if (!atomic_read(&(m->error_count)))
42220 + if (!atomic_read_unchecked(&(m->error_count)))
42221 return 'A';
42222
42223 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42224 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42225 index d907ca6..cfb8384 100644
42226 --- a/drivers/md/dm-stripe.c
42227 +++ b/drivers/md/dm-stripe.c
42228 @@ -20,7 +20,7 @@ struct stripe {
42229 struct dm_dev *dev;
42230 sector_t physical_start;
42231
42232 - atomic_t error_count;
42233 + atomic_unchecked_t error_count;
42234 };
42235
42236 struct stripe_c {
42237 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42238 kfree(sc);
42239 return r;
42240 }
42241 - atomic_set(&(sc->stripe[i].error_count), 0);
42242 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42243 }
42244
42245 ti->private = sc;
42246 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42247 DMEMIT("%d ", sc->stripes);
42248 for (i = 0; i < sc->stripes; i++) {
42249 DMEMIT("%s ", sc->stripe[i].dev->name);
42250 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42251 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42252 'D' : 'A';
42253 }
42254 buffer[i] = '\0';
42255 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42256 */
42257 for (i = 0; i < sc->stripes; i++)
42258 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42259 - atomic_inc(&(sc->stripe[i].error_count));
42260 - if (atomic_read(&(sc->stripe[i].error_count)) <
42261 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42262 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42263 DM_IO_ERROR_THRESHOLD)
42264 schedule_work(&sc->trigger_event);
42265 }
42266 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42267 index f221812..aca962b 100644
42268 --- a/drivers/md/dm-table.c
42269 +++ b/drivers/md/dm-table.c
42270 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42271 if (!dev_size)
42272 return 0;
42273
42274 - if ((start >= dev_size) || (start + len > dev_size)) {
42275 + if ((start >= dev_size) || (len > dev_size - start)) {
42276 DMWARN("%s: %s too small for target: "
42277 "start=%llu, len=%llu, dev_size=%llu",
42278 dm_device_name(ti->table->md), bdevname(bdev, b),
42279 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42280 index 60bce43..9b997d0 100644
42281 --- a/drivers/md/dm-thin-metadata.c
42282 +++ b/drivers/md/dm-thin-metadata.c
42283 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42284 {
42285 pmd->info.tm = pmd->tm;
42286 pmd->info.levels = 2;
42287 - pmd->info.value_type.context = pmd->data_sm;
42288 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42289 pmd->info.value_type.size = sizeof(__le64);
42290 pmd->info.value_type.inc = data_block_inc;
42291 pmd->info.value_type.dec = data_block_dec;
42292 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42293
42294 pmd->bl_info.tm = pmd->tm;
42295 pmd->bl_info.levels = 1;
42296 - pmd->bl_info.value_type.context = pmd->data_sm;
42297 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42298 pmd->bl_info.value_type.size = sizeof(__le64);
42299 pmd->bl_info.value_type.inc = data_block_inc;
42300 pmd->bl_info.value_type.dec = data_block_dec;
42301 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42302 index 995e1fc..2468cec 100644
42303 --- a/drivers/md/dm.c
42304 +++ b/drivers/md/dm.c
42305 @@ -178,9 +178,9 @@ struct mapped_device {
42306 /*
42307 * Event handling.
42308 */
42309 - atomic_t event_nr;
42310 + atomic_unchecked_t event_nr;
42311 wait_queue_head_t eventq;
42312 - atomic_t uevent_seq;
42313 + atomic_unchecked_t uevent_seq;
42314 struct list_head uevent_list;
42315 spinlock_t uevent_lock; /* Protect access to uevent_list */
42316
42317 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42318 spin_lock_init(&md->deferred_lock);
42319 atomic_set(&md->holders, 1);
42320 atomic_set(&md->open_count, 0);
42321 - atomic_set(&md->event_nr, 0);
42322 - atomic_set(&md->uevent_seq, 0);
42323 + atomic_set_unchecked(&md->event_nr, 0);
42324 + atomic_set_unchecked(&md->uevent_seq, 0);
42325 INIT_LIST_HEAD(&md->uevent_list);
42326 spin_lock_init(&md->uevent_lock);
42327
42328 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42329
42330 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42331
42332 - atomic_inc(&md->event_nr);
42333 + atomic_inc_unchecked(&md->event_nr);
42334 wake_up(&md->eventq);
42335 }
42336
42337 @@ -2727,18 +2727,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42338
42339 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42340 {
42341 - return atomic_add_return(1, &md->uevent_seq);
42342 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42343 }
42344
42345 uint32_t dm_get_event_nr(struct mapped_device *md)
42346 {
42347 - return atomic_read(&md->event_nr);
42348 + return atomic_read_unchecked(&md->event_nr);
42349 }
42350
42351 int dm_wait_event(struct mapped_device *md, int event_nr)
42352 {
42353 return wait_event_interruptible(md->eventq,
42354 - (event_nr != atomic_read(&md->event_nr)));
42355 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42356 }
42357
42358 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42359 diff --git a/drivers/md/md.c b/drivers/md/md.c
42360 index 9f13e13..411a5b8 100644
42361 --- a/drivers/md/md.c
42362 +++ b/drivers/md/md.c
42363 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42364 * start build, activate spare
42365 */
42366 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42367 -static atomic_t md_event_count;
42368 +static atomic_unchecked_t md_event_count;
42369 void md_new_event(struct mddev *mddev)
42370 {
42371 - atomic_inc(&md_event_count);
42372 + atomic_inc_unchecked(&md_event_count);
42373 wake_up(&md_event_waiters);
42374 }
42375 EXPORT_SYMBOL_GPL(md_new_event);
42376 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42377 */
42378 static void md_new_event_inintr(struct mddev *mddev)
42379 {
42380 - atomic_inc(&md_event_count);
42381 + atomic_inc_unchecked(&md_event_count);
42382 wake_up(&md_event_waiters);
42383 }
42384
42385 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42386 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42387 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42388 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42389 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42390 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42391
42392 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42393 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42394 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42395 else
42396 sb->resync_offset = cpu_to_le64(0);
42397
42398 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42399 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42400
42401 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42402 sb->size = cpu_to_le64(mddev->dev_sectors);
42403 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42404 static ssize_t
42405 errors_show(struct md_rdev *rdev, char *page)
42406 {
42407 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42408 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42409 }
42410
42411 static ssize_t
42412 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42413 char *e;
42414 unsigned long n = simple_strtoul(buf, &e, 10);
42415 if (*buf && (*e == 0 || *e == '\n')) {
42416 - atomic_set(&rdev->corrected_errors, n);
42417 + atomic_set_unchecked(&rdev->corrected_errors, n);
42418 return len;
42419 }
42420 return -EINVAL;
42421 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42422 rdev->sb_loaded = 0;
42423 rdev->bb_page = NULL;
42424 atomic_set(&rdev->nr_pending, 0);
42425 - atomic_set(&rdev->read_errors, 0);
42426 - atomic_set(&rdev->corrected_errors, 0);
42427 + atomic_set_unchecked(&rdev->read_errors, 0);
42428 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42429
42430 INIT_LIST_HEAD(&rdev->same_set);
42431 init_waitqueue_head(&rdev->blocked_wait);
42432 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42433
42434 spin_unlock(&pers_lock);
42435 seq_printf(seq, "\n");
42436 - seq->poll_event = atomic_read(&md_event_count);
42437 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42438 return 0;
42439 }
42440 if (v == (void*)2) {
42441 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42442 return error;
42443
42444 seq = file->private_data;
42445 - seq->poll_event = atomic_read(&md_event_count);
42446 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42447 return error;
42448 }
42449
42450 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42451 /* always allow read */
42452 mask = POLLIN | POLLRDNORM;
42453
42454 - if (seq->poll_event != atomic_read(&md_event_count))
42455 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42456 mask |= POLLERR | POLLPRI;
42457 return mask;
42458 }
42459 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42460 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42461 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42462 (int)part_stat_read(&disk->part0, sectors[1]) -
42463 - atomic_read(&disk->sync_io);
42464 + atomic_read_unchecked(&disk->sync_io);
42465 /* sync IO will cause sync_io to increase before the disk_stats
42466 * as sync_io is counted when a request starts, and
42467 * disk_stats is counted when it completes.
42468 diff --git a/drivers/md/md.h b/drivers/md/md.h
42469 index 20f02c0..fd8c821 100644
42470 --- a/drivers/md/md.h
42471 +++ b/drivers/md/md.h
42472 @@ -94,13 +94,13 @@ struct md_rdev {
42473 * only maintained for arrays that
42474 * support hot removal
42475 */
42476 - atomic_t read_errors; /* number of consecutive read errors that
42477 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42478 * we have tried to ignore.
42479 */
42480 struct timespec last_read_error; /* monotonic time since our
42481 * last read error
42482 */
42483 - atomic_t corrected_errors; /* number of corrected read errors,
42484 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42485 * for reporting to userspace and storing
42486 * in superblock.
42487 */
42488 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42489
42490 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42491 {
42492 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42493 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42494 }
42495
42496 struct md_personality
42497 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42498 index 3e6d115..ffecdeb 100644
42499 --- a/drivers/md/persistent-data/dm-space-map.h
42500 +++ b/drivers/md/persistent-data/dm-space-map.h
42501 @@ -71,6 +71,7 @@ struct dm_space_map {
42502 dm_sm_threshold_fn fn,
42503 void *context);
42504 };
42505 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42506
42507 /*----------------------------------------------------------------*/
42508
42509 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42510 index d60412c..8d4c982 100644
42511 --- a/drivers/md/raid1.c
42512 +++ b/drivers/md/raid1.c
42513 @@ -1823,7 +1823,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42514 if (r1_sync_page_io(rdev, sect, s,
42515 bio->bi_io_vec[idx].bv_page,
42516 READ) != 0)
42517 - atomic_add(s, &rdev->corrected_errors);
42518 + atomic_add_unchecked(s, &rdev->corrected_errors);
42519 }
42520 sectors -= s;
42521 sect += s;
42522 @@ -2050,7 +2050,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42523 test_bit(In_sync, &rdev->flags)) {
42524 if (r1_sync_page_io(rdev, sect, s,
42525 conf->tmppage, READ)) {
42526 - atomic_add(s, &rdev->corrected_errors);
42527 + atomic_add_unchecked(s, &rdev->corrected_errors);
42528 printk(KERN_INFO
42529 "md/raid1:%s: read error corrected "
42530 "(%d sectors at %llu on %s)\n",
42531 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42532 index df7b0a0..a257495 100644
42533 --- a/drivers/md/raid10.c
42534 +++ b/drivers/md/raid10.c
42535 @@ -1962,7 +1962,7 @@ static void end_sync_read(struct bio *bio, int error)
42536 /* The write handler will notice the lack of
42537 * R10BIO_Uptodate and record any errors etc
42538 */
42539 - atomic_add(r10_bio->sectors,
42540 + atomic_add_unchecked(r10_bio->sectors,
42541 &conf->mirrors[d].rdev->corrected_errors);
42542
42543 /* for reconstruct, we always reschedule after a read.
42544 @@ -2320,7 +2320,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42545 {
42546 struct timespec cur_time_mon;
42547 unsigned long hours_since_last;
42548 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42549 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42550
42551 ktime_get_ts(&cur_time_mon);
42552
42553 @@ -2342,9 +2342,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42554 * overflowing the shift of read_errors by hours_since_last.
42555 */
42556 if (hours_since_last >= 8 * sizeof(read_errors))
42557 - atomic_set(&rdev->read_errors, 0);
42558 + atomic_set_unchecked(&rdev->read_errors, 0);
42559 else
42560 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42561 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42562 }
42563
42564 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42565 @@ -2398,8 +2398,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42566 return;
42567
42568 check_decay_read_errors(mddev, rdev);
42569 - atomic_inc(&rdev->read_errors);
42570 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42571 + atomic_inc_unchecked(&rdev->read_errors);
42572 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42573 char b[BDEVNAME_SIZE];
42574 bdevname(rdev->bdev, b);
42575
42576 @@ -2407,7 +2407,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42577 "md/raid10:%s: %s: Raid device exceeded "
42578 "read_error threshold [cur %d:max %d]\n",
42579 mdname(mddev), b,
42580 - atomic_read(&rdev->read_errors), max_read_errors);
42581 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42582 printk(KERN_NOTICE
42583 "md/raid10:%s: %s: Failing raid device\n",
42584 mdname(mddev), b);
42585 @@ -2562,7 +2562,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42586 sect +
42587 choose_data_offset(r10_bio, rdev)),
42588 bdevname(rdev->bdev, b));
42589 - atomic_add(s, &rdev->corrected_errors);
42590 + atomic_add_unchecked(s, &rdev->corrected_errors);
42591 }
42592
42593 rdev_dec_pending(rdev, mddev);
42594 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42595 index 78ea443..7d57513 100644
42596 --- a/drivers/md/raid5.c
42597 +++ b/drivers/md/raid5.c
42598 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42599 mdname(conf->mddev), STRIPE_SECTORS,
42600 (unsigned long long)s,
42601 bdevname(rdev->bdev, b));
42602 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42603 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42604 clear_bit(R5_ReadError, &sh->dev[i].flags);
42605 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42606 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42607 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42608
42609 - if (atomic_read(&rdev->read_errors))
42610 - atomic_set(&rdev->read_errors, 0);
42611 + if (atomic_read_unchecked(&rdev->read_errors))
42612 + atomic_set_unchecked(&rdev->read_errors, 0);
42613 } else {
42614 const char *bdn = bdevname(rdev->bdev, b);
42615 int retry = 0;
42616 int set_bad = 0;
42617
42618 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42619 - atomic_inc(&rdev->read_errors);
42620 + atomic_inc_unchecked(&rdev->read_errors);
42621 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42622 printk_ratelimited(
42623 KERN_WARNING
42624 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42625 mdname(conf->mddev),
42626 (unsigned long long)s,
42627 bdn);
42628 - } else if (atomic_read(&rdev->read_errors)
42629 + } else if (atomic_read_unchecked(&rdev->read_errors)
42630 > conf->max_nr_stripes)
42631 printk(KERN_WARNING
42632 "md/raid:%s: Too many read errors, failing device %s.\n",
42633 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42634 index 401ef64..836e563 100644
42635 --- a/drivers/media/dvb-core/dvbdev.c
42636 +++ b/drivers/media/dvb-core/dvbdev.c
42637 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42638 const struct dvb_device *template, void *priv, int type)
42639 {
42640 struct dvb_device *dvbdev;
42641 - struct file_operations *dvbdevfops;
42642 + file_operations_no_const *dvbdevfops;
42643 struct device *clsdev;
42644 int minor;
42645 int id;
42646 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42647 index 9b6c3bb..baeb5c7 100644
42648 --- a/drivers/media/dvb-frontends/dib3000.h
42649 +++ b/drivers/media/dvb-frontends/dib3000.h
42650 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42651 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42652 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42653 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42654 -};
42655 +} __no_const;
42656
42657 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42658 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42659 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42660 index ecf21d9..b992428d 100644
42661 --- a/drivers/media/pci/cx88/cx88-video.c
42662 +++ b/drivers/media/pci/cx88/cx88-video.c
42663 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42664
42665 /* ------------------------------------------------------------------ */
42666
42667 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42668 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42669 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42670 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42671 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42672 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42673
42674 module_param_array(video_nr, int, NULL, 0444);
42675 module_param_array(vbi_nr, int, NULL, 0444);
42676 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42677 index c08ae3e..eb59af1 100644
42678 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42679 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42680 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42681 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42682
42683 /* ivtv instance counter */
42684 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42685 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42686
42687 /* Parameter declarations */
42688 static int cardtype[IVTV_MAX_CARDS];
42689 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42690 index dfd0a21..6bbb465 100644
42691 --- a/drivers/media/platform/omap/omap_vout.c
42692 +++ b/drivers/media/platform/omap/omap_vout.c
42693 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42694 OMAP_VIDEO2,
42695 };
42696
42697 -static struct videobuf_queue_ops video_vbq_ops;
42698 /* Variables configurable through module params*/
42699 static u32 video1_numbuffers = 3;
42700 static u32 video2_numbuffers = 3;
42701 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42702 {
42703 struct videobuf_queue *q;
42704 struct omap_vout_device *vout = NULL;
42705 + static struct videobuf_queue_ops video_vbq_ops = {
42706 + .buf_setup = omap_vout_buffer_setup,
42707 + .buf_prepare = omap_vout_buffer_prepare,
42708 + .buf_release = omap_vout_buffer_release,
42709 + .buf_queue = omap_vout_buffer_queue,
42710 + };
42711
42712 vout = video_drvdata(file);
42713 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42714 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42715 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42716
42717 q = &vout->vbq;
42718 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42719 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42720 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42721 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42722 spin_lock_init(&vout->vbq_lock);
42723
42724 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42725 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42726 index 04e6490..2df65bf 100644
42727 --- a/drivers/media/platform/s5p-tv/mixer.h
42728 +++ b/drivers/media/platform/s5p-tv/mixer.h
42729 @@ -156,7 +156,7 @@ struct mxr_layer {
42730 /** layer index (unique identifier) */
42731 int idx;
42732 /** callbacks for layer methods */
42733 - struct mxr_layer_ops ops;
42734 + struct mxr_layer_ops *ops;
42735 /** format array */
42736 const struct mxr_format **fmt_array;
42737 /** size of format array */
42738 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42739 index b93a21f..2535195 100644
42740 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42741 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42742 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42743 {
42744 struct mxr_layer *layer;
42745 int ret;
42746 - struct mxr_layer_ops ops = {
42747 + static struct mxr_layer_ops ops = {
42748 .release = mxr_graph_layer_release,
42749 .buffer_set = mxr_graph_buffer_set,
42750 .stream_set = mxr_graph_stream_set,
42751 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42752 index b713403..53cb5ad 100644
42753 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42754 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42755 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42756 layer->update_buf = next;
42757 }
42758
42759 - layer->ops.buffer_set(layer, layer->update_buf);
42760 + layer->ops->buffer_set(layer, layer->update_buf);
42761
42762 if (done && done != layer->shadow_buf)
42763 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42764 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42765 index 641b1f0..49cff30 100644
42766 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42767 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42768 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42769 layer->geo.src.height = layer->geo.src.full_height;
42770
42771 mxr_geometry_dump(mdev, &layer->geo);
42772 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42773 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42774 mxr_geometry_dump(mdev, &layer->geo);
42775 }
42776
42777 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42778 layer->geo.dst.full_width = mbus_fmt.width;
42779 layer->geo.dst.full_height = mbus_fmt.height;
42780 layer->geo.dst.field = mbus_fmt.field;
42781 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42782 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42783
42784 mxr_geometry_dump(mdev, &layer->geo);
42785 }
42786 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42787 /* set source size to highest accepted value */
42788 geo->src.full_width = max(geo->dst.full_width, pix->width);
42789 geo->src.full_height = max(geo->dst.full_height, pix->height);
42790 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42791 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42792 mxr_geometry_dump(mdev, &layer->geo);
42793 /* set cropping to total visible screen */
42794 geo->src.width = pix->width;
42795 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42796 geo->src.x_offset = 0;
42797 geo->src.y_offset = 0;
42798 /* assure consistency of geometry */
42799 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42800 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42801 mxr_geometry_dump(mdev, &layer->geo);
42802 /* set full size to lowest possible value */
42803 geo->src.full_width = 0;
42804 geo->src.full_height = 0;
42805 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42806 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42807 mxr_geometry_dump(mdev, &layer->geo);
42808
42809 /* returning results */
42810 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42811 target->width = s->r.width;
42812 target->height = s->r.height;
42813
42814 - layer->ops.fix_geometry(layer, stage, s->flags);
42815 + layer->ops->fix_geometry(layer, stage, s->flags);
42816
42817 /* retrieve update selection rectangle */
42818 res.left = target->x_offset;
42819 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42820 mxr_output_get(mdev);
42821
42822 mxr_layer_update_output(layer);
42823 - layer->ops.format_set(layer);
42824 + layer->ops->format_set(layer);
42825 /* enabling layer in hardware */
42826 spin_lock_irqsave(&layer->enq_slock, flags);
42827 layer->state = MXR_LAYER_STREAMING;
42828 spin_unlock_irqrestore(&layer->enq_slock, flags);
42829
42830 - layer->ops.stream_set(layer, MXR_ENABLE);
42831 + layer->ops->stream_set(layer, MXR_ENABLE);
42832 mxr_streamer_get(mdev);
42833
42834 return 0;
42835 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42836 spin_unlock_irqrestore(&layer->enq_slock, flags);
42837
42838 /* disabling layer in hardware */
42839 - layer->ops.stream_set(layer, MXR_DISABLE);
42840 + layer->ops->stream_set(layer, MXR_DISABLE);
42841 /* remove one streamer */
42842 mxr_streamer_put(mdev);
42843 /* allow changes in output configuration */
42844 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42845
42846 void mxr_layer_release(struct mxr_layer *layer)
42847 {
42848 - if (layer->ops.release)
42849 - layer->ops.release(layer);
42850 + if (layer->ops->release)
42851 + layer->ops->release(layer);
42852 }
42853
42854 void mxr_base_layer_release(struct mxr_layer *layer)
42855 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42856
42857 layer->mdev = mdev;
42858 layer->idx = idx;
42859 - layer->ops = *ops;
42860 + layer->ops = ops;
42861
42862 spin_lock_init(&layer->enq_slock);
42863 INIT_LIST_HEAD(&layer->enq_list);
42864 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42865 index 3d13a63..da31bf1 100644
42866 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42867 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42868 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42869 {
42870 struct mxr_layer *layer;
42871 int ret;
42872 - struct mxr_layer_ops ops = {
42873 + static struct mxr_layer_ops ops = {
42874 .release = mxr_vp_layer_release,
42875 .buffer_set = mxr_vp_buffer_set,
42876 .stream_set = mxr_vp_stream_set,
42877 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42878 index 545c04c..a14bded 100644
42879 --- a/drivers/media/radio/radio-cadet.c
42880 +++ b/drivers/media/radio/radio-cadet.c
42881 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42882 unsigned char readbuf[RDS_BUFFER];
42883 int i = 0;
42884
42885 + if (count > RDS_BUFFER)
42886 + return -EFAULT;
42887 mutex_lock(&dev->lock);
42888 if (dev->rdsstat == 0)
42889 cadet_start_rds(dev);
42890 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42891 while (i < count && dev->rdsin != dev->rdsout)
42892 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42893
42894 - if (i && copy_to_user(data, readbuf, i))
42895 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42896 i = -EFAULT;
42897 unlock:
42898 mutex_unlock(&dev->lock);
42899 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42900 index bd4d3a7..ffc0b9d 100644
42901 --- a/drivers/media/radio/radio-maxiradio.c
42902 +++ b/drivers/media/radio/radio-maxiradio.c
42903 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42904 /* TEA5757 pin mappings */
42905 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42906
42907 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42908 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42909
42910 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42911 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42912 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42913 index 8fa18ab..caee70f 100644
42914 --- a/drivers/media/radio/radio-shark.c
42915 +++ b/drivers/media/radio/radio-shark.c
42916 @@ -79,7 +79,7 @@ struct shark_device {
42917 u32 last_val;
42918 };
42919
42920 -static atomic_t shark_instance = ATOMIC_INIT(0);
42921 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42922
42923 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42924 {
42925 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42926 index 9fb6697..f167415 100644
42927 --- a/drivers/media/radio/radio-shark2.c
42928 +++ b/drivers/media/radio/radio-shark2.c
42929 @@ -74,7 +74,7 @@ struct shark_device {
42930 u8 *transfer_buffer;
42931 };
42932
42933 -static atomic_t shark_instance = ATOMIC_INIT(0);
42934 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42935
42936 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42937 {
42938 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42939 index 9c9084c..a9e8dfb 100644
42940 --- a/drivers/media/radio/radio-si476x.c
42941 +++ b/drivers/media/radio/radio-si476x.c
42942 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42943 struct si476x_radio *radio;
42944 struct v4l2_ctrl *ctrl;
42945
42946 - static atomic_t instance = ATOMIC_INIT(0);
42947 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42948
42949 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42950 if (!radio)
42951 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42952 index 1cf382a..c22998c 100644
42953 --- a/drivers/media/rc/rc-main.c
42954 +++ b/drivers/media/rc/rc-main.c
42955 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42956 int rc_register_device(struct rc_dev *dev)
42957 {
42958 static bool raw_init = false; /* raw decoders loaded? */
42959 - static atomic_t devno = ATOMIC_INIT(0);
42960 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42961 struct rc_map *rc_map;
42962 const char *path;
42963 int rc;
42964 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
42965 */
42966 mutex_lock(&dev->lock);
42967
42968 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42969 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42970 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42971 dev_set_drvdata(&dev->dev, dev);
42972 rc = device_add(&dev->dev);
42973 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42974 index 3940bb0..fb3952a 100644
42975 --- a/drivers/media/usb/dvb-usb/cxusb.c
42976 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42977 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42978
42979 struct dib0700_adapter_state {
42980 int (*set_param_save) (struct dvb_frontend *);
42981 -};
42982 +} __no_const;
42983
42984 static int dib7070_set_param_override(struct dvb_frontend *fe)
42985 {
42986 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42987 index 6e237b6..dc25556 100644
42988 --- a/drivers/media/usb/dvb-usb/dw2102.c
42989 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42990 @@ -118,7 +118,7 @@ struct su3000_state {
42991
42992 struct s6x0_state {
42993 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42994 -};
42995 +} __no_const;
42996
42997 /* debug */
42998 static int dvb_usb_dw2102_debug;
42999 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43000 index 8f7a6a4..59502dd 100644
43001 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43002 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43003 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43004 __u32 reserved;
43005 };
43006
43007 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43008 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43009 enum v4l2_memory memory)
43010 {
43011 void __user *up_pln;
43012 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43013 return 0;
43014 }
43015
43016 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43017 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43018 enum v4l2_memory memory)
43019 {
43020 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43021 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43022 put_user(kp->start_block, &up->start_block) ||
43023 put_user(kp->blocks, &up->blocks) ||
43024 put_user(tmp, &up->edid) ||
43025 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43026 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43027 return -EFAULT;
43028 return 0;
43029 }
43030 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43031 index 02d1b63..5fd6b16 100644
43032 --- a/drivers/media/v4l2-core/v4l2-device.c
43033 +++ b/drivers/media/v4l2-core/v4l2-device.c
43034 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43035 EXPORT_SYMBOL_GPL(v4l2_device_put);
43036
43037 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43038 - atomic_t *instance)
43039 + atomic_unchecked_t *instance)
43040 {
43041 - int num = atomic_inc_return(instance) - 1;
43042 + int num = atomic_inc_return_unchecked(instance) - 1;
43043 int len = strlen(basename);
43044
43045 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43046 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43047 index 68e6b5e..d8b923e 100644
43048 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43049 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43050 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43051 struct file *file, void *fh, void *p);
43052 } u;
43053 void (*debug)(const void *arg, bool write_only);
43054 -};
43055 +} __do_const;
43056 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43057
43058 /* This control needs a priority check */
43059 #define INFO_FL_PRIO (1 << 0)
43060 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43061 struct video_device *vfd = video_devdata(file);
43062 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43063 bool write_only = false;
43064 - struct v4l2_ioctl_info default_info;
43065 + v4l2_ioctl_info_no_const default_info;
43066 const struct v4l2_ioctl_info *info;
43067 void *fh = file->private_data;
43068 struct v4l2_fh *vfh = NULL;
43069 @@ -2194,7 +2195,7 @@ done:
43070 }
43071
43072 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43073 - void * __user *user_ptr, void ***kernel_ptr)
43074 + void __user **user_ptr, void ***kernel_ptr)
43075 {
43076 int ret = 0;
43077
43078 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43079 ret = -EINVAL;
43080 break;
43081 }
43082 - *user_ptr = (void __user *)buf->m.planes;
43083 + *user_ptr = (void __force_user *)buf->m.planes;
43084 *kernel_ptr = (void *)&buf->m.planes;
43085 *array_size = sizeof(struct v4l2_plane) * buf->length;
43086 ret = 1;
43087 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43088 ret = -EINVAL;
43089 break;
43090 }
43091 - *user_ptr = (void __user *)ctrls->controls;
43092 + *user_ptr = (void __force_user *)ctrls->controls;
43093 *kernel_ptr = (void *)&ctrls->controls;
43094 *array_size = sizeof(struct v4l2_ext_control)
43095 * ctrls->count;
43096 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43097 index 767ff4d..c69d259 100644
43098 --- a/drivers/message/fusion/mptbase.c
43099 +++ b/drivers/message/fusion/mptbase.c
43100 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43101 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43102 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43103
43104 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43105 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43106 +#else
43107 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43108 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43109 +#endif
43110 +
43111 /*
43112 * Rounding UP to nearest 4-kB boundary here...
43113 */
43114 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43115 ioc->facts.GlobalCredits);
43116
43117 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43118 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43119 + NULL, NULL);
43120 +#else
43121 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43122 +#endif
43123 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43124 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43125 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43126 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43127 index dd239bd..689c4f7 100644
43128 --- a/drivers/message/fusion/mptsas.c
43129 +++ b/drivers/message/fusion/mptsas.c
43130 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43131 return 0;
43132 }
43133
43134 +static inline void
43135 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43136 +{
43137 + if (phy_info->port_details) {
43138 + phy_info->port_details->rphy = rphy;
43139 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43140 + ioc->name, rphy));
43141 + }
43142 +
43143 + if (rphy) {
43144 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43145 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43146 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43147 + ioc->name, rphy, rphy->dev.release));
43148 + }
43149 +}
43150 +
43151 /* no mutex */
43152 static void
43153 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43154 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43155 return NULL;
43156 }
43157
43158 -static inline void
43159 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43160 -{
43161 - if (phy_info->port_details) {
43162 - phy_info->port_details->rphy = rphy;
43163 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43164 - ioc->name, rphy));
43165 - }
43166 -
43167 - if (rphy) {
43168 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43169 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43170 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43171 - ioc->name, rphy, rphy->dev.release));
43172 - }
43173 -}
43174 -
43175 static inline struct sas_port *
43176 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43177 {
43178 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43179 index 727819c..ad74694 100644
43180 --- a/drivers/message/fusion/mptscsih.c
43181 +++ b/drivers/message/fusion/mptscsih.c
43182 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43183
43184 h = shost_priv(SChost);
43185
43186 - if (h) {
43187 - if (h->info_kbuf == NULL)
43188 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43189 - return h->info_kbuf;
43190 - h->info_kbuf[0] = '\0';
43191 + if (!h)
43192 + return NULL;
43193
43194 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43195 - h->info_kbuf[size-1] = '\0';
43196 - }
43197 + if (h->info_kbuf == NULL)
43198 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43199 + return h->info_kbuf;
43200 + h->info_kbuf[0] = '\0';
43201 +
43202 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43203 + h->info_kbuf[size-1] = '\0';
43204
43205 return h->info_kbuf;
43206 }
43207 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43208 index b7d87cd..9890039 100644
43209 --- a/drivers/message/i2o/i2o_proc.c
43210 +++ b/drivers/message/i2o/i2o_proc.c
43211 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43212 "Array Controller Device"
43213 };
43214
43215 -static char *chtostr(char *tmp, u8 *chars, int n)
43216 -{
43217 - tmp[0] = 0;
43218 - return strncat(tmp, (char *)chars, n);
43219 -}
43220 -
43221 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43222 char *group)
43223 {
43224 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43225 } *result;
43226
43227 i2o_exec_execute_ddm_table ddm_table;
43228 - char tmp[28 + 1];
43229
43230 result = kmalloc(sizeof(*result), GFP_KERNEL);
43231 if (!result)
43232 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43233
43234 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43235 seq_printf(seq, "%-#8x", ddm_table.module_id);
43236 - seq_printf(seq, "%-29s",
43237 - chtostr(tmp, ddm_table.module_name_version, 28));
43238 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43239 seq_printf(seq, "%9d ", ddm_table.data_size);
43240 seq_printf(seq, "%8d", ddm_table.code_size);
43241
43242 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43243
43244 i2o_driver_result_table *result;
43245 i2o_driver_store_table *dst;
43246 - char tmp[28 + 1];
43247
43248 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43249 if (result == NULL)
43250 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43251
43252 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43253 seq_printf(seq, "%-#8x", dst->module_id);
43254 - seq_printf(seq, "%-29s",
43255 - chtostr(tmp, dst->module_name_version, 28));
43256 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43257 + seq_printf(seq, "%-.28s", dst->module_name_version);
43258 + seq_printf(seq, "%-.8s", dst->date);
43259 seq_printf(seq, "%8d ", dst->module_size);
43260 seq_printf(seq, "%8d ", dst->mpb_size);
43261 seq_printf(seq, "0x%04x", dst->module_flags);
43262 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43263 // == (allow) 512d bytes (max)
43264 static u16 *work16 = (u16 *) work32;
43265 int token;
43266 - char tmp[16 + 1];
43267
43268 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43269
43270 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43271 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43272 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43273 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43274 - seq_printf(seq, "Vendor info : %s\n",
43275 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43276 - seq_printf(seq, "Product info : %s\n",
43277 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43278 - seq_printf(seq, "Description : %s\n",
43279 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43280 - seq_printf(seq, "Product rev. : %s\n",
43281 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43282 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43283 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43284 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43285 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43286
43287 seq_printf(seq, "Serial number : ");
43288 print_serial_number(seq, (u8 *) (work32 + 16),
43289 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43290 u8 pad[256]; // allow up to 256 byte (max) serial number
43291 } result;
43292
43293 - char tmp[24 + 1];
43294 -
43295 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43296
43297 if (token < 0) {
43298 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43299 }
43300
43301 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43302 - seq_printf(seq, "Module name : %s\n",
43303 - chtostr(tmp, result.module_name, 24));
43304 - seq_printf(seq, "Module revision : %s\n",
43305 - chtostr(tmp, result.module_rev, 8));
43306 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43307 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43308
43309 seq_printf(seq, "Serial number : ");
43310 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43311 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43312 u8 instance_number[4];
43313 } result;
43314
43315 - char tmp[64 + 1];
43316 -
43317 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43318
43319 if (token < 0) {
43320 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43321 return 0;
43322 }
43323
43324 - seq_printf(seq, "Device name : %s\n",
43325 - chtostr(tmp, result.device_name, 64));
43326 - seq_printf(seq, "Service name : %s\n",
43327 - chtostr(tmp, result.service_name, 64));
43328 - seq_printf(seq, "Physical name : %s\n",
43329 - chtostr(tmp, result.physical_location, 64));
43330 - seq_printf(seq, "Instance number : %s\n",
43331 - chtostr(tmp, result.instance_number, 4));
43332 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43333 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43334 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43335 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43336
43337 return 0;
43338 }
43339 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43340 index a8c08f3..155fe3d 100644
43341 --- a/drivers/message/i2o/iop.c
43342 +++ b/drivers/message/i2o/iop.c
43343 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43344
43345 spin_lock_irqsave(&c->context_list_lock, flags);
43346
43347 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43348 - atomic_inc(&c->context_list_counter);
43349 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43350 + atomic_inc_unchecked(&c->context_list_counter);
43351
43352 - entry->context = atomic_read(&c->context_list_counter);
43353 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43354
43355 list_add(&entry->list, &c->context_list);
43356
43357 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43358
43359 #if BITS_PER_LONG == 64
43360 spin_lock_init(&c->context_list_lock);
43361 - atomic_set(&c->context_list_counter, 0);
43362 + atomic_set_unchecked(&c->context_list_counter, 0);
43363 INIT_LIST_HEAD(&c->context_list);
43364 #endif
43365
43366 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43367 index fcbb2e9..2635e11 100644
43368 --- a/drivers/mfd/janz-cmodio.c
43369 +++ b/drivers/mfd/janz-cmodio.c
43370 @@ -13,6 +13,7 @@
43371
43372 #include <linux/kernel.h>
43373 #include <linux/module.h>
43374 +#include <linux/slab.h>
43375 #include <linux/init.h>
43376 #include <linux/pci.h>
43377 #include <linux/interrupt.h>
43378 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43379 index 9aa6d1e..1631bfc 100644
43380 --- a/drivers/mfd/twl4030-irq.c
43381 +++ b/drivers/mfd/twl4030-irq.c
43382 @@ -35,6 +35,7 @@
43383 #include <linux/of.h>
43384 #include <linux/irqdomain.h>
43385 #include <linux/i2c/twl.h>
43386 +#include <asm/pgtable.h>
43387
43388 #include "twl-core.h"
43389
43390 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43391 * Install an irq handler for each of the SIH modules;
43392 * clone dummy irq_chip since PIH can't *do* anything
43393 */
43394 - twl4030_irq_chip = dummy_irq_chip;
43395 - twl4030_irq_chip.name = "twl4030";
43396 + pax_open_kernel();
43397 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43398 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43399
43400 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43401 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43402 + pax_close_kernel();
43403
43404 for (i = irq_base; i < irq_end; i++) {
43405 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43406 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43407 index 277a8db..0e0b754 100644
43408 --- a/drivers/mfd/twl6030-irq.c
43409 +++ b/drivers/mfd/twl6030-irq.c
43410 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43411 * install an irq handler for each of the modules;
43412 * clone dummy irq_chip since PIH can't *do* anything
43413 */
43414 - twl6030_irq_chip = dummy_irq_chip;
43415 - twl6030_irq_chip.name = "twl6030";
43416 - twl6030_irq_chip.irq_set_type = NULL;
43417 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43418 + pax_open_kernel();
43419 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43420 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43421 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43422 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43423 + pax_close_kernel();
43424
43425 for (i = irq_base; i < irq_end; i++) {
43426 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43427 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43428 index f32550a..e3e52a2 100644
43429 --- a/drivers/misc/c2port/core.c
43430 +++ b/drivers/misc/c2port/core.c
43431 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43432 mutex_init(&c2dev->mutex);
43433
43434 /* Create binary file */
43435 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43436 + pax_open_kernel();
43437 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43438 + pax_close_kernel();
43439 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43440 if (unlikely(ret))
43441 goto error_device_create_bin_file;
43442 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43443 index 36f5d52..32311c3 100644
43444 --- a/drivers/misc/kgdbts.c
43445 +++ b/drivers/misc/kgdbts.c
43446 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43447 char before[BREAK_INSTR_SIZE];
43448 char after[BREAK_INSTR_SIZE];
43449
43450 - probe_kernel_read(before, (char *)kgdbts_break_test,
43451 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43452 BREAK_INSTR_SIZE);
43453 init_simple_test();
43454 ts.tst = plant_and_detach_test;
43455 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43456 /* Activate test with initial breakpoint */
43457 if (!is_early)
43458 kgdb_breakpoint();
43459 - probe_kernel_read(after, (char *)kgdbts_break_test,
43460 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43461 BREAK_INSTR_SIZE);
43462 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43463 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43464 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43465 index 036effe..b3a6336 100644
43466 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43467 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43468 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43469 * the lid is closed. This leads to interrupts as soon as a little move
43470 * is done.
43471 */
43472 - atomic_inc(&lis3->count);
43473 + atomic_inc_unchecked(&lis3->count);
43474
43475 wake_up_interruptible(&lis3->misc_wait);
43476 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43477 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43478 if (lis3->pm_dev)
43479 pm_runtime_get_sync(lis3->pm_dev);
43480
43481 - atomic_set(&lis3->count, 0);
43482 + atomic_set_unchecked(&lis3->count, 0);
43483 return 0;
43484 }
43485
43486 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43487 add_wait_queue(&lis3->misc_wait, &wait);
43488 while (true) {
43489 set_current_state(TASK_INTERRUPTIBLE);
43490 - data = atomic_xchg(&lis3->count, 0);
43491 + data = atomic_xchg_unchecked(&lis3->count, 0);
43492 if (data)
43493 break;
43494
43495 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43496 struct lis3lv02d, miscdev);
43497
43498 poll_wait(file, &lis3->misc_wait, wait);
43499 - if (atomic_read(&lis3->count))
43500 + if (atomic_read_unchecked(&lis3->count))
43501 return POLLIN | POLLRDNORM;
43502 return 0;
43503 }
43504 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43505 index c439c82..1f20f57 100644
43506 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43507 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43508 @@ -297,7 +297,7 @@ struct lis3lv02d {
43509 struct input_polled_dev *idev; /* input device */
43510 struct platform_device *pdev; /* platform device */
43511 struct regulator_bulk_data regulators[2];
43512 - atomic_t count; /* interrupt count after last read */
43513 + atomic_unchecked_t count; /* interrupt count after last read */
43514 union axis_conversion ac; /* hw -> logical axis */
43515 int mapped_btns[3];
43516
43517 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43518 index 2f30bad..c4c13d0 100644
43519 --- a/drivers/misc/sgi-gru/gruhandles.c
43520 +++ b/drivers/misc/sgi-gru/gruhandles.c
43521 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43522 unsigned long nsec;
43523
43524 nsec = CLKS2NSEC(clks);
43525 - atomic_long_inc(&mcs_op_statistics[op].count);
43526 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43527 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43528 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43529 if (mcs_op_statistics[op].max < nsec)
43530 mcs_op_statistics[op].max = nsec;
43531 }
43532 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43533 index 4f76359..cdfcb2e 100644
43534 --- a/drivers/misc/sgi-gru/gruprocfs.c
43535 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43536 @@ -32,9 +32,9 @@
43537
43538 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43539
43540 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43541 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43542 {
43543 - unsigned long val = atomic_long_read(v);
43544 + unsigned long val = atomic_long_read_unchecked(v);
43545
43546 seq_printf(s, "%16lu %s\n", val, id);
43547 }
43548 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43549
43550 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43551 for (op = 0; op < mcsop_last; op++) {
43552 - count = atomic_long_read(&mcs_op_statistics[op].count);
43553 - total = atomic_long_read(&mcs_op_statistics[op].total);
43554 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43555 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43556 max = mcs_op_statistics[op].max;
43557 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43558 count ? total / count : 0, max);
43559 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43560 index 5c3ce24..4915ccb 100644
43561 --- a/drivers/misc/sgi-gru/grutables.h
43562 +++ b/drivers/misc/sgi-gru/grutables.h
43563 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43564 * GRU statistics.
43565 */
43566 struct gru_stats_s {
43567 - atomic_long_t vdata_alloc;
43568 - atomic_long_t vdata_free;
43569 - atomic_long_t gts_alloc;
43570 - atomic_long_t gts_free;
43571 - atomic_long_t gms_alloc;
43572 - atomic_long_t gms_free;
43573 - atomic_long_t gts_double_allocate;
43574 - atomic_long_t assign_context;
43575 - atomic_long_t assign_context_failed;
43576 - atomic_long_t free_context;
43577 - atomic_long_t load_user_context;
43578 - atomic_long_t load_kernel_context;
43579 - atomic_long_t lock_kernel_context;
43580 - atomic_long_t unlock_kernel_context;
43581 - atomic_long_t steal_user_context;
43582 - atomic_long_t steal_kernel_context;
43583 - atomic_long_t steal_context_failed;
43584 - atomic_long_t nopfn;
43585 - atomic_long_t asid_new;
43586 - atomic_long_t asid_next;
43587 - atomic_long_t asid_wrap;
43588 - atomic_long_t asid_reuse;
43589 - atomic_long_t intr;
43590 - atomic_long_t intr_cbr;
43591 - atomic_long_t intr_tfh;
43592 - atomic_long_t intr_spurious;
43593 - atomic_long_t intr_mm_lock_failed;
43594 - atomic_long_t call_os;
43595 - atomic_long_t call_os_wait_queue;
43596 - atomic_long_t user_flush_tlb;
43597 - atomic_long_t user_unload_context;
43598 - atomic_long_t user_exception;
43599 - atomic_long_t set_context_option;
43600 - atomic_long_t check_context_retarget_intr;
43601 - atomic_long_t check_context_unload;
43602 - atomic_long_t tlb_dropin;
43603 - atomic_long_t tlb_preload_page;
43604 - atomic_long_t tlb_dropin_fail_no_asid;
43605 - atomic_long_t tlb_dropin_fail_upm;
43606 - atomic_long_t tlb_dropin_fail_invalid;
43607 - atomic_long_t tlb_dropin_fail_range_active;
43608 - atomic_long_t tlb_dropin_fail_idle;
43609 - atomic_long_t tlb_dropin_fail_fmm;
43610 - atomic_long_t tlb_dropin_fail_no_exception;
43611 - atomic_long_t tfh_stale_on_fault;
43612 - atomic_long_t mmu_invalidate_range;
43613 - atomic_long_t mmu_invalidate_page;
43614 - atomic_long_t flush_tlb;
43615 - atomic_long_t flush_tlb_gru;
43616 - atomic_long_t flush_tlb_gru_tgh;
43617 - atomic_long_t flush_tlb_gru_zero_asid;
43618 + atomic_long_unchecked_t vdata_alloc;
43619 + atomic_long_unchecked_t vdata_free;
43620 + atomic_long_unchecked_t gts_alloc;
43621 + atomic_long_unchecked_t gts_free;
43622 + atomic_long_unchecked_t gms_alloc;
43623 + atomic_long_unchecked_t gms_free;
43624 + atomic_long_unchecked_t gts_double_allocate;
43625 + atomic_long_unchecked_t assign_context;
43626 + atomic_long_unchecked_t assign_context_failed;
43627 + atomic_long_unchecked_t free_context;
43628 + atomic_long_unchecked_t load_user_context;
43629 + atomic_long_unchecked_t load_kernel_context;
43630 + atomic_long_unchecked_t lock_kernel_context;
43631 + atomic_long_unchecked_t unlock_kernel_context;
43632 + atomic_long_unchecked_t steal_user_context;
43633 + atomic_long_unchecked_t steal_kernel_context;
43634 + atomic_long_unchecked_t steal_context_failed;
43635 + atomic_long_unchecked_t nopfn;
43636 + atomic_long_unchecked_t asid_new;
43637 + atomic_long_unchecked_t asid_next;
43638 + atomic_long_unchecked_t asid_wrap;
43639 + atomic_long_unchecked_t asid_reuse;
43640 + atomic_long_unchecked_t intr;
43641 + atomic_long_unchecked_t intr_cbr;
43642 + atomic_long_unchecked_t intr_tfh;
43643 + atomic_long_unchecked_t intr_spurious;
43644 + atomic_long_unchecked_t intr_mm_lock_failed;
43645 + atomic_long_unchecked_t call_os;
43646 + atomic_long_unchecked_t call_os_wait_queue;
43647 + atomic_long_unchecked_t user_flush_tlb;
43648 + atomic_long_unchecked_t user_unload_context;
43649 + atomic_long_unchecked_t user_exception;
43650 + atomic_long_unchecked_t set_context_option;
43651 + atomic_long_unchecked_t check_context_retarget_intr;
43652 + atomic_long_unchecked_t check_context_unload;
43653 + atomic_long_unchecked_t tlb_dropin;
43654 + atomic_long_unchecked_t tlb_preload_page;
43655 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43656 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43657 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43658 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43659 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43660 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43661 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43662 + atomic_long_unchecked_t tfh_stale_on_fault;
43663 + atomic_long_unchecked_t mmu_invalidate_range;
43664 + atomic_long_unchecked_t mmu_invalidate_page;
43665 + atomic_long_unchecked_t flush_tlb;
43666 + atomic_long_unchecked_t flush_tlb_gru;
43667 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43668 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43669
43670 - atomic_long_t copy_gpa;
43671 - atomic_long_t read_gpa;
43672 + atomic_long_unchecked_t copy_gpa;
43673 + atomic_long_unchecked_t read_gpa;
43674
43675 - atomic_long_t mesq_receive;
43676 - atomic_long_t mesq_receive_none;
43677 - atomic_long_t mesq_send;
43678 - atomic_long_t mesq_send_failed;
43679 - atomic_long_t mesq_noop;
43680 - atomic_long_t mesq_send_unexpected_error;
43681 - atomic_long_t mesq_send_lb_overflow;
43682 - atomic_long_t mesq_send_qlimit_reached;
43683 - atomic_long_t mesq_send_amo_nacked;
43684 - atomic_long_t mesq_send_put_nacked;
43685 - atomic_long_t mesq_page_overflow;
43686 - atomic_long_t mesq_qf_locked;
43687 - atomic_long_t mesq_qf_noop_not_full;
43688 - atomic_long_t mesq_qf_switch_head_failed;
43689 - atomic_long_t mesq_qf_unexpected_error;
43690 - atomic_long_t mesq_noop_unexpected_error;
43691 - atomic_long_t mesq_noop_lb_overflow;
43692 - atomic_long_t mesq_noop_qlimit_reached;
43693 - atomic_long_t mesq_noop_amo_nacked;
43694 - atomic_long_t mesq_noop_put_nacked;
43695 - atomic_long_t mesq_noop_page_overflow;
43696 + atomic_long_unchecked_t mesq_receive;
43697 + atomic_long_unchecked_t mesq_receive_none;
43698 + atomic_long_unchecked_t mesq_send;
43699 + atomic_long_unchecked_t mesq_send_failed;
43700 + atomic_long_unchecked_t mesq_noop;
43701 + atomic_long_unchecked_t mesq_send_unexpected_error;
43702 + atomic_long_unchecked_t mesq_send_lb_overflow;
43703 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43704 + atomic_long_unchecked_t mesq_send_amo_nacked;
43705 + atomic_long_unchecked_t mesq_send_put_nacked;
43706 + atomic_long_unchecked_t mesq_page_overflow;
43707 + atomic_long_unchecked_t mesq_qf_locked;
43708 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43709 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43710 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43711 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43712 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43713 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43714 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43715 + atomic_long_unchecked_t mesq_noop_put_nacked;
43716 + atomic_long_unchecked_t mesq_noop_page_overflow;
43717
43718 };
43719
43720 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43721 tghop_invalidate, mcsop_last};
43722
43723 struct mcs_op_statistic {
43724 - atomic_long_t count;
43725 - atomic_long_t total;
43726 + atomic_long_unchecked_t count;
43727 + atomic_long_unchecked_t total;
43728 unsigned long max;
43729 };
43730
43731 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43732
43733 #define STAT(id) do { \
43734 if (gru_options & OPT_STATS) \
43735 - atomic_long_inc(&gru_stats.id); \
43736 + atomic_long_inc_unchecked(&gru_stats.id); \
43737 } while (0)
43738
43739 #ifdef CONFIG_SGI_GRU_DEBUG
43740 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43741 index c862cd4..0d176fe 100644
43742 --- a/drivers/misc/sgi-xp/xp.h
43743 +++ b/drivers/misc/sgi-xp/xp.h
43744 @@ -288,7 +288,7 @@ struct xpc_interface {
43745 xpc_notify_func, void *);
43746 void (*received) (short, int, void *);
43747 enum xp_retval (*partid_to_nasids) (short, void *);
43748 -};
43749 +} __no_const;
43750
43751 extern struct xpc_interface xpc_interface;
43752
43753 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43754 index b94d5f7..7f494c5 100644
43755 --- a/drivers/misc/sgi-xp/xpc.h
43756 +++ b/drivers/misc/sgi-xp/xpc.h
43757 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43758 void (*received_payload) (struct xpc_channel *, void *);
43759 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43760 };
43761 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43762
43763 /* struct xpc_partition act_state values (for XPC HB) */
43764
43765 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43766 /* found in xpc_main.c */
43767 extern struct device *xpc_part;
43768 extern struct device *xpc_chan;
43769 -extern struct xpc_arch_operations xpc_arch_ops;
43770 +extern xpc_arch_operations_no_const xpc_arch_ops;
43771 extern int xpc_disengage_timelimit;
43772 extern int xpc_disengage_timedout;
43773 extern int xpc_activate_IRQ_rcvd;
43774 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43775 index 82dc574..8539ab2 100644
43776 --- a/drivers/misc/sgi-xp/xpc_main.c
43777 +++ b/drivers/misc/sgi-xp/xpc_main.c
43778 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43779 .notifier_call = xpc_system_die,
43780 };
43781
43782 -struct xpc_arch_operations xpc_arch_ops;
43783 +xpc_arch_operations_no_const xpc_arch_ops;
43784
43785 /*
43786 * Timer function to enforce the timelimit on the partition disengage.
43787 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43788
43789 if (((die_args->trapnr == X86_TRAP_MF) ||
43790 (die_args->trapnr == X86_TRAP_XF)) &&
43791 - !user_mode_vm(die_args->regs))
43792 + !user_mode(die_args->regs))
43793 xpc_die_deactivate();
43794
43795 break;
43796 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43797 index 837fc73..acb5862 100644
43798 --- a/drivers/mmc/core/mmc_ops.c
43799 +++ b/drivers/mmc/core/mmc_ops.c
43800 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43801 void *data_buf;
43802 int is_on_stack;
43803
43804 - is_on_stack = object_is_on_stack(buf);
43805 + is_on_stack = object_starts_on_stack(buf);
43806 if (is_on_stack) {
43807 /*
43808 * dma onto stack is unsafe/nonportable, but callers to this
43809 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43810 index 81b2994..dce857e 100644
43811 --- a/drivers/mmc/host/dw_mmc.h
43812 +++ b/drivers/mmc/host/dw_mmc.h
43813 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43814 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43815 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43816 int (*parse_dt)(struct dw_mci *host);
43817 -};
43818 +} __do_const;
43819 #endif /* _DW_MMC_H_ */
43820 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43821 index c3785ed..1984c44 100644
43822 --- a/drivers/mmc/host/mmci.c
43823 +++ b/drivers/mmc/host/mmci.c
43824 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43825 }
43826
43827 if (variant->busy_detect) {
43828 - mmci_ops.card_busy = mmci_card_busy;
43829 + pax_open_kernel();
43830 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43831 + pax_close_kernel();
43832 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43833 }
43834
43835 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43836 index 926aaf6..8e153e2 100644
43837 --- a/drivers/mmc/host/sdhci-s3c.c
43838 +++ b/drivers/mmc/host/sdhci-s3c.c
43839 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43840 * we can use overriding functions instead of default.
43841 */
43842 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43843 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43844 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43845 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43846 + pax_open_kernel();
43847 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43848 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43849 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43850 + pax_close_kernel();
43851 }
43852
43853 /* It supports additional host capabilities if needed */
43854 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43855 index 0c8bb6b..6f35deb 100644
43856 --- a/drivers/mtd/nand/denali.c
43857 +++ b/drivers/mtd/nand/denali.c
43858 @@ -24,6 +24,7 @@
43859 #include <linux/slab.h>
43860 #include <linux/mtd/mtd.h>
43861 #include <linux/module.h>
43862 +#include <linux/slab.h>
43863
43864 #include "denali.h"
43865
43866 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43867 index 51b9d6a..52af9a7 100644
43868 --- a/drivers/mtd/nftlmount.c
43869 +++ b/drivers/mtd/nftlmount.c
43870 @@ -24,6 +24,7 @@
43871 #include <asm/errno.h>
43872 #include <linux/delay.h>
43873 #include <linux/slab.h>
43874 +#include <linux/sched.h>
43875 #include <linux/mtd/mtd.h>
43876 #include <linux/mtd/nand.h>
43877 #include <linux/mtd/nftl.h>
43878 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43879 index f9d5615..99dd95f 100644
43880 --- a/drivers/mtd/sm_ftl.c
43881 +++ b/drivers/mtd/sm_ftl.c
43882 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43883 #define SM_CIS_VENDOR_OFFSET 0x59
43884 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43885 {
43886 - struct attribute_group *attr_group;
43887 + attribute_group_no_const *attr_group;
43888 struct attribute **attributes;
43889 struct sm_sysfs_attribute *vendor_attribute;
43890
43891 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43892 index 5e31046..82f8ddc 100644
43893 --- a/drivers/net/bonding/bond_main.c
43894 +++ b/drivers/net/bonding/bond_main.c
43895 @@ -4839,7 +4839,7 @@ static unsigned int bond_get_num_tx_queues(void)
43896 return tx_queues;
43897 }
43898
43899 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43900 +static struct rtnl_link_ops bond_link_ops = {
43901 .kind = "bond",
43902 .priv_size = sizeof(struct bonding),
43903 .setup = bond_setup,
43904 @@ -4964,8 +4964,8 @@ static void __exit bonding_exit(void)
43905
43906 bond_destroy_debugfs();
43907
43908 - rtnl_link_unregister(&bond_link_ops);
43909 unregister_pernet_subsys(&bond_net_ops);
43910 + rtnl_link_unregister(&bond_link_ops);
43911
43912 #ifdef CONFIG_NET_POLL_CONTROLLER
43913 /*
43914 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43915 index e1d2643..7f4133b 100644
43916 --- a/drivers/net/ethernet/8390/ax88796.c
43917 +++ b/drivers/net/ethernet/8390/ax88796.c
43918 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43919 if (ax->plat->reg_offsets)
43920 ei_local->reg_offset = ax->plat->reg_offsets;
43921 else {
43922 + resource_size_t _mem_size = mem_size;
43923 + do_div(_mem_size, 0x18);
43924 ei_local->reg_offset = ax->reg_offsets;
43925 for (ret = 0; ret < 0x18; ret++)
43926 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43927 + ax->reg_offsets[ret] = _mem_size * ret;
43928 }
43929
43930 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43931 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43932 index c07a6d0..ca88c45 100644
43933 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43934 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43935 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43936 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43937 {
43938 /* RX_MODE controlling object */
43939 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43940 + bnx2x_init_rx_mode_obj(bp);
43941
43942 /* multicast configuration controlling object */
43943 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43944 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43945 index 8f03c98..dd0ef10 100644
43946 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43947 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43948 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43949 return rc;
43950 }
43951
43952 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43953 - struct bnx2x_rx_mode_obj *o)
43954 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43955 {
43956 if (CHIP_IS_E1x(bp)) {
43957 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43958 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43959 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43960 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43961 } else {
43962 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43963 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43964 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43965 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43966 }
43967 }
43968
43969 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43970 index 798dfe9..05d0a44 100644
43971 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43972 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43973 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43974
43975 /********************* RX MODE ****************/
43976
43977 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43978 - struct bnx2x_rx_mode_obj *o);
43979 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43980
43981 /**
43982 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43983 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43984 index cd63d11..b67dd78 100644
43985 --- a/drivers/net/ethernet/broadcom/tg3.h
43986 +++ b/drivers/net/ethernet/broadcom/tg3.h
43987 @@ -147,6 +147,7 @@
43988 #define CHIPREV_ID_5750_A0 0x4000
43989 #define CHIPREV_ID_5750_A1 0x4001
43990 #define CHIPREV_ID_5750_A3 0x4003
43991 +#define CHIPREV_ID_5750_C1 0x4201
43992 #define CHIPREV_ID_5750_C2 0x4202
43993 #define CHIPREV_ID_5752_A0_HW 0x5000
43994 #define CHIPREV_ID_5752_A0 0x6000
43995 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43996 index 8cffcdf..aadf043 100644
43997 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43998 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43999 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44000 */
44001 struct l2t_skb_cb {
44002 arp_failure_handler_func arp_failure_handler;
44003 -};
44004 +} __no_const;
44005
44006 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44007
44008 diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c
44009 index 9c89dc8..725ecc3 100644
44010 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
44011 +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
44012 @@ -1599,7 +1599,7 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
44013 flits = skb_transport_offset(skb) / 8;
44014 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
44015 sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
44016 - skb->tail - skb->transport_header,
44017 + skb_tail_pointer(skb) - skb_transport_header(skb),
44018 adap->pdev);
44019 if (need_skb_unmap()) {
44020 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
44021 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44022 index 4c83003..2a2a5b9 100644
44023 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44024 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44025 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44026 for (i=0; i<ETH_ALEN; i++) {
44027 tmp.addr[i] = dev->dev_addr[i];
44028 }
44029 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44030 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44031 break;
44032
44033 case DE4X5_SET_HWADDR: /* Set the hardware address */
44034 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44035 spin_lock_irqsave(&lp->lock, flags);
44036 memcpy(&statbuf, &lp->pktStats, ioc->len);
44037 spin_unlock_irqrestore(&lp->lock, flags);
44038 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44039 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44040 return -EFAULT;
44041 break;
44042 }
44043 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44044 index 3d91a5e..1014702 100644
44045 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44046 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44047 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44048
44049 if (wrapped)
44050 newacc += 65536;
44051 - ACCESS_ONCE(*acc) = newacc;
44052 + ACCESS_ONCE_RW(*acc) = newacc;
44053 }
44054
44055 void populate_erx_stats(struct be_adapter *adapter,
44056 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44057 index 934e1ae..b262e6b 100644
44058 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44059 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44060 @@ -31,6 +31,8 @@
44061 #include <linux/netdevice.h>
44062 #include <linux/phy.h>
44063 #include <linux/platform_device.h>
44064 +#include <linux/interrupt.h>
44065 +#include <linux/irqreturn.h>
44066 #include <net/ip.h>
44067
44068 #include "ftgmac100.h"
44069 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44070 index 4658f4c..407d155 100644
44071 --- a/drivers/net/ethernet/faraday/ftmac100.c
44072 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44073 @@ -31,6 +31,8 @@
44074 #include <linux/module.h>
44075 #include <linux/netdevice.h>
44076 #include <linux/platform_device.h>
44077 +#include <linux/interrupt.h>
44078 +#include <linux/irqreturn.h>
44079
44080 #include "ftmac100.h"
44081
44082 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44083 index 331987d..3be1135 100644
44084 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44085 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44086 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44087 }
44088
44089 /* update the base incval used to calculate frequency adjustment */
44090 - ACCESS_ONCE(adapter->base_incval) = incval;
44091 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44092 smp_mb();
44093
44094 /* need lock to prevent incorrect read while modifying cyclecounter */
44095 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44096 index fbe5363..266b4e3 100644
44097 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44098 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44099 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44100 struct __vxge_hw_fifo *fifo;
44101 struct vxge_hw_fifo_config *config;
44102 u32 txdl_size, txdl_per_memblock;
44103 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44104 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44105 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44106 + };
44107 +
44108 struct __vxge_hw_virtualpath *vpath;
44109
44110 if ((vp == NULL) || (attr == NULL)) {
44111 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44112 goto exit;
44113 }
44114
44115 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44116 -
44117 fifo->mempool =
44118 __vxge_hw_mempool_create(vpath->hldev,
44119 fifo->config->memblock_size,
44120 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44121 index 345d987..af69721 100644
44122 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44123 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44124 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44125 op_mode = QLC_83XX_DEFAULT_OPMODE;
44126
44127 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44128 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44129 + pax_open_kernel();
44130 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44131 + pax_close_kernel();
44132 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44133 } else {
44134 return -EIO;
44135 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44136 index 599d1fd..59868fe 100644
44137 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44138 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44139 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44140 case QLCNIC_NON_PRIV_FUNC:
44141 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44142 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44143 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44144 + pax_open_kernel();
44145 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44146 + pax_close_kernel();
44147 break;
44148 case QLCNIC_PRIV_FUNC:
44149 ahw->op_mode = QLCNIC_PRIV_FUNC;
44150 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44151 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44152 + pax_open_kernel();
44153 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44154 + pax_close_kernel();
44155 break;
44156 case QLCNIC_MGMT_FUNC:
44157 ahw->op_mode = QLCNIC_MGMT_FUNC;
44158 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44159 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44160 + pax_open_kernel();
44161 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44162 + pax_close_kernel();
44163 break;
44164 default:
44165 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44166 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44167 index 7ba68e0..618c73d 100644
44168 --- a/drivers/net/ethernet/realtek/r8169.c
44169 +++ b/drivers/net/ethernet/realtek/r8169.c
44170 @@ -759,22 +759,22 @@ struct rtl8169_private {
44171 struct mdio_ops {
44172 void (*write)(struct rtl8169_private *, int, int);
44173 int (*read)(struct rtl8169_private *, int);
44174 - } mdio_ops;
44175 + } __no_const mdio_ops;
44176
44177 struct pll_power_ops {
44178 void (*down)(struct rtl8169_private *);
44179 void (*up)(struct rtl8169_private *);
44180 - } pll_power_ops;
44181 + } __no_const pll_power_ops;
44182
44183 struct jumbo_ops {
44184 void (*enable)(struct rtl8169_private *);
44185 void (*disable)(struct rtl8169_private *);
44186 - } jumbo_ops;
44187 + } __no_const jumbo_ops;
44188
44189 struct csi_ops {
44190 void (*write)(struct rtl8169_private *, int, int);
44191 u32 (*read)(struct rtl8169_private *, int);
44192 - } csi_ops;
44193 + } __no_const csi_ops;
44194
44195 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44196 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44197 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44198 index b495394..0748c54 100644
44199 --- a/drivers/net/ethernet/sfc/ptp.c
44200 +++ b/drivers/net/ethernet/sfc/ptp.c
44201 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44202 (u32)((u64)ptp->start.dma_addr >> 32));
44203
44204 /* Clear flag that signals MC ready */
44205 - ACCESS_ONCE(*start) = 0;
44206 + ACCESS_ONCE_RW(*start) = 0;
44207 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44208 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44209
44210 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44211 index 50617c5..b13724c 100644
44212 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44213 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44214 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44215
44216 writel(value, ioaddr + MMC_CNTRL);
44217
44218 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44219 - MMC_CNTRL, value);
44220 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44221 +// MMC_CNTRL, value);
44222 }
44223
44224 /* To mask all all interrupts.*/
44225 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44226 index e6fe0d8..2b7d752 100644
44227 --- a/drivers/net/hyperv/hyperv_net.h
44228 +++ b/drivers/net/hyperv/hyperv_net.h
44229 @@ -101,7 +101,7 @@ struct rndis_device {
44230
44231 enum rndis_device_state state;
44232 bool link_state;
44233 - atomic_t new_req_id;
44234 + atomic_unchecked_t new_req_id;
44235
44236 spinlock_t request_lock;
44237 struct list_head req_list;
44238 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44239 index 0775f0a..d4fb316 100644
44240 --- a/drivers/net/hyperv/rndis_filter.c
44241 +++ b/drivers/net/hyperv/rndis_filter.c
44242 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44243 * template
44244 */
44245 set = &rndis_msg->msg.set_req;
44246 - set->req_id = atomic_inc_return(&dev->new_req_id);
44247 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44248
44249 /* Add to the request list */
44250 spin_lock_irqsave(&dev->request_lock, flags);
44251 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44252
44253 /* Setup the rndis set */
44254 halt = &request->request_msg.msg.halt_req;
44255 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44256 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44257
44258 /* Ignore return since this msg is optional. */
44259 rndis_filter_send_request(dev, request);
44260 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44261 index bf0d55e..82bcfbd1 100644
44262 --- a/drivers/net/ieee802154/fakehard.c
44263 +++ b/drivers/net/ieee802154/fakehard.c
44264 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44265 phy->transmit_power = 0xbf;
44266
44267 dev->netdev_ops = &fake_ops;
44268 - dev->ml_priv = &fake_mlme;
44269 + dev->ml_priv = (void *)&fake_mlme;
44270
44271 priv = netdev_priv(dev);
44272 priv->phy = phy;
44273 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44274 index 16b43bf..ead0c35 100644
44275 --- a/drivers/net/macvlan.c
44276 +++ b/drivers/net/macvlan.c
44277 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44278 int macvlan_link_register(struct rtnl_link_ops *ops)
44279 {
44280 /* common fields */
44281 - ops->priv_size = sizeof(struct macvlan_dev);
44282 - ops->validate = macvlan_validate;
44283 - ops->maxtype = IFLA_MACVLAN_MAX;
44284 - ops->policy = macvlan_policy;
44285 - ops->changelink = macvlan_changelink;
44286 - ops->get_size = macvlan_get_size;
44287 - ops->fill_info = macvlan_fill_info;
44288 + pax_open_kernel();
44289 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44290 + *(void **)&ops->validate = macvlan_validate;
44291 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44292 + *(const void **)&ops->policy = macvlan_policy;
44293 + *(void **)&ops->changelink = macvlan_changelink;
44294 + *(void **)&ops->get_size = macvlan_get_size;
44295 + *(void **)&ops->fill_info = macvlan_fill_info;
44296 + pax_close_kernel();
44297
44298 return rtnl_link_register(ops);
44299 };
44300 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44301 return NOTIFY_DONE;
44302 }
44303
44304 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44305 +static struct notifier_block macvlan_notifier_block = {
44306 .notifier_call = macvlan_device_event,
44307 };
44308
44309 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44310 index ea53abb..2e4d087 100644
44311 --- a/drivers/net/macvtap.c
44312 +++ b/drivers/net/macvtap.c
44313 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44314 return NOTIFY_DONE;
44315 }
44316
44317 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44318 +static struct notifier_block macvtap_notifier_block = {
44319 .notifier_call = macvtap_device_event,
44320 };
44321
44322 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44323 index daec9b0..6428fcb 100644
44324 --- a/drivers/net/phy/mdio-bitbang.c
44325 +++ b/drivers/net/phy/mdio-bitbang.c
44326 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44327 struct mdiobb_ctrl *ctrl = bus->priv;
44328
44329 module_put(ctrl->ops->owner);
44330 + mdiobus_unregister(bus);
44331 mdiobus_free(bus);
44332 }
44333 EXPORT_SYMBOL(free_mdio_bitbang);
44334 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44335 index 72ff14b..11d442d 100644
44336 --- a/drivers/net/ppp/ppp_generic.c
44337 +++ b/drivers/net/ppp/ppp_generic.c
44338 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44339 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44340 struct ppp_stats stats;
44341 struct ppp_comp_stats cstats;
44342 - char *vers;
44343
44344 switch (cmd) {
44345 case SIOCGPPPSTATS:
44346 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44347 break;
44348
44349 case SIOCGPPPVER:
44350 - vers = PPP_VERSION;
44351 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44352 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44353 break;
44354 err = 0;
44355 break;
44356 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44357 index 1252d9c..80e660b 100644
44358 --- a/drivers/net/slip/slhc.c
44359 +++ b/drivers/net/slip/slhc.c
44360 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44361 register struct tcphdr *thp;
44362 register struct iphdr *ip;
44363 register struct cstate *cs;
44364 - int len, hdrlen;
44365 + long len, hdrlen;
44366 unsigned char *cp = icp;
44367
44368 /* We've got a compressed packet; read the change byte */
44369 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44370 index bff7e0b..7315137 100644
44371 --- a/drivers/net/team/team.c
44372 +++ b/drivers/net/team/team.c
44373 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44374 return NOTIFY_DONE;
44375 }
44376
44377 -static struct notifier_block team_notifier_block __read_mostly = {
44378 +static struct notifier_block team_notifier_block = {
44379 .notifier_call = team_device_event,
44380 };
44381
44382 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44383 index 68b9aa3..b3c20f3 100644
44384 --- a/drivers/net/tun.c
44385 +++ b/drivers/net/tun.c
44386 @@ -1874,7 +1874,7 @@ unlock:
44387 }
44388
44389 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44390 - unsigned long arg, int ifreq_len)
44391 + unsigned long arg, size_t ifreq_len)
44392 {
44393 struct tun_file *tfile = file->private_data;
44394 struct tun_struct *tun;
44395 @@ -1886,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44396 int vnet_hdr_sz;
44397 int ret;
44398
44399 + if (ifreq_len > sizeof ifr)
44400 + return -EFAULT;
44401 +
44402 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44403 if (copy_from_user(&ifr, argp, ifreq_len))
44404 return -EFAULT;
44405 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44406 index 86292e6..8d34433 100644
44407 --- a/drivers/net/usb/hso.c
44408 +++ b/drivers/net/usb/hso.c
44409 @@ -71,7 +71,7 @@
44410 #include <asm/byteorder.h>
44411 #include <linux/serial_core.h>
44412 #include <linux/serial.h>
44413 -
44414 +#include <asm/local.h>
44415
44416 #define MOD_AUTHOR "Option Wireless"
44417 #define MOD_DESCRIPTION "USB High Speed Option driver"
44418 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44419 struct urb *urb;
44420
44421 urb = serial->rx_urb[0];
44422 - if (serial->port.count > 0) {
44423 + if (atomic_read(&serial->port.count) > 0) {
44424 count = put_rxbuf_data(urb, serial);
44425 if (count == -1)
44426 return;
44427 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44428 DUMP1(urb->transfer_buffer, urb->actual_length);
44429
44430 /* Anyone listening? */
44431 - if (serial->port.count == 0)
44432 + if (atomic_read(&serial->port.count) == 0)
44433 return;
44434
44435 if (status == 0) {
44436 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44437 tty_port_tty_set(&serial->port, tty);
44438
44439 /* check for port already opened, if not set the termios */
44440 - serial->port.count++;
44441 - if (serial->port.count == 1) {
44442 + if (atomic_inc_return(&serial->port.count) == 1) {
44443 serial->rx_state = RX_IDLE;
44444 /* Force default termio settings */
44445 _hso_serial_set_termios(tty, NULL);
44446 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44447 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44448 if (result) {
44449 hso_stop_serial_device(serial->parent);
44450 - serial->port.count--;
44451 + atomic_dec(&serial->port.count);
44452 kref_put(&serial->parent->ref, hso_serial_ref_free);
44453 }
44454 } else {
44455 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44456
44457 /* reset the rts and dtr */
44458 /* do the actual close */
44459 - serial->port.count--;
44460 + atomic_dec(&serial->port.count);
44461
44462 - if (serial->port.count <= 0) {
44463 - serial->port.count = 0;
44464 + if (atomic_read(&serial->port.count) <= 0) {
44465 + atomic_set(&serial->port.count, 0);
44466 tty_port_tty_set(&serial->port, NULL);
44467 if (!usb_gone)
44468 hso_stop_serial_device(serial->parent);
44469 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44470
44471 /* the actual setup */
44472 spin_lock_irqsave(&serial->serial_lock, flags);
44473 - if (serial->port.count)
44474 + if (atomic_read(&serial->port.count))
44475 _hso_serial_set_termios(tty, old);
44476 else
44477 tty->termios = *old;
44478 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44479 D1("Pending read interrupt on port %d\n", i);
44480 spin_lock(&serial->serial_lock);
44481 if (serial->rx_state == RX_IDLE &&
44482 - serial->port.count > 0) {
44483 + atomic_read(&serial->port.count) > 0) {
44484 /* Setup and send a ctrl req read on
44485 * port i */
44486 if (!serial->rx_urb_filled[0]) {
44487 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44488 /* Start all serial ports */
44489 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44490 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44491 - if (dev2ser(serial_table[i])->port.count) {
44492 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44493 result =
44494 hso_start_serial_device(serial_table[i], GFP_NOIO);
44495 hso_kick_transmit(dev2ser(serial_table[i]));
44496 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44497 index a79e9d3..78cd4fa 100644
44498 --- a/drivers/net/usb/sierra_net.c
44499 +++ b/drivers/net/usb/sierra_net.c
44500 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44501 /* atomic counter partially included in MAC address to make sure 2 devices
44502 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44503 */
44504 -static atomic_t iface_counter = ATOMIC_INIT(0);
44505 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44506
44507 /*
44508 * SYNC Timer Delay definition used to set the expiry time
44509 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44510 dev->net->netdev_ops = &sierra_net_device_ops;
44511
44512 /* change MAC addr to include, ifacenum, and to be unique */
44513 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44514 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44515 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44516
44517 /* we will have to manufacture ethernet headers, prepare template */
44518 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44519 index 8a05d77..ba8b9c5 100644
44520 --- a/drivers/net/vxlan.c
44521 +++ b/drivers/net/vxlan.c
44522 @@ -1870,7 +1870,7 @@ nla_put_failure:
44523 return -EMSGSIZE;
44524 }
44525
44526 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44527 +static struct rtnl_link_ops vxlan_link_ops = {
44528 .kind = "vxlan",
44529 .maxtype = IFLA_VXLAN_MAX,
44530 .policy = vxlan_policy,
44531 diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
44532 index 3f0c4f2..bcfff0d 100644
44533 --- a/drivers/net/wan/farsync.c
44534 +++ b/drivers/net/wan/farsync.c
44535 @@ -1972,6 +1972,7 @@ fst_get_iface(struct fst_card_info *card, struct fst_port_info *port,
44536 }
44537
44538 i = port->index;
44539 + memset(&sync, 0, sizeof(sync));
44540 sync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed);
44541 /* Lucky card and linux use same encoding here */
44542 sync.clock_type = FST_RDB(card, portConfig[i].internalClock) ==
44543 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44544 index 0b60295..b8bfa5b 100644
44545 --- a/drivers/net/wimax/i2400m/rx.c
44546 +++ b/drivers/net/wimax/i2400m/rx.c
44547 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44548 if (i2400m->rx_roq == NULL)
44549 goto error_roq_alloc;
44550
44551 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44552 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44553 GFP_KERNEL);
44554 if (rd == NULL) {
44555 result = -ENOMEM;
44556 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44557 index 34c8a33..3261fdc 100644
44558 --- a/drivers/net/wireless/at76c50x-usb.c
44559 +++ b/drivers/net/wireless/at76c50x-usb.c
44560 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44561 }
44562
44563 /* Convert timeout from the DFU status to jiffies */
44564 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44565 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44566 {
44567 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44568 | (s->poll_timeout[1] << 8)
44569 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44570 index 2b3426b..1f564be 100644
44571 --- a/drivers/net/wireless/ath/ath10k/core.c
44572 +++ b/drivers/net/wireless/ath/ath10k/core.c
44573 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44574
44575 int ath10k_core_register(struct ath10k *ar)
44576 {
44577 - struct ath10k_htc_ops htc_ops;
44578 + static struct ath10k_htc_ops htc_ops = {
44579 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44580 + };
44581 struct bmi_target_info target_info;
44582 int status;
44583
44584 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44585 if (status)
44586 goto err;
44587
44588 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44589 -
44590 ar->htc = ath10k_htc_create(ar, &htc_ops);
44591 if (IS_ERR(ar->htc)) {
44592 status = PTR_ERR(ar->htc);
44593 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44594 index 74363c9..237b926 100644
44595 --- a/drivers/net/wireless/ath/ath10k/htc.c
44596 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44597 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44598 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44599 struct ath10k_htc_ops *htc_ops)
44600 {
44601 - struct ath10k_hif_cb htc_callbacks;
44602 + static struct ath10k_hif_cb htc_callbacks = {
44603 + .rx_completion = ath10k_htc_rx_completion_handler,
44604 + .tx_completion = ath10k_htc_tx_completion_handler,
44605 + };
44606 struct ath10k_htc_ep *ep = NULL;
44607 struct ath10k_htc *htc = NULL;
44608
44609 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44610 ath10k_htc_reset_endpoint_states(htc);
44611
44612 /* setup HIF layer callbacks */
44613 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44614 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44615 htc->ar = ar;
44616
44617 /* Get HIF default pipe for HTC message exchange */
44618 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44619 index 8d78253..bebbb68 100644
44620 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44621 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44622 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44623 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44624 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44625
44626 - ACCESS_ONCE(ads->ds_link) = i->link;
44627 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44628 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44629 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44630
44631 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44632 ctl6 = SM(i->keytype, AR_EncrType);
44633 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44634
44635 if ((i->is_first || i->is_last) &&
44636 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44637 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44638 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44639 | set11nTries(i->rates, 1)
44640 | set11nTries(i->rates, 2)
44641 | set11nTries(i->rates, 3)
44642 | (i->dur_update ? AR_DurUpdateEna : 0)
44643 | SM(0, AR_BurstDur);
44644
44645 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44646 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44647 | set11nRate(i->rates, 1)
44648 | set11nRate(i->rates, 2)
44649 | set11nRate(i->rates, 3);
44650 } else {
44651 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44652 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44653 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44654 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44655 }
44656
44657 if (!i->is_first) {
44658 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44659 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44660 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44661 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44662 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44663 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44664 return;
44665 }
44666
44667 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44668 break;
44669 }
44670
44671 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44672 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44673 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44674 | SM(i->txpower, AR_XmitPower)
44675 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44676 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44677 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44678 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44679
44680 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44681 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44682 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44683 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44684
44685 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44686 return;
44687
44688 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44689 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44690 | set11nPktDurRTSCTS(i->rates, 1);
44691
44692 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44693 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44694 | set11nPktDurRTSCTS(i->rates, 3);
44695
44696 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44697 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44698 | set11nRateFlags(i->rates, 1)
44699 | set11nRateFlags(i->rates, 2)
44700 | set11nRateFlags(i->rates, 3)
44701 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44702 index 5163abd..3ada4c2 100644
44703 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44704 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44705 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44706 (i->qcu << AR_TxQcuNum_S) | desc_len;
44707
44708 checksum += val;
44709 - ACCESS_ONCE(ads->info) = val;
44710 + ACCESS_ONCE_RW(ads->info) = val;
44711
44712 checksum += i->link;
44713 - ACCESS_ONCE(ads->link) = i->link;
44714 + ACCESS_ONCE_RW(ads->link) = i->link;
44715
44716 checksum += i->buf_addr[0];
44717 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44718 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44719 checksum += i->buf_addr[1];
44720 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44721 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44722 checksum += i->buf_addr[2];
44723 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44724 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44725 checksum += i->buf_addr[3];
44726 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44727 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44728
44729 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44730 - ACCESS_ONCE(ads->ctl3) = val;
44731 + ACCESS_ONCE_RW(ads->ctl3) = val;
44732 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44733 - ACCESS_ONCE(ads->ctl5) = val;
44734 + ACCESS_ONCE_RW(ads->ctl5) = val;
44735 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44736 - ACCESS_ONCE(ads->ctl7) = val;
44737 + ACCESS_ONCE_RW(ads->ctl7) = val;
44738 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44739 - ACCESS_ONCE(ads->ctl9) = val;
44740 + ACCESS_ONCE_RW(ads->ctl9) = val;
44741
44742 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44743 - ACCESS_ONCE(ads->ctl10) = checksum;
44744 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44745
44746 if (i->is_first || i->is_last) {
44747 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44748 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44749 | set11nTries(i->rates, 1)
44750 | set11nTries(i->rates, 2)
44751 | set11nTries(i->rates, 3)
44752 | (i->dur_update ? AR_DurUpdateEna : 0)
44753 | SM(0, AR_BurstDur);
44754
44755 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44756 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44757 | set11nRate(i->rates, 1)
44758 | set11nRate(i->rates, 2)
44759 | set11nRate(i->rates, 3);
44760 } else {
44761 - ACCESS_ONCE(ads->ctl13) = 0;
44762 - ACCESS_ONCE(ads->ctl14) = 0;
44763 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44764 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44765 }
44766
44767 ads->ctl20 = 0;
44768 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44769
44770 ctl17 = SM(i->keytype, AR_EncrType);
44771 if (!i->is_first) {
44772 - ACCESS_ONCE(ads->ctl11) = 0;
44773 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44774 - ACCESS_ONCE(ads->ctl15) = 0;
44775 - ACCESS_ONCE(ads->ctl16) = 0;
44776 - ACCESS_ONCE(ads->ctl17) = ctl17;
44777 - ACCESS_ONCE(ads->ctl18) = 0;
44778 - ACCESS_ONCE(ads->ctl19) = 0;
44779 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44780 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44781 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44782 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44783 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44784 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44785 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44786 return;
44787 }
44788
44789 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44790 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44791 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44792 | SM(i->txpower, AR_XmitPower)
44793 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44794 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44795 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44796 ctl12 |= SM(val, AR_PAPRDChainMask);
44797
44798 - ACCESS_ONCE(ads->ctl12) = ctl12;
44799 - ACCESS_ONCE(ads->ctl17) = ctl17;
44800 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44801 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44802
44803 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44804 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44805 | set11nPktDurRTSCTS(i->rates, 1);
44806
44807 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44808 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44809 | set11nPktDurRTSCTS(i->rates, 3);
44810
44811 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44812 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44813 | set11nRateFlags(i->rates, 1)
44814 | set11nRateFlags(i->rates, 2)
44815 | set11nRateFlags(i->rates, 3)
44816 | SM(i->rtscts_rate, AR_RTSCTSRate);
44817
44818 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44819 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44820 }
44821
44822 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44823 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44824 index cd74b3a..6a28d24 100644
44825 --- a/drivers/net/wireless/ath/ath9k/hw.h
44826 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44827 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44828
44829 /* ANI */
44830 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44831 -};
44832 +} __no_const;
44833
44834 /**
44835 * struct ath_spec_scan - parameters for Atheros spectral scan
44836 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44837 struct ath_spec_scan *param);
44838 void (*spectral_scan_trigger)(struct ath_hw *ah);
44839 void (*spectral_scan_wait)(struct ath_hw *ah);
44840 -};
44841 +} __no_const;
44842
44843 struct ath_nf_limits {
44844 s16 max;
44845 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44846 index 9581d07..84f6a76 100644
44847 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44848 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44849 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44850 */
44851 if (il3945_mod_params.disable_hw_scan) {
44852 D_INFO("Disabling hw_scan\n");
44853 - il3945_mac_ops.hw_scan = NULL;
44854 + pax_open_kernel();
44855 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44856 + pax_close_kernel();
44857 }
44858
44859 D_INFO("*** LOAD DRIVER ***\n");
44860 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44861 index d532948..e0d8bb1 100644
44862 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44863 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44864 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44865 {
44866 struct iwl_priv *priv = file->private_data;
44867 char buf[64];
44868 - int buf_size;
44869 + size_t buf_size;
44870 u32 offset, len;
44871
44872 memset(buf, 0, sizeof(buf));
44873 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44874 struct iwl_priv *priv = file->private_data;
44875
44876 char buf[8];
44877 - int buf_size;
44878 + size_t buf_size;
44879 u32 reset_flag;
44880
44881 memset(buf, 0, sizeof(buf));
44882 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44883 {
44884 struct iwl_priv *priv = file->private_data;
44885 char buf[8];
44886 - int buf_size;
44887 + size_t buf_size;
44888 int ht40;
44889
44890 memset(buf, 0, sizeof(buf));
44891 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44892 {
44893 struct iwl_priv *priv = file->private_data;
44894 char buf[8];
44895 - int buf_size;
44896 + size_t buf_size;
44897 int value;
44898
44899 memset(buf, 0, sizeof(buf));
44900 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44901 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44902 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44903
44904 -static const char *fmt_value = " %-30s %10u\n";
44905 -static const char *fmt_hex = " %-30s 0x%02X\n";
44906 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44907 -static const char *fmt_header =
44908 +static const char fmt_value[] = " %-30s %10u\n";
44909 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44910 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44911 +static const char fmt_header[] =
44912 "%-32s current cumulative delta max\n";
44913
44914 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44915 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44916 {
44917 struct iwl_priv *priv = file->private_data;
44918 char buf[8];
44919 - int buf_size;
44920 + size_t buf_size;
44921 int clear;
44922
44923 memset(buf, 0, sizeof(buf));
44924 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44925 {
44926 struct iwl_priv *priv = file->private_data;
44927 char buf[8];
44928 - int buf_size;
44929 + size_t buf_size;
44930 int trace;
44931
44932 memset(buf, 0, sizeof(buf));
44933 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44934 {
44935 struct iwl_priv *priv = file->private_data;
44936 char buf[8];
44937 - int buf_size;
44938 + size_t buf_size;
44939 int missed;
44940
44941 memset(buf, 0, sizeof(buf));
44942 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44943
44944 struct iwl_priv *priv = file->private_data;
44945 char buf[8];
44946 - int buf_size;
44947 + size_t buf_size;
44948 int plcp;
44949
44950 memset(buf, 0, sizeof(buf));
44951 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44952
44953 struct iwl_priv *priv = file->private_data;
44954 char buf[8];
44955 - int buf_size;
44956 + size_t buf_size;
44957 int flush;
44958
44959 memset(buf, 0, sizeof(buf));
44960 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44961
44962 struct iwl_priv *priv = file->private_data;
44963 char buf[8];
44964 - int buf_size;
44965 + size_t buf_size;
44966 int rts;
44967
44968 if (!priv->cfg->ht_params)
44969 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44970 {
44971 struct iwl_priv *priv = file->private_data;
44972 char buf[8];
44973 - int buf_size;
44974 + size_t buf_size;
44975
44976 memset(buf, 0, sizeof(buf));
44977 buf_size = min(count, sizeof(buf) - 1);
44978 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44979 struct iwl_priv *priv = file->private_data;
44980 u32 event_log_flag;
44981 char buf[8];
44982 - int buf_size;
44983 + size_t buf_size;
44984
44985 /* check that the interface is up */
44986 if (!iwl_is_ready(priv))
44987 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44988 struct iwl_priv *priv = file->private_data;
44989 char buf[8];
44990 u32 calib_disabled;
44991 - int buf_size;
44992 + size_t buf_size;
44993
44994 memset(buf, 0, sizeof(buf));
44995 buf_size = min(count, sizeof(buf) - 1);
44996 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44997 index 1531a4f..21d2641 100644
44998 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44999 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45000 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45001 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45002 {
45003 struct iwl_nvm_data *data = priv->nvm_data;
45004 - char *debug_msg;
45005 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45006
45007 if (data->sku_cap_11n_enable &&
45008 !priv->cfg->ht_params) {
45009 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45010 return -EINVAL;
45011 }
45012
45013 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45014 IWL_DEBUG_INFO(priv, debug_msg,
45015 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45016 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45017 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45018 index 390e2f0..75cfbaf 100644
45019 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45020 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45021 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45022 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45023
45024 char buf[8];
45025 - int buf_size;
45026 + size_t buf_size;
45027 u32 reset_flag;
45028
45029 memset(buf, 0, sizeof(buf));
45030 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45031 {
45032 struct iwl_trans *trans = file->private_data;
45033 char buf[8];
45034 - int buf_size;
45035 + size_t buf_size;
45036 int csr;
45037
45038 memset(buf, 0, sizeof(buf));
45039 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45040 index cb34c78..9fec0dc 100644
45041 --- a/drivers/net/wireless/mac80211_hwsim.c
45042 +++ b/drivers/net/wireless/mac80211_hwsim.c
45043 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
45044
45045 if (channels > 1) {
45046 hwsim_if_comb.num_different_channels = channels;
45047 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45048 - mac80211_hwsim_ops.cancel_hw_scan =
45049 - mac80211_hwsim_cancel_hw_scan;
45050 - mac80211_hwsim_ops.sw_scan_start = NULL;
45051 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45052 - mac80211_hwsim_ops.remain_on_channel =
45053 - mac80211_hwsim_roc;
45054 - mac80211_hwsim_ops.cancel_remain_on_channel =
45055 - mac80211_hwsim_croc;
45056 - mac80211_hwsim_ops.add_chanctx =
45057 - mac80211_hwsim_add_chanctx;
45058 - mac80211_hwsim_ops.remove_chanctx =
45059 - mac80211_hwsim_remove_chanctx;
45060 - mac80211_hwsim_ops.change_chanctx =
45061 - mac80211_hwsim_change_chanctx;
45062 - mac80211_hwsim_ops.assign_vif_chanctx =
45063 - mac80211_hwsim_assign_vif_chanctx;
45064 - mac80211_hwsim_ops.unassign_vif_chanctx =
45065 - mac80211_hwsim_unassign_vif_chanctx;
45066 + pax_open_kernel();
45067 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45068 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45069 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45070 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45071 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45072 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45073 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45074 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45075 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45076 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45077 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45078 + pax_close_kernel();
45079 }
45080
45081 spin_lock_init(&hwsim_radio_lock);
45082 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45083 index 8169a85..7fa3b47 100644
45084 --- a/drivers/net/wireless/rndis_wlan.c
45085 +++ b/drivers/net/wireless/rndis_wlan.c
45086 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45087
45088 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45089
45090 - if (rts_threshold < 0 || rts_threshold > 2347)
45091 + if (rts_threshold > 2347)
45092 rts_threshold = 2347;
45093
45094 tmp = cpu_to_le32(rts_threshold);
45095 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45096 index ee3fc57..ed5ddc9 100644
45097 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45098 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45099 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45100 * for hardware which doesn't support hardware
45101 * sequence counting.
45102 */
45103 - atomic_t seqno;
45104 + atomic_unchecked_t seqno;
45105 };
45106
45107 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45108 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45109 index aa95c6c..a59dd67 100644
45110 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45111 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45112 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45113 * sequence counter given by mac80211.
45114 */
45115 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45116 - seqno = atomic_add_return(0x10, &intf->seqno);
45117 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45118 else
45119 - seqno = atomic_read(&intf->seqno);
45120 + seqno = atomic_read_unchecked(&intf->seqno);
45121
45122 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45123 hdr->seq_ctrl |= cpu_to_le16(seqno);
45124 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45125 index e2b3d9c..67a5184 100644
45126 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45127 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45128 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45129
45130 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45131
45132 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45133 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45134 + pax_open_kernel();
45135 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45136 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45137 + pax_close_kernel();
45138
45139 wl1251_info("using dedicated interrupt line");
45140 } else {
45141 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45142 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45143 + pax_open_kernel();
45144 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45145 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45146 + pax_close_kernel();
45147
45148 wl1251_info("using SDIO interrupt");
45149 }
45150 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45151 index 1c627da..69f7d17 100644
45152 --- a/drivers/net/wireless/ti/wl12xx/main.c
45153 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45154 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45155 sizeof(wl->conf.mem));
45156
45157 /* read data preparation is only needed by wl127x */
45158 - wl->ops->prepare_read = wl127x_prepare_read;
45159 + pax_open_kernel();
45160 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45161 + pax_close_kernel();
45162
45163 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45164 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45165 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45166 sizeof(wl->conf.mem));
45167
45168 /* read data preparation is only needed by wl127x */
45169 - wl->ops->prepare_read = wl127x_prepare_read;
45170 + pax_open_kernel();
45171 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45172 + pax_close_kernel();
45173
45174 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45175 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45176 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45177 index 7aa0eb8..5a9ef38 100644
45178 --- a/drivers/net/wireless/ti/wl18xx/main.c
45179 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45180 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45181 }
45182
45183 if (!checksum_param) {
45184 - wl18xx_ops.set_rx_csum = NULL;
45185 - wl18xx_ops.init_vif = NULL;
45186 + pax_open_kernel();
45187 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45188 + *(void **)&wl18xx_ops.init_vif = NULL;
45189 + pax_close_kernel();
45190 }
45191
45192 /* Enable 11a Band only if we have 5G antennas */
45193 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45194 index 7ef0b4a..ff65c28 100644
45195 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45196 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45197 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45198 {
45199 struct zd_usb *usb = urb->context;
45200 struct zd_usb_interrupt *intr = &usb->intr;
45201 - int len;
45202 + unsigned int len;
45203 u16 int_num;
45204
45205 ZD_ASSERT(in_interrupt());
45206 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45207 index d93b2b6..ae50401 100644
45208 --- a/drivers/oprofile/buffer_sync.c
45209 +++ b/drivers/oprofile/buffer_sync.c
45210 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45211 if (cookie == NO_COOKIE)
45212 offset = pc;
45213 if (cookie == INVALID_COOKIE) {
45214 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45215 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45216 offset = pc;
45217 }
45218 if (cookie != last_cookie) {
45219 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45220 /* add userspace sample */
45221
45222 if (!mm) {
45223 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45224 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45225 return 0;
45226 }
45227
45228 cookie = lookup_dcookie(mm, s->eip, &offset);
45229
45230 if (cookie == INVALID_COOKIE) {
45231 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45232 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45233 return 0;
45234 }
45235
45236 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45237 /* ignore backtraces if failed to add a sample */
45238 if (state == sb_bt_start) {
45239 state = sb_bt_ignore;
45240 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45241 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45242 }
45243 }
45244 release_mm(mm);
45245 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45246 index c0cc4e7..44d4e54 100644
45247 --- a/drivers/oprofile/event_buffer.c
45248 +++ b/drivers/oprofile/event_buffer.c
45249 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45250 }
45251
45252 if (buffer_pos == buffer_size) {
45253 - atomic_inc(&oprofile_stats.event_lost_overflow);
45254 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45255 return;
45256 }
45257
45258 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45259 index ed2c3ec..deda85a 100644
45260 --- a/drivers/oprofile/oprof.c
45261 +++ b/drivers/oprofile/oprof.c
45262 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45263 if (oprofile_ops.switch_events())
45264 return;
45265
45266 - atomic_inc(&oprofile_stats.multiplex_counter);
45267 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45268 start_switch_worker();
45269 }
45270
45271 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45272 index 84a208d..d61b0a1 100644
45273 --- a/drivers/oprofile/oprofile_files.c
45274 +++ b/drivers/oprofile/oprofile_files.c
45275 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45276
45277 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45278
45279 -static ssize_t timeout_read(struct file *file, char __user *buf,
45280 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45281 size_t count, loff_t *offset)
45282 {
45283 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45284 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45285 index 917d28e..d62d981 100644
45286 --- a/drivers/oprofile/oprofile_stats.c
45287 +++ b/drivers/oprofile/oprofile_stats.c
45288 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45289 cpu_buf->sample_invalid_eip = 0;
45290 }
45291
45292 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45293 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45294 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45295 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45296 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45297 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45298 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45299 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45300 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45301 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45302 }
45303
45304
45305 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45306 index 38b6fc0..b5cbfce 100644
45307 --- a/drivers/oprofile/oprofile_stats.h
45308 +++ b/drivers/oprofile/oprofile_stats.h
45309 @@ -13,11 +13,11 @@
45310 #include <linux/atomic.h>
45311
45312 struct oprofile_stat_struct {
45313 - atomic_t sample_lost_no_mm;
45314 - atomic_t sample_lost_no_mapping;
45315 - atomic_t bt_lost_no_mapping;
45316 - atomic_t event_lost_overflow;
45317 - atomic_t multiplex_counter;
45318 + atomic_unchecked_t sample_lost_no_mm;
45319 + atomic_unchecked_t sample_lost_no_mapping;
45320 + atomic_unchecked_t bt_lost_no_mapping;
45321 + atomic_unchecked_t event_lost_overflow;
45322 + atomic_unchecked_t multiplex_counter;
45323 };
45324
45325 extern struct oprofile_stat_struct oprofile_stats;
45326 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45327 index 7c12d9c..558bf3bb 100644
45328 --- a/drivers/oprofile/oprofilefs.c
45329 +++ b/drivers/oprofile/oprofilefs.c
45330 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45331
45332
45333 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45334 - char const *name, atomic_t *val)
45335 + char const *name, atomic_unchecked_t *val)
45336 {
45337 return __oprofilefs_create_file(sb, root, name,
45338 &atomic_ro_fops, 0444, val);
45339 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45340 index 61be1d9..dec05d7 100644
45341 --- a/drivers/oprofile/timer_int.c
45342 +++ b/drivers/oprofile/timer_int.c
45343 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45344 return NOTIFY_OK;
45345 }
45346
45347 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45348 +static struct notifier_block oprofile_cpu_notifier = {
45349 .notifier_call = oprofile_cpu_notify,
45350 };
45351
45352 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45353 index 92ed045..62d39bd7 100644
45354 --- a/drivers/parport/procfs.c
45355 +++ b/drivers/parport/procfs.c
45356 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45357
45358 *ppos += len;
45359
45360 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45361 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45362 }
45363
45364 #ifdef CONFIG_PARPORT_1284
45365 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45366
45367 *ppos += len;
45368
45369 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45370 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45371 }
45372 #endif /* IEEE1284.3 support. */
45373
45374 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45375 index c35e8ad..fc33beb 100644
45376 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45377 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45378 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45379 goto init_cleanup;
45380 }
45381
45382 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45383 + pax_open_kernel();
45384 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45385 + pax_close_kernel();
45386 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45387
45388 return retval;
45389 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45390 index a6a71c4..c91097b 100644
45391 --- a/drivers/pci/hotplug/cpcihp_generic.c
45392 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45393 @@ -73,7 +73,6 @@ static u16 port;
45394 static unsigned int enum_bit;
45395 static u8 enum_mask;
45396
45397 -static struct cpci_hp_controller_ops generic_hpc_ops;
45398 static struct cpci_hp_controller generic_hpc;
45399
45400 static int __init validate_parameters(void)
45401 @@ -139,6 +138,10 @@ static int query_enum(void)
45402 return ((value & enum_mask) == enum_mask);
45403 }
45404
45405 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45406 + .query_enum = query_enum,
45407 +};
45408 +
45409 static int __init cpcihp_generic_init(void)
45410 {
45411 int status;
45412 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45413 pci_dev_put(dev);
45414
45415 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45416 - generic_hpc_ops.query_enum = query_enum;
45417 generic_hpc.ops = &generic_hpc_ops;
45418
45419 status = cpci_hp_register_controller(&generic_hpc);
45420 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45421 index 449b4bb..257e2e8 100644
45422 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45423 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45424 @@ -59,7 +59,6 @@
45425 /* local variables */
45426 static bool debug;
45427 static bool poll;
45428 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45429 static struct cpci_hp_controller zt5550_hpc;
45430
45431 /* Primary cPCI bus bridge device */
45432 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45433 return 0;
45434 }
45435
45436 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45437 + .query_enum = zt5550_hc_query_enum,
45438 +};
45439 +
45440 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45441 {
45442 int status;
45443 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45444 dbg("returned from zt5550_hc_config");
45445
45446 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45447 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45448 zt5550_hpc.ops = &zt5550_hpc_ops;
45449 if(!poll) {
45450 zt5550_hpc.irq = hc_dev->irq;
45451 zt5550_hpc.irq_flags = IRQF_SHARED;
45452 zt5550_hpc.dev_id = hc_dev;
45453
45454 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45455 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45456 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45457 + pax_open_kernel();
45458 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45459 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45460 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45461 + pax_open_kernel();
45462 } else {
45463 info("using ENUM# polling mode");
45464 }
45465 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45466 index 76ba8a1..20ca857 100644
45467 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45468 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45469 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45470
45471 void compaq_nvram_init (void __iomem *rom_start)
45472 {
45473 +
45474 +#ifndef CONFIG_PAX_KERNEXEC
45475 if (rom_start) {
45476 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45477 }
45478 +#endif
45479 +
45480 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45481
45482 /* initialize our int15 lock */
45483 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45484 index ec20f74..c1d961e 100644
45485 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45486 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45487 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45488 return -EINVAL;
45489 }
45490
45491 - slot->ops->owner = owner;
45492 - slot->ops->mod_name = mod_name;
45493 + pax_open_kernel();
45494 + *(struct module **)&slot->ops->owner = owner;
45495 + *(const char **)&slot->ops->mod_name = mod_name;
45496 + pax_close_kernel();
45497
45498 mutex_lock(&pci_hp_mutex);
45499 /*
45500 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45501 index 7d72c5e..edce02c 100644
45502 --- a/drivers/pci/hotplug/pciehp_core.c
45503 +++ b/drivers/pci/hotplug/pciehp_core.c
45504 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45505 struct slot *slot = ctrl->slot;
45506 struct hotplug_slot *hotplug = NULL;
45507 struct hotplug_slot_info *info = NULL;
45508 - struct hotplug_slot_ops *ops = NULL;
45509 + hotplug_slot_ops_no_const *ops = NULL;
45510 char name[SLOT_NAME_SIZE];
45511 int retval = -ENOMEM;
45512
45513 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45514 index c0dbe1f..94cf3d8 100644
45515 --- a/drivers/pci/pci-sysfs.c
45516 +++ b/drivers/pci/pci-sysfs.c
45517 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45518 {
45519 /* allocate attribute structure, piggyback attribute name */
45520 int name_len = write_combine ? 13 : 10;
45521 - struct bin_attribute *res_attr;
45522 + bin_attribute_no_const *res_attr;
45523 int retval;
45524
45525 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45526 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45527 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45528 {
45529 int retval;
45530 - struct bin_attribute *attr;
45531 + bin_attribute_no_const *attr;
45532
45533 /* If the device has VPD, try to expose it in sysfs. */
45534 if (dev->vpd) {
45535 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45536 {
45537 int retval;
45538 int rom_size = 0;
45539 - struct bin_attribute *attr;
45540 + bin_attribute_no_const *attr;
45541
45542 if (!sysfs_initialized)
45543 return -EACCES;
45544 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45545 index d1182c4..2a138ec 100644
45546 --- a/drivers/pci/pci.h
45547 +++ b/drivers/pci/pci.h
45548 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45549 struct pci_vpd {
45550 unsigned int len;
45551 const struct pci_vpd_ops *ops;
45552 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45553 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45554 };
45555
45556 int pci_vpd_pci22_init(struct pci_dev *dev);
45557 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45558 index 403a443..034e050 100644
45559 --- a/drivers/pci/pcie/aspm.c
45560 +++ b/drivers/pci/pcie/aspm.c
45561 @@ -27,9 +27,9 @@
45562 #define MODULE_PARAM_PREFIX "pcie_aspm."
45563
45564 /* Note: those are not register definitions */
45565 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45566 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45567 -#define ASPM_STATE_L1 (4) /* L1 state */
45568 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45569 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45570 +#define ASPM_STATE_L1 (4U) /* L1 state */
45571 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45572 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45573
45574 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45575 index 46ada5c..20da716 100644
45576 --- a/drivers/pci/probe.c
45577 +++ b/drivers/pci/probe.c
45578 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45579 struct pci_bus_region region, inverted_region;
45580 bool bar_too_big = false, bar_disabled = false;
45581
45582 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45583 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45584
45585 /* No printks while decoding is disabled! */
45586 if (!dev->mmio_always_on) {
45587 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45588 index cdc7836..528635c 100644
45589 --- a/drivers/pci/proc.c
45590 +++ b/drivers/pci/proc.c
45591 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45592 static int __init pci_proc_init(void)
45593 {
45594 struct pci_dev *dev = NULL;
45595 +
45596 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45597 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45598 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45599 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45600 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45601 +#endif
45602 +#else
45603 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45604 +#endif
45605 proc_create("devices", 0, proc_bus_pci_dir,
45606 &proc_bus_pci_dev_operations);
45607 proc_initialized = 1;
45608 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45609 index 3e5b4497..dcdfb70 100644
45610 --- a/drivers/platform/x86/chromeos_laptop.c
45611 +++ b/drivers/platform/x86/chromeos_laptop.c
45612 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45613 return 0;
45614 }
45615
45616 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45617 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45618 {
45619 .ident = "Samsung Series 5 550 - Touchpad",
45620 .matches = {
45621 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45622 index 62f8030..c7f2a45 100644
45623 --- a/drivers/platform/x86/msi-laptop.c
45624 +++ b/drivers/platform/x86/msi-laptop.c
45625 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45626
45627 if (!quirks->ec_read_only) {
45628 /* allow userland write sysfs file */
45629 - dev_attr_bluetooth.store = store_bluetooth;
45630 - dev_attr_wlan.store = store_wlan;
45631 - dev_attr_threeg.store = store_threeg;
45632 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45633 - dev_attr_wlan.attr.mode |= S_IWUSR;
45634 - dev_attr_threeg.attr.mode |= S_IWUSR;
45635 + pax_open_kernel();
45636 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45637 + *(void **)&dev_attr_wlan.store = store_wlan;
45638 + *(void **)&dev_attr_threeg.store = store_threeg;
45639 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45640 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45641 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45642 + pax_close_kernel();
45643 }
45644
45645 /* disable hardware control by fn key */
45646 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45647 index 3a1b6bf..b453930 100644
45648 --- a/drivers/platform/x86/sony-laptop.c
45649 +++ b/drivers/platform/x86/sony-laptop.c
45650 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45651 }
45652
45653 /* High speed charging function */
45654 -static struct device_attribute *hsc_handle;
45655 +static device_attribute_no_const *hsc_handle;
45656
45657 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45658 struct device_attribute *attr,
45659 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45660 index 54d31c0..3f896d3 100644
45661 --- a/drivers/platform/x86/thinkpad_acpi.c
45662 +++ b/drivers/platform/x86/thinkpad_acpi.c
45663 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45664 return 0;
45665 }
45666
45667 -void static hotkey_mask_warn_incomplete_mask(void)
45668 +static void hotkey_mask_warn_incomplete_mask(void)
45669 {
45670 /* log only what the user can fix... */
45671 const u32 wantedmask = hotkey_driver_mask &
45672 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45673 }
45674 }
45675
45676 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45677 - struct tp_nvram_state *newn,
45678 - const u32 event_mask)
45679 -{
45680 -
45681 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45682 do { \
45683 if ((event_mask & (1 << __scancode)) && \
45684 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45685 tpacpi_hotkey_send_key(__scancode); \
45686 } while (0)
45687
45688 - void issue_volchange(const unsigned int oldvol,
45689 - const unsigned int newvol)
45690 - {
45691 - unsigned int i = oldvol;
45692 +static void issue_volchange(const unsigned int oldvol,
45693 + const unsigned int newvol,
45694 + const u32 event_mask)
45695 +{
45696 + unsigned int i = oldvol;
45697
45698 - while (i > newvol) {
45699 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45700 - i--;
45701 - }
45702 - while (i < newvol) {
45703 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45704 - i++;
45705 - }
45706 + while (i > newvol) {
45707 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45708 + i--;
45709 }
45710 + while (i < newvol) {
45711 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45712 + i++;
45713 + }
45714 +}
45715
45716 - void issue_brightnesschange(const unsigned int oldbrt,
45717 - const unsigned int newbrt)
45718 - {
45719 - unsigned int i = oldbrt;
45720 +static void issue_brightnesschange(const unsigned int oldbrt,
45721 + const unsigned int newbrt,
45722 + const u32 event_mask)
45723 +{
45724 + unsigned int i = oldbrt;
45725
45726 - while (i > newbrt) {
45727 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45728 - i--;
45729 - }
45730 - while (i < newbrt) {
45731 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45732 - i++;
45733 - }
45734 + while (i > newbrt) {
45735 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45736 + i--;
45737 + }
45738 + while (i < newbrt) {
45739 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45740 + i++;
45741 }
45742 +}
45743
45744 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45745 + struct tp_nvram_state *newn,
45746 + const u32 event_mask)
45747 +{
45748 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45749 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45750 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45751 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45752 oldn->volume_level != newn->volume_level) {
45753 /* recently muted, or repeated mute keypress, or
45754 * multiple presses ending in mute */
45755 - issue_volchange(oldn->volume_level, newn->volume_level);
45756 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45757 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45758 }
45759 } else {
45760 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45761 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45762 }
45763 if (oldn->volume_level != newn->volume_level) {
45764 - issue_volchange(oldn->volume_level, newn->volume_level);
45765 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45766 } else if (oldn->volume_toggle != newn->volume_toggle) {
45767 /* repeated vol up/down keypress at end of scale ? */
45768 if (newn->volume_level == 0)
45769 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45770 /* handle brightness */
45771 if (oldn->brightness_level != newn->brightness_level) {
45772 issue_brightnesschange(oldn->brightness_level,
45773 - newn->brightness_level);
45774 + newn->brightness_level,
45775 + event_mask);
45776 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45777 /* repeated key presses that didn't change state */
45778 if (newn->brightness_level == 0)
45779 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45780 && !tp_features.bright_unkfw)
45781 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45782 }
45783 +}
45784
45785 #undef TPACPI_COMPARE_KEY
45786 #undef TPACPI_MAY_SEND_KEY
45787 -}
45788
45789 /*
45790 * Polling driver
45791 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45792 index 769d265..a3a05ca 100644
45793 --- a/drivers/pnp/pnpbios/bioscalls.c
45794 +++ b/drivers/pnp/pnpbios/bioscalls.c
45795 @@ -58,7 +58,7 @@ do { \
45796 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45797 } while(0)
45798
45799 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45800 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45801 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45802
45803 /*
45804 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45805
45806 cpu = get_cpu();
45807 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45808 +
45809 + pax_open_kernel();
45810 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45811 + pax_close_kernel();
45812
45813 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45814 spin_lock_irqsave(&pnp_bios_lock, flags);
45815 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45816 :"memory");
45817 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45818
45819 + pax_open_kernel();
45820 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45821 + pax_close_kernel();
45822 +
45823 put_cpu();
45824
45825 /* If we get here and this is set then the PnP BIOS faulted on us. */
45826 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45827 return status;
45828 }
45829
45830 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45831 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45832 {
45833 int i;
45834
45835 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45836 pnp_bios_callpoint.offset = header->fields.pm16offset;
45837 pnp_bios_callpoint.segment = PNP_CS16;
45838
45839 + pax_open_kernel();
45840 +
45841 for_each_possible_cpu(i) {
45842 struct desc_struct *gdt = get_cpu_gdt_table(i);
45843 if (!gdt)
45844 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45845 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45846 (unsigned long)__va(header->fields.pm16dseg));
45847 }
45848 +
45849 + pax_close_kernel();
45850 }
45851 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45852 index d95e101..67f0c3f 100644
45853 --- a/drivers/pnp/resource.c
45854 +++ b/drivers/pnp/resource.c
45855 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45856 return 1;
45857
45858 /* check if the resource is valid */
45859 - if (*irq < 0 || *irq > 15)
45860 + if (*irq > 15)
45861 return 0;
45862
45863 /* check if the resource is reserved */
45864 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45865 return 1;
45866
45867 /* check if the resource is valid */
45868 - if (*dma < 0 || *dma == 4 || *dma > 7)
45869 + if (*dma == 4 || *dma > 7)
45870 return 0;
45871
45872 /* check if the resource is reserved */
45873 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45874 index 0c52e2a..3421ab7 100644
45875 --- a/drivers/power/pda_power.c
45876 +++ b/drivers/power/pda_power.c
45877 @@ -37,7 +37,11 @@ static int polling;
45878
45879 #if IS_ENABLED(CONFIG_USB_PHY)
45880 static struct usb_phy *transceiver;
45881 -static struct notifier_block otg_nb;
45882 +static int otg_handle_notification(struct notifier_block *nb,
45883 + unsigned long event, void *unused);
45884 +static struct notifier_block otg_nb = {
45885 + .notifier_call = otg_handle_notification
45886 +};
45887 #endif
45888
45889 static struct regulator *ac_draw;
45890 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45891
45892 #if IS_ENABLED(CONFIG_USB_PHY)
45893 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45894 - otg_nb.notifier_call = otg_handle_notification;
45895 ret = usb_register_notifier(transceiver, &otg_nb);
45896 if (ret) {
45897 dev_err(dev, "failure to register otg notifier\n");
45898 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45899 index cc439fd..8fa30df 100644
45900 --- a/drivers/power/power_supply.h
45901 +++ b/drivers/power/power_supply.h
45902 @@ -16,12 +16,12 @@ struct power_supply;
45903
45904 #ifdef CONFIG_SYSFS
45905
45906 -extern void power_supply_init_attrs(struct device_type *dev_type);
45907 +extern void power_supply_init_attrs(void);
45908 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45909
45910 #else
45911
45912 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45913 +static inline void power_supply_init_attrs(void) {}
45914 #define power_supply_uevent NULL
45915
45916 #endif /* CONFIG_SYSFS */
45917 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45918 index 3b2d5df..3207114 100644
45919 --- a/drivers/power/power_supply_core.c
45920 +++ b/drivers/power/power_supply_core.c
45921 @@ -24,7 +24,10 @@
45922 struct class *power_supply_class;
45923 EXPORT_SYMBOL_GPL(power_supply_class);
45924
45925 -static struct device_type power_supply_dev_type;
45926 +extern const struct attribute_group *power_supply_attr_groups[];
45927 +static struct device_type power_supply_dev_type = {
45928 + .groups = power_supply_attr_groups,
45929 +};
45930
45931 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45932 struct power_supply *supply)
45933 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
45934 return PTR_ERR(power_supply_class);
45935
45936 power_supply_class->dev_uevent = power_supply_uevent;
45937 - power_supply_init_attrs(&power_supply_dev_type);
45938 + power_supply_init_attrs();
45939
45940 return 0;
45941 }
45942 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45943 index 29178f7..c65f324 100644
45944 --- a/drivers/power/power_supply_sysfs.c
45945 +++ b/drivers/power/power_supply_sysfs.c
45946 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45947 .is_visible = power_supply_attr_is_visible,
45948 };
45949
45950 -static const struct attribute_group *power_supply_attr_groups[] = {
45951 +const struct attribute_group *power_supply_attr_groups[] = {
45952 &power_supply_attr_group,
45953 NULL,
45954 };
45955
45956 -void power_supply_init_attrs(struct device_type *dev_type)
45957 +void power_supply_init_attrs(void)
45958 {
45959 int i;
45960
45961 - dev_type->groups = power_supply_attr_groups;
45962 -
45963 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45964 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45965 }
45966 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45967 index 288c75a..065bc84 100644
45968 --- a/drivers/regulator/core.c
45969 +++ b/drivers/regulator/core.c
45970 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45971 {
45972 const struct regulation_constraints *constraints = NULL;
45973 const struct regulator_init_data *init_data;
45974 - static atomic_t regulator_no = ATOMIC_INIT(0);
45975 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45976 struct regulator_dev *rdev;
45977 struct device *dev;
45978 int ret, i;
45979 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45980 rdev->dev.of_node = config->of_node;
45981 rdev->dev.parent = dev;
45982 dev_set_name(&rdev->dev, "regulator.%d",
45983 - atomic_inc_return(&regulator_no) - 1);
45984 + atomic_inc_return_unchecked(&regulator_no) - 1);
45985 ret = device_register(&rdev->dev);
45986 if (ret != 0) {
45987 put_device(&rdev->dev);
45988 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45989 index d428ef9..fdc0357 100644
45990 --- a/drivers/regulator/max8660.c
45991 +++ b/drivers/regulator/max8660.c
45992 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
45993 max8660->shadow_regs[MAX8660_OVER1] = 5;
45994 } else {
45995 /* Otherwise devices can be toggled via software */
45996 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45997 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45998 + pax_open_kernel();
45999 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46000 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46001 + pax_close_kernel();
46002 }
46003
46004 /*
46005 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46006 index 0c5195a..637a453d 100644
46007 --- a/drivers/regulator/max8973-regulator.c
46008 +++ b/drivers/regulator/max8973-regulator.c
46009 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
46010 if (!pdata || !pdata->enable_ext_control) {
46011 max->desc.enable_reg = MAX8973_VOUT;
46012 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46013 - max->ops.enable = regulator_enable_regmap;
46014 - max->ops.disable = regulator_disable_regmap;
46015 - max->ops.is_enabled = regulator_is_enabled_regmap;
46016 + pax_open_kernel();
46017 + *(void **)&max->ops.enable = regulator_enable_regmap;
46018 + *(void **)&max->ops.disable = regulator_disable_regmap;
46019 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46020 + pax_close_kernel();
46021 }
46022
46023 if (pdata) {
46024 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46025 index 1037e07..e64dea1 100644
46026 --- a/drivers/regulator/mc13892-regulator.c
46027 +++ b/drivers/regulator/mc13892-regulator.c
46028 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46029 }
46030 mc13xxx_unlock(mc13892);
46031
46032 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46033 + pax_open_kernel();
46034 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46035 = mc13892_vcam_set_mode;
46036 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46037 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46038 = mc13892_vcam_get_mode;
46039 + pax_close_kernel();
46040
46041 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46042 ARRAY_SIZE(mc13892_regulators));
46043 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46044 index be06d71..264aee9 100644
46045 --- a/drivers/rtc/rtc-cmos.c
46046 +++ b/drivers/rtc/rtc-cmos.c
46047 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46048 hpet_rtc_timer_init();
46049
46050 /* export at least the first block of NVRAM */
46051 - nvram.size = address_space - NVRAM_OFFSET;
46052 + pax_open_kernel();
46053 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46054 + pax_close_kernel();
46055 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46056 if (retval < 0) {
46057 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46058 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46059 index d049393..bb20be0 100644
46060 --- a/drivers/rtc/rtc-dev.c
46061 +++ b/drivers/rtc/rtc-dev.c
46062 @@ -16,6 +16,7 @@
46063 #include <linux/module.h>
46064 #include <linux/rtc.h>
46065 #include <linux/sched.h>
46066 +#include <linux/grsecurity.h>
46067 #include "rtc-core.h"
46068
46069 static dev_t rtc_devt;
46070 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46071 if (copy_from_user(&tm, uarg, sizeof(tm)))
46072 return -EFAULT;
46073
46074 + gr_log_timechange();
46075 +
46076 return rtc_set_time(rtc, &tm);
46077
46078 case RTC_PIE_ON:
46079 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46080 index ca18fd1..055e42d 100644
46081 --- a/drivers/rtc/rtc-ds1307.c
46082 +++ b/drivers/rtc/rtc-ds1307.c
46083 @@ -107,7 +107,7 @@ struct ds1307 {
46084 u8 offset; /* register's offset */
46085 u8 regs[11];
46086 u16 nvram_offset;
46087 - struct bin_attribute *nvram;
46088 + bin_attribute_no_const *nvram;
46089 enum ds_type type;
46090 unsigned long flags;
46091 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46092 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46093 index fcb0329..d77b7f2 100644
46094 --- a/drivers/rtc/rtc-m48t59.c
46095 +++ b/drivers/rtc/rtc-m48t59.c
46096 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46097 if (IS_ERR(m48t59->rtc))
46098 return PTR_ERR(m48t59->rtc);
46099
46100 - m48t59_nvram_attr.size = pdata->offset;
46101 + pax_open_kernel();
46102 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46103 + pax_close_kernel();
46104
46105 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46106 if (ret)
46107 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46108 index e693af6..2e525b6 100644
46109 --- a/drivers/scsi/bfa/bfa_fcpim.h
46110 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46111 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46112
46113 struct bfa_itn_s {
46114 bfa_isr_func_t isr;
46115 -};
46116 +} __no_const;
46117
46118 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46119 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46120 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46121 index 90814fe..4384138 100644
46122 --- a/drivers/scsi/bfa/bfa_ioc.h
46123 +++ b/drivers/scsi/bfa/bfa_ioc.h
46124 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46125 bfa_ioc_disable_cbfn_t disable_cbfn;
46126 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46127 bfa_ioc_reset_cbfn_t reset_cbfn;
46128 -};
46129 +} __no_const;
46130
46131 /*
46132 * IOC event notification mechanism.
46133 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46134 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46135 enum bfi_ioc_state fwstate);
46136 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46137 -};
46138 +} __no_const;
46139
46140 /*
46141 * Queue element to wait for room in request queue. FIFO order is
46142 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46143 index c9382d6..6619864 100644
46144 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46145 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46146 @@ -33,8 +33,8 @@
46147 */
46148 #include "libfcoe.h"
46149
46150 -static atomic_t ctlr_num;
46151 -static atomic_t fcf_num;
46152 +static atomic_unchecked_t ctlr_num;
46153 +static atomic_unchecked_t fcf_num;
46154
46155 /*
46156 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46157 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46158 if (!ctlr)
46159 goto out;
46160
46161 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46162 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46163 ctlr->f = f;
46164 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46165 INIT_LIST_HEAD(&ctlr->fcfs);
46166 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46167 fcf->dev.parent = &ctlr->dev;
46168 fcf->dev.bus = &fcoe_bus_type;
46169 fcf->dev.type = &fcoe_fcf_device_type;
46170 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46171 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46172 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46173
46174 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46175 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46176 {
46177 int error;
46178
46179 - atomic_set(&ctlr_num, 0);
46180 - atomic_set(&fcf_num, 0);
46181 + atomic_set_unchecked(&ctlr_num, 0);
46182 + atomic_set_unchecked(&fcf_num, 0);
46183
46184 error = bus_register(&fcoe_bus_type);
46185 if (error)
46186 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46187 index df0c3c7..b00e1d0 100644
46188 --- a/drivers/scsi/hosts.c
46189 +++ b/drivers/scsi/hosts.c
46190 @@ -42,7 +42,7 @@
46191 #include "scsi_logging.h"
46192
46193
46194 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46195 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46196
46197
46198 static void scsi_host_cls_release(struct device *dev)
46199 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46200 * subtract one because we increment first then return, but we need to
46201 * know what the next host number was before increment
46202 */
46203 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46204 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46205 shost->dma_channel = 0xff;
46206
46207 /* These three are default values which can be overridden */
46208 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46209 index 7f4f790..b75b92a 100644
46210 --- a/drivers/scsi/hpsa.c
46211 +++ b/drivers/scsi/hpsa.c
46212 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46213 unsigned long flags;
46214
46215 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46216 - return h->access.command_completed(h, q);
46217 + return h->access->command_completed(h, q);
46218
46219 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46220 a = rq->head[rq->current_entry];
46221 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46222 while (!list_empty(&h->reqQ)) {
46223 c = list_entry(h->reqQ.next, struct CommandList, list);
46224 /* can't do anything if fifo is full */
46225 - if ((h->access.fifo_full(h))) {
46226 + if ((h->access->fifo_full(h))) {
46227 dev_warn(&h->pdev->dev, "fifo full\n");
46228 break;
46229 }
46230 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46231
46232 /* Tell the controller execute command */
46233 spin_unlock_irqrestore(&h->lock, flags);
46234 - h->access.submit_command(h, c);
46235 + h->access->submit_command(h, c);
46236 spin_lock_irqsave(&h->lock, flags);
46237 }
46238 spin_unlock_irqrestore(&h->lock, flags);
46239 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46240
46241 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46242 {
46243 - return h->access.command_completed(h, q);
46244 + return h->access->command_completed(h, q);
46245 }
46246
46247 static inline bool interrupt_pending(struct ctlr_info *h)
46248 {
46249 - return h->access.intr_pending(h);
46250 + return h->access->intr_pending(h);
46251 }
46252
46253 static inline long interrupt_not_for_us(struct ctlr_info *h)
46254 {
46255 - return (h->access.intr_pending(h) == 0) ||
46256 + return (h->access->intr_pending(h) == 0) ||
46257 (h->interrupts_enabled == 0);
46258 }
46259
46260 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46261 if (prod_index < 0)
46262 return -ENODEV;
46263 h->product_name = products[prod_index].product_name;
46264 - h->access = *(products[prod_index].access);
46265 + h->access = products[prod_index].access;
46266
46267 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46268 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46269 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46270
46271 assert_spin_locked(&lockup_detector_lock);
46272 remove_ctlr_from_lockup_detector_list(h);
46273 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46274 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46275 spin_lock_irqsave(&h->lock, flags);
46276 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46277 spin_unlock_irqrestore(&h->lock, flags);
46278 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46279 }
46280
46281 /* make sure the board interrupts are off */
46282 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46283 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46284
46285 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46286 goto clean2;
46287 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46288 * fake ones to scoop up any residual completions.
46289 */
46290 spin_lock_irqsave(&h->lock, flags);
46291 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46292 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46293 spin_unlock_irqrestore(&h->lock, flags);
46294 free_irqs(h);
46295 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46296 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46297 dev_info(&h->pdev->dev, "Board READY.\n");
46298 dev_info(&h->pdev->dev,
46299 "Waiting for stale completions to drain.\n");
46300 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46301 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46302 msleep(10000);
46303 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46304 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46305
46306 rc = controller_reset_failed(h->cfgtable);
46307 if (rc)
46308 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46309 }
46310
46311 /* Turn the interrupts on so we can service requests */
46312 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46313 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46314
46315 hpsa_hba_inquiry(h);
46316 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46317 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46318 * To write all data in the battery backed cache to disks
46319 */
46320 hpsa_flush_cache(h);
46321 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46322 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46323 hpsa_free_irqs_and_disable_msix(h);
46324 }
46325
46326 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46327 return;
46328 }
46329 /* Change the access methods to the performant access methods */
46330 - h->access = SA5_performant_access;
46331 + h->access = &SA5_performant_access;
46332 h->transMethod = CFGTBL_Trans_Performant;
46333 }
46334
46335 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46336 index 9816479..c5d4e97 100644
46337 --- a/drivers/scsi/hpsa.h
46338 +++ b/drivers/scsi/hpsa.h
46339 @@ -79,7 +79,7 @@ struct ctlr_info {
46340 unsigned int msix_vector;
46341 unsigned int msi_vector;
46342 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46343 - struct access_method access;
46344 + struct access_method *access;
46345
46346 /* queue and queue Info */
46347 struct list_head reqQ;
46348 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46349 index 5879929..32b241d 100644
46350 --- a/drivers/scsi/libfc/fc_exch.c
46351 +++ b/drivers/scsi/libfc/fc_exch.c
46352 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46353 u16 pool_max_index;
46354
46355 struct {
46356 - atomic_t no_free_exch;
46357 - atomic_t no_free_exch_xid;
46358 - atomic_t xid_not_found;
46359 - atomic_t xid_busy;
46360 - atomic_t seq_not_found;
46361 - atomic_t non_bls_resp;
46362 + atomic_unchecked_t no_free_exch;
46363 + atomic_unchecked_t no_free_exch_xid;
46364 + atomic_unchecked_t xid_not_found;
46365 + atomic_unchecked_t xid_busy;
46366 + atomic_unchecked_t seq_not_found;
46367 + atomic_unchecked_t non_bls_resp;
46368 } stats;
46369 };
46370
46371 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46372 /* allocate memory for exchange */
46373 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46374 if (!ep) {
46375 - atomic_inc(&mp->stats.no_free_exch);
46376 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46377 goto out;
46378 }
46379 memset(ep, 0, sizeof(*ep));
46380 @@ -797,7 +797,7 @@ out:
46381 return ep;
46382 err:
46383 spin_unlock_bh(&pool->lock);
46384 - atomic_inc(&mp->stats.no_free_exch_xid);
46385 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46386 mempool_free(ep, mp->ep_pool);
46387 return NULL;
46388 }
46389 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46390 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46391 ep = fc_exch_find(mp, xid);
46392 if (!ep) {
46393 - atomic_inc(&mp->stats.xid_not_found);
46394 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46395 reject = FC_RJT_OX_ID;
46396 goto out;
46397 }
46398 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46399 ep = fc_exch_find(mp, xid);
46400 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46401 if (ep) {
46402 - atomic_inc(&mp->stats.xid_busy);
46403 + atomic_inc_unchecked(&mp->stats.xid_busy);
46404 reject = FC_RJT_RX_ID;
46405 goto rel;
46406 }
46407 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46408 }
46409 xid = ep->xid; /* get our XID */
46410 } else if (!ep) {
46411 - atomic_inc(&mp->stats.xid_not_found);
46412 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46413 reject = FC_RJT_RX_ID; /* XID not found */
46414 goto out;
46415 }
46416 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46417 } else {
46418 sp = &ep->seq;
46419 if (sp->id != fh->fh_seq_id) {
46420 - atomic_inc(&mp->stats.seq_not_found);
46421 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46422 if (f_ctl & FC_FC_END_SEQ) {
46423 /*
46424 * Update sequence_id based on incoming last
46425 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46426
46427 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46428 if (!ep) {
46429 - atomic_inc(&mp->stats.xid_not_found);
46430 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46431 goto out;
46432 }
46433 if (ep->esb_stat & ESB_ST_COMPLETE) {
46434 - atomic_inc(&mp->stats.xid_not_found);
46435 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46436 goto rel;
46437 }
46438 if (ep->rxid == FC_XID_UNKNOWN)
46439 ep->rxid = ntohs(fh->fh_rx_id);
46440 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46441 - atomic_inc(&mp->stats.xid_not_found);
46442 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46443 goto rel;
46444 }
46445 if (ep->did != ntoh24(fh->fh_s_id) &&
46446 ep->did != FC_FID_FLOGI) {
46447 - atomic_inc(&mp->stats.xid_not_found);
46448 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46449 goto rel;
46450 }
46451 sof = fr_sof(fp);
46452 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46453 sp->ssb_stat |= SSB_ST_RESP;
46454 sp->id = fh->fh_seq_id;
46455 } else if (sp->id != fh->fh_seq_id) {
46456 - atomic_inc(&mp->stats.seq_not_found);
46457 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46458 goto rel;
46459 }
46460
46461 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46462 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46463
46464 if (!sp)
46465 - atomic_inc(&mp->stats.xid_not_found);
46466 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46467 else
46468 - atomic_inc(&mp->stats.non_bls_resp);
46469 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46470
46471 fc_frame_free(fp);
46472 }
46473 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46474
46475 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46476 mp = ema->mp;
46477 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46478 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46479 st->fc_no_free_exch_xid +=
46480 - atomic_read(&mp->stats.no_free_exch_xid);
46481 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46482 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46483 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46484 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46485 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46486 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46487 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46488 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46489 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46490 }
46491 }
46492 EXPORT_SYMBOL(fc_exch_update_stats);
46493 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46494 index 161c98e..6d563b3 100644
46495 --- a/drivers/scsi/libsas/sas_ata.c
46496 +++ b/drivers/scsi/libsas/sas_ata.c
46497 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46498 .postreset = ata_std_postreset,
46499 .error_handler = ata_std_error_handler,
46500 .post_internal_cmd = sas_ata_post_internal,
46501 - .qc_defer = ata_std_qc_defer,
46502 + .qc_defer = ata_std_qc_defer,
46503 .qc_prep = ata_noop_qc_prep,
46504 .qc_issue = sas_ata_qc_issue,
46505 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46506 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46507 index 93f222d..73e977b 100644
46508 --- a/drivers/scsi/lpfc/lpfc.h
46509 +++ b/drivers/scsi/lpfc/lpfc.h
46510 @@ -431,7 +431,7 @@ struct lpfc_vport {
46511 struct dentry *debug_nodelist;
46512 struct dentry *vport_debugfs_root;
46513 struct lpfc_debugfs_trc *disc_trc;
46514 - atomic_t disc_trc_cnt;
46515 + atomic_unchecked_t disc_trc_cnt;
46516 #endif
46517 uint8_t stat_data_enabled;
46518 uint8_t stat_data_blocked;
46519 @@ -865,8 +865,8 @@ struct lpfc_hba {
46520 struct timer_list fabric_block_timer;
46521 unsigned long bit_flags;
46522 #define FABRIC_COMANDS_BLOCKED 0
46523 - atomic_t num_rsrc_err;
46524 - atomic_t num_cmd_success;
46525 + atomic_unchecked_t num_rsrc_err;
46526 + atomic_unchecked_t num_cmd_success;
46527 unsigned long last_rsrc_error_time;
46528 unsigned long last_ramp_down_time;
46529 unsigned long last_ramp_up_time;
46530 @@ -902,7 +902,7 @@ struct lpfc_hba {
46531
46532 struct dentry *debug_slow_ring_trc;
46533 struct lpfc_debugfs_trc *slow_ring_trc;
46534 - atomic_t slow_ring_trc_cnt;
46535 + atomic_unchecked_t slow_ring_trc_cnt;
46536 /* iDiag debugfs sub-directory */
46537 struct dentry *idiag_root;
46538 struct dentry *idiag_pci_cfg;
46539 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46540 index 60084e6..0e2e700 100644
46541 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46542 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46543 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46544
46545 #include <linux/debugfs.h>
46546
46547 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46548 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46549 static unsigned long lpfc_debugfs_start_time = 0L;
46550
46551 /* iDiag */
46552 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46553 lpfc_debugfs_enable = 0;
46554
46555 len = 0;
46556 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46557 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46558 (lpfc_debugfs_max_disc_trc - 1);
46559 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46560 dtp = vport->disc_trc + i;
46561 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46562 lpfc_debugfs_enable = 0;
46563
46564 len = 0;
46565 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46566 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46567 (lpfc_debugfs_max_slow_ring_trc - 1);
46568 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46569 dtp = phba->slow_ring_trc + i;
46570 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46571 !vport || !vport->disc_trc)
46572 return;
46573
46574 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46575 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46576 (lpfc_debugfs_max_disc_trc - 1);
46577 dtp = vport->disc_trc + index;
46578 dtp->fmt = fmt;
46579 dtp->data1 = data1;
46580 dtp->data2 = data2;
46581 dtp->data3 = data3;
46582 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46583 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46584 dtp->jif = jiffies;
46585 #endif
46586 return;
46587 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46588 !phba || !phba->slow_ring_trc)
46589 return;
46590
46591 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46592 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46593 (lpfc_debugfs_max_slow_ring_trc - 1);
46594 dtp = phba->slow_ring_trc + index;
46595 dtp->fmt = fmt;
46596 dtp->data1 = data1;
46597 dtp->data2 = data2;
46598 dtp->data3 = data3;
46599 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46600 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46601 dtp->jif = jiffies;
46602 #endif
46603 return;
46604 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46605 "slow_ring buffer\n");
46606 goto debug_failed;
46607 }
46608 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46609 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46610 memset(phba->slow_ring_trc, 0,
46611 (sizeof(struct lpfc_debugfs_trc) *
46612 lpfc_debugfs_max_slow_ring_trc));
46613 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46614 "buffer\n");
46615 goto debug_failed;
46616 }
46617 - atomic_set(&vport->disc_trc_cnt, 0);
46618 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46619
46620 snprintf(name, sizeof(name), "discovery_trace");
46621 vport->debug_disc_trc =
46622 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46623 index e0b20fa..30c2c0d 100644
46624 --- a/drivers/scsi/lpfc/lpfc_init.c
46625 +++ b/drivers/scsi/lpfc/lpfc_init.c
46626 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46627 "misc_register returned with status %d", error);
46628
46629 if (lpfc_enable_npiv) {
46630 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46631 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46632 + pax_open_kernel();
46633 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46634 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46635 + pax_close_kernel();
46636 }
46637 lpfc_transport_template =
46638 fc_attach_transport(&lpfc_transport_functions);
46639 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46640 index 243de1d..f40e3e5 100644
46641 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46642 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46643 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46644 uint32_t evt_posted;
46645
46646 spin_lock_irqsave(&phba->hbalock, flags);
46647 - atomic_inc(&phba->num_rsrc_err);
46648 + atomic_inc_unchecked(&phba->num_rsrc_err);
46649 phba->last_rsrc_error_time = jiffies;
46650
46651 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46652 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46653 unsigned long flags;
46654 struct lpfc_hba *phba = vport->phba;
46655 uint32_t evt_posted;
46656 - atomic_inc(&phba->num_cmd_success);
46657 + atomic_inc_unchecked(&phba->num_cmd_success);
46658
46659 if (vport->cfg_lun_queue_depth <= queue_depth)
46660 return;
46661 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46662 unsigned long num_rsrc_err, num_cmd_success;
46663 int i;
46664
46665 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46666 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46667 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46668 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46669
46670 /*
46671 * The error and success command counters are global per
46672 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46673 }
46674 }
46675 lpfc_destroy_vport_work_array(phba, vports);
46676 - atomic_set(&phba->num_rsrc_err, 0);
46677 - atomic_set(&phba->num_cmd_success, 0);
46678 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46679 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46680 }
46681
46682 /**
46683 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46684 }
46685 }
46686 lpfc_destroy_vport_work_array(phba, vports);
46687 - atomic_set(&phba->num_rsrc_err, 0);
46688 - atomic_set(&phba->num_cmd_success, 0);
46689 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46690 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46691 }
46692
46693 /**
46694 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46695 index 1eb7b028..b2a6080 100644
46696 --- a/drivers/scsi/pmcraid.c
46697 +++ b/drivers/scsi/pmcraid.c
46698 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46699 res->scsi_dev = scsi_dev;
46700 scsi_dev->hostdata = res;
46701 res->change_detected = 0;
46702 - atomic_set(&res->read_failures, 0);
46703 - atomic_set(&res->write_failures, 0);
46704 + atomic_set_unchecked(&res->read_failures, 0);
46705 + atomic_set_unchecked(&res->write_failures, 0);
46706 rc = 0;
46707 }
46708 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46709 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46710
46711 /* If this was a SCSI read/write command keep count of errors */
46712 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46713 - atomic_inc(&res->read_failures);
46714 + atomic_inc_unchecked(&res->read_failures);
46715 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46716 - atomic_inc(&res->write_failures);
46717 + atomic_inc_unchecked(&res->write_failures);
46718
46719 if (!RES_IS_GSCSI(res->cfg_entry) &&
46720 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46721 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46722 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46723 * hrrq_id assigned here in queuecommand
46724 */
46725 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46726 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46727 pinstance->num_hrrq;
46728 cmd->cmd_done = pmcraid_io_done;
46729
46730 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46731 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46732 * hrrq_id assigned here in queuecommand
46733 */
46734 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46735 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46736 pinstance->num_hrrq;
46737
46738 if (request_size) {
46739 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46740
46741 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46742 /* add resources only after host is added into system */
46743 - if (!atomic_read(&pinstance->expose_resources))
46744 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46745 return;
46746
46747 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46748 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46749 init_waitqueue_head(&pinstance->reset_wait_q);
46750
46751 atomic_set(&pinstance->outstanding_cmds, 0);
46752 - atomic_set(&pinstance->last_message_id, 0);
46753 - atomic_set(&pinstance->expose_resources, 0);
46754 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46755 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46756
46757 INIT_LIST_HEAD(&pinstance->free_res_q);
46758 INIT_LIST_HEAD(&pinstance->used_res_q);
46759 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46760 /* Schedule worker thread to handle CCN and take care of adding and
46761 * removing devices to OS
46762 */
46763 - atomic_set(&pinstance->expose_resources, 1);
46764 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46765 schedule_work(&pinstance->worker_q);
46766 return rc;
46767
46768 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46769 index e1d150f..6c6df44 100644
46770 --- a/drivers/scsi/pmcraid.h
46771 +++ b/drivers/scsi/pmcraid.h
46772 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46773 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46774
46775 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46776 - atomic_t last_message_id;
46777 + atomic_unchecked_t last_message_id;
46778
46779 /* configuration table */
46780 struct pmcraid_config_table *cfg_table;
46781 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46782 atomic_t outstanding_cmds;
46783
46784 /* should add/delete resources to mid-layer now ?*/
46785 - atomic_t expose_resources;
46786 + atomic_unchecked_t expose_resources;
46787
46788
46789
46790 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46791 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46792 };
46793 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46794 - atomic_t read_failures; /* count of failed READ commands */
46795 - atomic_t write_failures; /* count of failed WRITE commands */
46796 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46797 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46798
46799 /* To indicate add/delete/modify during CCN */
46800 u8 change_detected;
46801 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46802 index d7a99ae..801df70 100644
46803 --- a/drivers/scsi/qla2xxx/qla_attr.c
46804 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46805 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46806 return 0;
46807 }
46808
46809 -struct fc_function_template qla2xxx_transport_functions = {
46810 +fc_function_template_no_const qla2xxx_transport_functions = {
46811
46812 .show_host_node_name = 1,
46813 .show_host_port_name = 1,
46814 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46815 .bsg_timeout = qla24xx_bsg_timeout,
46816 };
46817
46818 -struct fc_function_template qla2xxx_transport_vport_functions = {
46819 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46820
46821 .show_host_node_name = 1,
46822 .show_host_port_name = 1,
46823 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46824 index 2d98232..a84298e 100644
46825 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46826 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46827 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46828 struct device_attribute;
46829 extern struct device_attribute *qla2x00_host_attrs[];
46830 struct fc_function_template;
46831 -extern struct fc_function_template qla2xxx_transport_functions;
46832 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46833 +extern fc_function_template_no_const qla2xxx_transport_functions;
46834 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46835 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46836 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46837 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46838 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46839 index 3e21e9f..426ba79 100644
46840 --- a/drivers/scsi/qla2xxx/qla_os.c
46841 +++ b/drivers/scsi/qla2xxx/qla_os.c
46842 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46843 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46844 /* Ok, a 64bit DMA mask is applicable. */
46845 ha->flags.enable_64bit_addressing = 1;
46846 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46847 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46848 + pax_open_kernel();
46849 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46850 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46851 + pax_close_kernel();
46852 return;
46853 }
46854 }
46855 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46856 index ddf16a8..80f4dd0 100644
46857 --- a/drivers/scsi/qla4xxx/ql4_def.h
46858 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46859 @@ -291,7 +291,7 @@ struct ddb_entry {
46860 * (4000 only) */
46861 atomic_t relogin_timer; /* Max Time to wait for
46862 * relogin to complete */
46863 - atomic_t relogin_retry_count; /* Num of times relogin has been
46864 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46865 * retried */
46866 uint32_t default_time2wait; /* Default Min time between
46867 * relogins (+aens) */
46868 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46869 index b246b3c..897004d 100644
46870 --- a/drivers/scsi/qla4xxx/ql4_os.c
46871 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46872 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46873 */
46874 if (!iscsi_is_session_online(cls_sess)) {
46875 /* Reset retry relogin timer */
46876 - atomic_inc(&ddb_entry->relogin_retry_count);
46877 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46878 DEBUG2(ql4_printk(KERN_INFO, ha,
46879 "%s: index[%d] relogin timed out-retrying"
46880 " relogin (%d), retry (%d)\n", __func__,
46881 ddb_entry->fw_ddb_index,
46882 - atomic_read(&ddb_entry->relogin_retry_count),
46883 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46884 ddb_entry->default_time2wait + 4));
46885 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46886 atomic_set(&ddb_entry->retry_relogin_timer,
46887 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46888
46889 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46890 atomic_set(&ddb_entry->relogin_timer, 0);
46891 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46892 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46893 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46894 ddb_entry->default_relogin_timeout =
46895 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46896 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46897 index eaa808e..95f8841 100644
46898 --- a/drivers/scsi/scsi.c
46899 +++ b/drivers/scsi/scsi.c
46900 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46901 unsigned long timeout;
46902 int rtn = 0;
46903
46904 - atomic_inc(&cmd->device->iorequest_cnt);
46905 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46906
46907 /* check if the device is still usable */
46908 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46909 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46910 index 124392f..75eb43e 100644
46911 --- a/drivers/scsi/scsi_lib.c
46912 +++ b/drivers/scsi/scsi_lib.c
46913 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46914 shost = sdev->host;
46915 scsi_init_cmd_errh(cmd);
46916 cmd->result = DID_NO_CONNECT << 16;
46917 - atomic_inc(&cmd->device->iorequest_cnt);
46918 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46919
46920 /*
46921 * SCSI request completion path will do scsi_device_unbusy(),
46922 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46923
46924 INIT_LIST_HEAD(&cmd->eh_entry);
46925
46926 - atomic_inc(&cmd->device->iodone_cnt);
46927 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46928 if (cmd->result)
46929 - atomic_inc(&cmd->device->ioerr_cnt);
46930 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46931
46932 disposition = scsi_decide_disposition(cmd);
46933 if (disposition != SUCCESS &&
46934 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46935 index 7e50061..71db7a6 100644
46936 --- a/drivers/scsi/scsi_sysfs.c
46937 +++ b/drivers/scsi/scsi_sysfs.c
46938 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46939 char *buf) \
46940 { \
46941 struct scsi_device *sdev = to_scsi_device(dev); \
46942 - unsigned long long count = atomic_read(&sdev->field); \
46943 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46944 return snprintf(buf, 20, "0x%llx\n", count); \
46945 } \
46946 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46947 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46948 index 84a1fdf..693b0d6 100644
46949 --- a/drivers/scsi/scsi_tgt_lib.c
46950 +++ b/drivers/scsi/scsi_tgt_lib.c
46951 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46952 int err;
46953
46954 dprintk("%lx %u\n", uaddr, len);
46955 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46956 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46957 if (err) {
46958 /*
46959 * TODO: need to fixup sg_tablesize, max_segment_size,
46960 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46961 index 4628fd5..a94a1c2 100644
46962 --- a/drivers/scsi/scsi_transport_fc.c
46963 +++ b/drivers/scsi/scsi_transport_fc.c
46964 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
46965 * Netlink Infrastructure
46966 */
46967
46968 -static atomic_t fc_event_seq;
46969 +static atomic_unchecked_t fc_event_seq;
46970
46971 /**
46972 * fc_get_event_number - Obtain the next sequential FC event number
46973 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
46974 u32
46975 fc_get_event_number(void)
46976 {
46977 - return atomic_add_return(1, &fc_event_seq);
46978 + return atomic_add_return_unchecked(1, &fc_event_seq);
46979 }
46980 EXPORT_SYMBOL(fc_get_event_number);
46981
46982 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
46983 {
46984 int error;
46985
46986 - atomic_set(&fc_event_seq, 0);
46987 + atomic_set_unchecked(&fc_event_seq, 0);
46988
46989 error = transport_class_register(&fc_host_class);
46990 if (error)
46991 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
46992 char *cp;
46993
46994 *val = simple_strtoul(buf, &cp, 0);
46995 - if ((*cp && (*cp != '\n')) || (*val < 0))
46996 + if (*cp && (*cp != '\n'))
46997 return -EINVAL;
46998 /*
46999 * Check for overflow; dev_loss_tmo is u32
47000 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47001 index abf7c40..c3240ed 100644
47002 --- a/drivers/scsi/scsi_transport_iscsi.c
47003 +++ b/drivers/scsi/scsi_transport_iscsi.c
47004 @@ -80,7 +80,7 @@ struct iscsi_internal {
47005 struct transport_container session_cont;
47006 };
47007
47008 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47009 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47010 static struct workqueue_struct *iscsi_eh_timer_workq;
47011
47012 static DEFINE_IDA(iscsi_sess_ida);
47013 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47014 int err;
47015
47016 ihost = shost->shost_data;
47017 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47018 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47019
47020 if (target_id == ISCSI_MAX_TARGET) {
47021 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47022 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47023 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47024 ISCSI_TRANSPORT_VERSION);
47025
47026 - atomic_set(&iscsi_session_nr, 0);
47027 + atomic_set_unchecked(&iscsi_session_nr, 0);
47028
47029 err = class_register(&iscsi_transport_class);
47030 if (err)
47031 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47032 index f379c7f..e8fc69c 100644
47033 --- a/drivers/scsi/scsi_transport_srp.c
47034 +++ b/drivers/scsi/scsi_transport_srp.c
47035 @@ -33,7 +33,7 @@
47036 #include "scsi_transport_srp_internal.h"
47037
47038 struct srp_host_attrs {
47039 - atomic_t next_port_id;
47040 + atomic_unchecked_t next_port_id;
47041 };
47042 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47043
47044 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47045 struct Scsi_Host *shost = dev_to_shost(dev);
47046 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47047
47048 - atomic_set(&srp_host->next_port_id, 0);
47049 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47050 return 0;
47051 }
47052
47053 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47054 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47055 rport->roles = ids->roles;
47056
47057 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47058 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47059 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47060
47061 transport_setup_device(&rport->dev);
47062 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47063 index 2783dd7..d20395b 100644
47064 --- a/drivers/scsi/sd.c
47065 +++ b/drivers/scsi/sd.c
47066 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
47067 sdkp->disk = gd;
47068 sdkp->index = index;
47069 atomic_set(&sdkp->openers, 0);
47070 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47071 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47072
47073 if (!sdp->request_queue->rq_timeout) {
47074 if (sdp->type != TYPE_MOD)
47075 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47076 index df5e961..df6b97f 100644
47077 --- a/drivers/scsi/sg.c
47078 +++ b/drivers/scsi/sg.c
47079 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47080 sdp->disk->disk_name,
47081 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47082 NULL,
47083 - (char *)arg);
47084 + (char __user *)arg);
47085 case BLKTRACESTART:
47086 return blk_trace_startstop(sdp->device->request_queue, 1);
47087 case BLKTRACESTOP:
47088 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47089 index 978dda2..cb19aa0 100644
47090 --- a/drivers/spi/spi.c
47091 +++ b/drivers/spi/spi.c
47092 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47093 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47094
47095 /* portable code must never pass more than 32 bytes */
47096 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47097 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47098
47099 static u8 *buf;
47100
47101 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47102 index ee3a57f..18368c1 100644
47103 --- a/drivers/staging/android/timed_output.c
47104 +++ b/drivers/staging/android/timed_output.c
47105 @@ -25,7 +25,7 @@
47106 #include "timed_output.h"
47107
47108 static struct class *timed_output_class;
47109 -static atomic_t device_count;
47110 +static atomic_unchecked_t device_count;
47111
47112 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47113 char *buf)
47114 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47115 timed_output_class = class_create(THIS_MODULE, "timed_output");
47116 if (IS_ERR(timed_output_class))
47117 return PTR_ERR(timed_output_class);
47118 - atomic_set(&device_count, 0);
47119 + atomic_set_unchecked(&device_count, 0);
47120 }
47121
47122 return 0;
47123 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47124 if (ret < 0)
47125 return ret;
47126
47127 - tdev->index = atomic_inc_return(&device_count);
47128 + tdev->index = atomic_inc_return_unchecked(&device_count);
47129 tdev->dev = device_create(timed_output_class, NULL,
47130 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47131 if (IS_ERR(tdev->dev))
47132 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47133 index 3675020..e80d92c 100644
47134 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47135 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47136 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47137
47138 static int solo_sysfs_init(struct solo_dev *solo_dev)
47139 {
47140 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47141 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47142 struct device *dev = &solo_dev->dev;
47143 const char *driver;
47144 int i;
47145 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47146 index 3335941..2b26186 100644
47147 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47148 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47149 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47150
47151 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47152 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47153 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47154 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47155 if (p2m_id < 0)
47156 p2m_id = -p2m_id;
47157 }
47158 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47159 index 6f91d2e..3f011d2 100644
47160 --- a/drivers/staging/media/solo6x10/solo6x10.h
47161 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47162 @@ -238,7 +238,7 @@ struct solo_dev {
47163
47164 /* P2M DMA Engine */
47165 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47166 - atomic_t p2m_count;
47167 + atomic_unchecked_t p2m_count;
47168 int p2m_jiffies;
47169 unsigned int p2m_timeouts;
47170
47171 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47172 index 34afc16..ffe44dd 100644
47173 --- a/drivers/staging/octeon/ethernet-rx.c
47174 +++ b/drivers/staging/octeon/ethernet-rx.c
47175 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47176 /* Increment RX stats for virtual ports */
47177 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47178 #ifdef CONFIG_64BIT
47179 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47180 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47181 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47182 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47183 #else
47184 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47185 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47186 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47187 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47188 #endif
47189 }
47190 netif_receive_skb(skb);
47191 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47192 dev->name);
47193 */
47194 #ifdef CONFIG_64BIT
47195 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47196 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47197 #else
47198 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47199 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47200 #endif
47201 dev_kfree_skb_irq(skb);
47202 }
47203 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47204 index c3a90e7..023619a 100644
47205 --- a/drivers/staging/octeon/ethernet.c
47206 +++ b/drivers/staging/octeon/ethernet.c
47207 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47208 * since the RX tasklet also increments it.
47209 */
47210 #ifdef CONFIG_64BIT
47211 - atomic64_add(rx_status.dropped_packets,
47212 - (atomic64_t *)&priv->stats.rx_dropped);
47213 + atomic64_add_unchecked(rx_status.dropped_packets,
47214 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47215 #else
47216 - atomic_add(rx_status.dropped_packets,
47217 - (atomic_t *)&priv->stats.rx_dropped);
47218 + atomic_add_unchecked(rx_status.dropped_packets,
47219 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47220 #endif
47221 }
47222
47223 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47224 index dc23395..cf7e9b1 100644
47225 --- a/drivers/staging/rtl8712/rtl871x_io.h
47226 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47227 @@ -108,7 +108,7 @@ struct _io_ops {
47228 u8 *pmem);
47229 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47230 u8 *pmem);
47231 -};
47232 +} __no_const;
47233
47234 struct io_req {
47235 struct list_head list;
47236 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47237 index 1f5088b..0e59820 100644
47238 --- a/drivers/staging/sbe-2t3e3/netdev.c
47239 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47240 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47241 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47242
47243 if (rlen)
47244 - if (copy_to_user(data, &resp, rlen))
47245 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47246 return -EFAULT;
47247
47248 return 0;
47249 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47250 index a863a98..d272795 100644
47251 --- a/drivers/staging/usbip/vhci.h
47252 +++ b/drivers/staging/usbip/vhci.h
47253 @@ -83,7 +83,7 @@ struct vhci_hcd {
47254 unsigned resuming:1;
47255 unsigned long re_timeout;
47256
47257 - atomic_t seqnum;
47258 + atomic_unchecked_t seqnum;
47259
47260 /*
47261 * NOTE:
47262 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47263 index d7974cb..d78076b 100644
47264 --- a/drivers/staging/usbip/vhci_hcd.c
47265 +++ b/drivers/staging/usbip/vhci_hcd.c
47266 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47267
47268 spin_lock(&vdev->priv_lock);
47269
47270 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47271 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47272 if (priv->seqnum == 0xffff)
47273 dev_info(&urb->dev->dev, "seqnum max\n");
47274
47275 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47276 return -ENOMEM;
47277 }
47278
47279 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47280 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47281 if (unlink->seqnum == 0xffff)
47282 pr_info("seqnum max\n");
47283
47284 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47285 vdev->rhport = rhport;
47286 }
47287
47288 - atomic_set(&vhci->seqnum, 0);
47289 + atomic_set_unchecked(&vhci->seqnum, 0);
47290 spin_lock_init(&vhci->lock);
47291
47292 hcd->power_budget = 0; /* no limit */
47293 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47294 index d07fcb5..358e1e1 100644
47295 --- a/drivers/staging/usbip/vhci_rx.c
47296 +++ b/drivers/staging/usbip/vhci_rx.c
47297 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47298 if (!urb) {
47299 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47300 pr_info("max seqnum %d\n",
47301 - atomic_read(&the_controller->seqnum));
47302 + atomic_read_unchecked(&the_controller->seqnum));
47303 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47304 return;
47305 }
47306 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47307 index 57a08c5..5b4bb7c 100644
47308 --- a/drivers/staging/vt6655/hostap.c
47309 +++ b/drivers/staging/vt6655/hostap.c
47310 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47311 *
47312 */
47313
47314 +static net_device_ops_no_const apdev_netdev_ops;
47315 +
47316 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47317 {
47318 PSDevice apdev_priv;
47319 struct net_device *dev = pDevice->dev;
47320 int ret;
47321 - const struct net_device_ops apdev_netdev_ops = {
47322 - .ndo_start_xmit = pDevice->tx_80211,
47323 - };
47324
47325 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47326
47327 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47328 *apdev_priv = *pDevice;
47329 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47330
47331 + /* only half broken now */
47332 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47333 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47334
47335 pDevice->apdev->type = ARPHRD_IEEE80211;
47336 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47337 index c699a30..b90a5fd 100644
47338 --- a/drivers/staging/vt6656/hostap.c
47339 +++ b/drivers/staging/vt6656/hostap.c
47340 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47341 *
47342 */
47343
47344 +static net_device_ops_no_const apdev_netdev_ops;
47345 +
47346 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47347 {
47348 struct vnt_private *apdev_priv;
47349 struct net_device *dev = pDevice->dev;
47350 int ret;
47351 - const struct net_device_ops apdev_netdev_ops = {
47352 - .ndo_start_xmit = pDevice->tx_80211,
47353 - };
47354
47355 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47356
47357 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47358 *apdev_priv = *pDevice;
47359 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47360
47361 + /* only half broken now */
47362 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47363 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47364
47365 pDevice->apdev->type = ARPHRD_IEEE80211;
47366 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47367 index d128ce2..fc1f9a1 100644
47368 --- a/drivers/staging/zcache/tmem.h
47369 +++ b/drivers/staging/zcache/tmem.h
47370 @@ -225,7 +225,7 @@ struct tmem_pamops {
47371 bool (*is_remote)(void *);
47372 int (*replace_in_obj)(void *, struct tmem_obj *);
47373 #endif
47374 -};
47375 +} __no_const;
47376 extern void tmem_register_pamops(struct tmem_pamops *m);
47377
47378 /* memory allocation methods provided by the host implementation */
47379 @@ -234,7 +234,7 @@ struct tmem_hostops {
47380 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47381 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47382 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47383 -};
47384 +} __no_const;
47385 extern void tmem_register_hostops(struct tmem_hostops *m);
47386
47387 /* core tmem accessor functions */
47388 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47389 index e51b09a..5ebac31 100644
47390 --- a/drivers/target/sbp/sbp_target.c
47391 +++ b/drivers/target/sbp/sbp_target.c
47392 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47393
47394 #define SESSION_MAINTENANCE_INTERVAL HZ
47395
47396 -static atomic_t login_id = ATOMIC_INIT(0);
47397 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47398
47399 static void session_maintenance_work(struct work_struct *);
47400 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47401 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47402 login->lun = se_lun;
47403 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47404 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47405 - login->login_id = atomic_inc_return(&login_id);
47406 + login->login_id = atomic_inc_return_unchecked(&login_id);
47407
47408 login->tgt_agt = sbp_target_agent_register(login);
47409 if (IS_ERR(login->tgt_agt)) {
47410 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47411 index 8f4142f..b127f7d 100644
47412 --- a/drivers/target/target_core_device.c
47413 +++ b/drivers/target/target_core_device.c
47414 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47415 spin_lock_init(&dev->se_port_lock);
47416 spin_lock_init(&dev->se_tmr_lock);
47417 spin_lock_init(&dev->qf_cmd_lock);
47418 - atomic_set(&dev->dev_ordered_id, 0);
47419 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47420 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47421 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47422 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47423 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47424 index d8e49d7..6fcfdec 100644
47425 --- a/drivers/target/target_core_transport.c
47426 +++ b/drivers/target/target_core_transport.c
47427 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47428 * Used to determine when ORDERED commands should go from
47429 * Dormant to Active status.
47430 */
47431 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47432 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47433 smp_mb__after_atomic_inc();
47434 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47435 cmd->se_ordered_id, cmd->sam_task_attr,
47436 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47437 index 33f83fe..d80f8e1 100644
47438 --- a/drivers/tty/cyclades.c
47439 +++ b/drivers/tty/cyclades.c
47440 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47441 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47442 info->port.count);
47443 #endif
47444 - info->port.count++;
47445 + atomic_inc(&info->port.count);
47446 #ifdef CY_DEBUG_COUNT
47447 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47448 - current->pid, info->port.count);
47449 + current->pid, atomic_read(&info->port.count));
47450 #endif
47451
47452 /*
47453 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47454 for (j = 0; j < cy_card[i].nports; j++) {
47455 info = &cy_card[i].ports[j];
47456
47457 - if (info->port.count) {
47458 + if (atomic_read(&info->port.count)) {
47459 /* XXX is the ldisc num worth this? */
47460 struct tty_struct *tty;
47461 struct tty_ldisc *ld;
47462 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47463 index eb255e8..f637a57 100644
47464 --- a/drivers/tty/hvc/hvc_console.c
47465 +++ b/drivers/tty/hvc/hvc_console.c
47466 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47467
47468 spin_lock_irqsave(&hp->port.lock, flags);
47469 /* Check and then increment for fast path open. */
47470 - if (hp->port.count++ > 0) {
47471 + if (atomic_inc_return(&hp->port.count) > 1) {
47472 spin_unlock_irqrestore(&hp->port.lock, flags);
47473 hvc_kick();
47474 return 0;
47475 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47476
47477 spin_lock_irqsave(&hp->port.lock, flags);
47478
47479 - if (--hp->port.count == 0) {
47480 + if (atomic_dec_return(&hp->port.count) == 0) {
47481 spin_unlock_irqrestore(&hp->port.lock, flags);
47482 /* We are done with the tty pointer now. */
47483 tty_port_tty_set(&hp->port, NULL);
47484 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47485 */
47486 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47487 } else {
47488 - if (hp->port.count < 0)
47489 + if (atomic_read(&hp->port.count) < 0)
47490 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47491 - hp->vtermno, hp->port.count);
47492 + hp->vtermno, atomic_read(&hp->port.count));
47493 spin_unlock_irqrestore(&hp->port.lock, flags);
47494 }
47495 }
47496 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47497 * open->hangup case this can be called after the final close so prevent
47498 * that from happening for now.
47499 */
47500 - if (hp->port.count <= 0) {
47501 + if (atomic_read(&hp->port.count) <= 0) {
47502 spin_unlock_irqrestore(&hp->port.lock, flags);
47503 return;
47504 }
47505
47506 - hp->port.count = 0;
47507 + atomic_set(&hp->port.count, 0);
47508 spin_unlock_irqrestore(&hp->port.lock, flags);
47509 tty_port_tty_set(&hp->port, NULL);
47510
47511 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47512 return -EPIPE;
47513
47514 /* FIXME what's this (unprotected) check for? */
47515 - if (hp->port.count <= 0)
47516 + if (atomic_read(&hp->port.count) <= 0)
47517 return -EIO;
47518
47519 spin_lock_irqsave(&hp->lock, flags);
47520 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47521 index 81e939e..95ead10 100644
47522 --- a/drivers/tty/hvc/hvcs.c
47523 +++ b/drivers/tty/hvc/hvcs.c
47524 @@ -83,6 +83,7 @@
47525 #include <asm/hvcserver.h>
47526 #include <asm/uaccess.h>
47527 #include <asm/vio.h>
47528 +#include <asm/local.h>
47529
47530 /*
47531 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47532 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47533
47534 spin_lock_irqsave(&hvcsd->lock, flags);
47535
47536 - if (hvcsd->port.count > 0) {
47537 + if (atomic_read(&hvcsd->port.count) > 0) {
47538 spin_unlock_irqrestore(&hvcsd->lock, flags);
47539 printk(KERN_INFO "HVCS: vterm state unchanged. "
47540 "The hvcs device node is still in use.\n");
47541 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47542 }
47543 }
47544
47545 - hvcsd->port.count = 0;
47546 + atomic_set(&hvcsd->port.count, 0);
47547 hvcsd->port.tty = tty;
47548 tty->driver_data = hvcsd;
47549
47550 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47551 unsigned long flags;
47552
47553 spin_lock_irqsave(&hvcsd->lock, flags);
47554 - hvcsd->port.count++;
47555 + atomic_inc(&hvcsd->port.count);
47556 hvcsd->todo_mask |= HVCS_SCHED_READ;
47557 spin_unlock_irqrestore(&hvcsd->lock, flags);
47558
47559 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47560 hvcsd = tty->driver_data;
47561
47562 spin_lock_irqsave(&hvcsd->lock, flags);
47563 - if (--hvcsd->port.count == 0) {
47564 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47565
47566 vio_disable_interrupts(hvcsd->vdev);
47567
47568 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47569
47570 free_irq(irq, hvcsd);
47571 return;
47572 - } else if (hvcsd->port.count < 0) {
47573 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47574 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47575 " is missmanaged.\n",
47576 - hvcsd->vdev->unit_address, hvcsd->port.count);
47577 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47578 }
47579
47580 spin_unlock_irqrestore(&hvcsd->lock, flags);
47581 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47582
47583 spin_lock_irqsave(&hvcsd->lock, flags);
47584 /* Preserve this so that we know how many kref refs to put */
47585 - temp_open_count = hvcsd->port.count;
47586 + temp_open_count = atomic_read(&hvcsd->port.count);
47587
47588 /*
47589 * Don't kref put inside the spinlock because the destruction
47590 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47591 tty->driver_data = NULL;
47592 hvcsd->port.tty = NULL;
47593
47594 - hvcsd->port.count = 0;
47595 + atomic_set(&hvcsd->port.count, 0);
47596
47597 /* This will drop any buffered data on the floor which is OK in a hangup
47598 * scenario. */
47599 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47600 * the middle of a write operation? This is a crummy place to do this
47601 * but we want to keep it all in the spinlock.
47602 */
47603 - if (hvcsd->port.count <= 0) {
47604 + if (atomic_read(&hvcsd->port.count) <= 0) {
47605 spin_unlock_irqrestore(&hvcsd->lock, flags);
47606 return -ENODEV;
47607 }
47608 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47609 {
47610 struct hvcs_struct *hvcsd = tty->driver_data;
47611
47612 - if (!hvcsd || hvcsd->port.count <= 0)
47613 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47614 return 0;
47615
47616 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47617 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47618 index 4190199..48f2920 100644
47619 --- a/drivers/tty/hvc/hvsi.c
47620 +++ b/drivers/tty/hvc/hvsi.c
47621 @@ -85,7 +85,7 @@ struct hvsi_struct {
47622 int n_outbuf;
47623 uint32_t vtermno;
47624 uint32_t virq;
47625 - atomic_t seqno; /* HVSI packet sequence number */
47626 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47627 uint16_t mctrl;
47628 uint8_t state; /* HVSI protocol state */
47629 uint8_t flags;
47630 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47631
47632 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47633 packet.hdr.len = sizeof(struct hvsi_query_response);
47634 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47635 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47636 packet.verb = VSV_SEND_VERSION_NUMBER;
47637 packet.u.version = HVSI_VERSION;
47638 packet.query_seqno = query_seqno+1;
47639 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47640
47641 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47642 packet.hdr.len = sizeof(struct hvsi_query);
47643 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47644 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47645 packet.verb = verb;
47646
47647 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47648 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47649 int wrote;
47650
47651 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47652 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47653 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47654 packet.hdr.len = sizeof(struct hvsi_control);
47655 packet.verb = VSV_SET_MODEM_CTL;
47656 packet.mask = HVSI_TSDTR;
47657 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47658 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47659
47660 packet.hdr.type = VS_DATA_PACKET_HEADER;
47661 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47662 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47663 packet.hdr.len = count + sizeof(struct hvsi_header);
47664 memcpy(&packet.data, buf, count);
47665
47666 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47667 struct hvsi_control packet __ALIGNED__;
47668
47669 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47670 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47671 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47672 packet.hdr.len = 6;
47673 packet.verb = VSV_CLOSE_PROTOCOL;
47674
47675 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47676 index ac27671..0f627ee 100644
47677 --- a/drivers/tty/hvc/hvsi_lib.c
47678 +++ b/drivers/tty/hvc/hvsi_lib.c
47679 @@ -9,7 +9,7 @@
47680
47681 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47682 {
47683 - packet->seqno = atomic_inc_return(&pv->seqno);
47684 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47685
47686 /* Assumes that always succeeds, works in practice */
47687 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47688 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47689
47690 /* Reset state */
47691 pv->established = 0;
47692 - atomic_set(&pv->seqno, 0);
47693 + atomic_set_unchecked(&pv->seqno, 0);
47694
47695 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47696
47697 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47698 pv->mctrl_update = 0;
47699 q.hdr.type = VS_QUERY_PACKET_HEADER;
47700 q.hdr.len = sizeof(struct hvsi_query);
47701 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47702 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47703 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47704 rc = hvsi_send_packet(pv, &q.hdr);
47705 if (rc <= 0) {
47706 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47707 index 8fd72ff..34a0bed 100644
47708 --- a/drivers/tty/ipwireless/tty.c
47709 +++ b/drivers/tty/ipwireless/tty.c
47710 @@ -29,6 +29,7 @@
47711 #include <linux/tty_driver.h>
47712 #include <linux/tty_flip.h>
47713 #include <linux/uaccess.h>
47714 +#include <asm/local.h>
47715
47716 #include "tty.h"
47717 #include "network.h"
47718 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47719 mutex_unlock(&tty->ipw_tty_mutex);
47720 return -ENODEV;
47721 }
47722 - if (tty->port.count == 0)
47723 + if (atomic_read(&tty->port.count) == 0)
47724 tty->tx_bytes_queued = 0;
47725
47726 - tty->port.count++;
47727 + atomic_inc(&tty->port.count);
47728
47729 tty->port.tty = linux_tty;
47730 linux_tty->driver_data = tty;
47731 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47732
47733 static void do_ipw_close(struct ipw_tty *tty)
47734 {
47735 - tty->port.count--;
47736 -
47737 - if (tty->port.count == 0) {
47738 + if (atomic_dec_return(&tty->port.count) == 0) {
47739 struct tty_struct *linux_tty = tty->port.tty;
47740
47741 if (linux_tty != NULL) {
47742 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47743 return;
47744
47745 mutex_lock(&tty->ipw_tty_mutex);
47746 - if (tty->port.count == 0) {
47747 + if (atomic_read(&tty->port.count) == 0) {
47748 mutex_unlock(&tty->ipw_tty_mutex);
47749 return;
47750 }
47751 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47752
47753 mutex_lock(&tty->ipw_tty_mutex);
47754
47755 - if (!tty->port.count) {
47756 + if (!atomic_read(&tty->port.count)) {
47757 mutex_unlock(&tty->ipw_tty_mutex);
47758 return;
47759 }
47760 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47761 return -ENODEV;
47762
47763 mutex_lock(&tty->ipw_tty_mutex);
47764 - if (!tty->port.count) {
47765 + if (!atomic_read(&tty->port.count)) {
47766 mutex_unlock(&tty->ipw_tty_mutex);
47767 return -EINVAL;
47768 }
47769 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47770 if (!tty)
47771 return -ENODEV;
47772
47773 - if (!tty->port.count)
47774 + if (!atomic_read(&tty->port.count))
47775 return -EINVAL;
47776
47777 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47778 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47779 if (!tty)
47780 return 0;
47781
47782 - if (!tty->port.count)
47783 + if (!atomic_read(&tty->port.count))
47784 return 0;
47785
47786 return tty->tx_bytes_queued;
47787 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47788 if (!tty)
47789 return -ENODEV;
47790
47791 - if (!tty->port.count)
47792 + if (!atomic_read(&tty->port.count))
47793 return -EINVAL;
47794
47795 return get_control_lines(tty);
47796 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47797 if (!tty)
47798 return -ENODEV;
47799
47800 - if (!tty->port.count)
47801 + if (!atomic_read(&tty->port.count))
47802 return -EINVAL;
47803
47804 return set_control_lines(tty, set, clear);
47805 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47806 if (!tty)
47807 return -ENODEV;
47808
47809 - if (!tty->port.count)
47810 + if (!atomic_read(&tty->port.count))
47811 return -EINVAL;
47812
47813 /* FIXME: Exactly how is the tty object locked here .. */
47814 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47815 * are gone */
47816 mutex_lock(&ttyj->ipw_tty_mutex);
47817 }
47818 - while (ttyj->port.count)
47819 + while (atomic_read(&ttyj->port.count))
47820 do_ipw_close(ttyj);
47821 ipwireless_disassociate_network_ttys(network,
47822 ttyj->channel_idx);
47823 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47824 index 1deaca4..c8582d4 100644
47825 --- a/drivers/tty/moxa.c
47826 +++ b/drivers/tty/moxa.c
47827 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47828 }
47829
47830 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47831 - ch->port.count++;
47832 + atomic_inc(&ch->port.count);
47833 tty->driver_data = ch;
47834 tty_port_tty_set(&ch->port, tty);
47835 mutex_lock(&ch->port.mutex);
47836 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47837 index 6422390..49003ac8 100644
47838 --- a/drivers/tty/n_gsm.c
47839 +++ b/drivers/tty/n_gsm.c
47840 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47841 spin_lock_init(&dlci->lock);
47842 mutex_init(&dlci->mutex);
47843 dlci->fifo = &dlci->_fifo;
47844 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47845 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47846 kfree(dlci);
47847 return NULL;
47848 }
47849 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47850 struct gsm_dlci *dlci = tty->driver_data;
47851 struct tty_port *port = &dlci->port;
47852
47853 - port->count++;
47854 + atomic_inc(&port->count);
47855 dlci_get(dlci);
47856 dlci_get(dlci->gsm->dlci[0]);
47857 mux_get(dlci->gsm);
47858 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47859 index 4bf0fc0..433bd58 100644
47860 --- a/drivers/tty/n_tty.c
47861 +++ b/drivers/tty/n_tty.c
47862 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47863 {
47864 *ops = tty_ldisc_N_TTY;
47865 ops->owner = NULL;
47866 - ops->refcount = ops->flags = 0;
47867 + atomic_set(&ops->refcount, 0);
47868 + ops->flags = 0;
47869 }
47870 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47871 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47872 index abfd990..5ab5da9 100644
47873 --- a/drivers/tty/pty.c
47874 +++ b/drivers/tty/pty.c
47875 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
47876 panic("Couldn't register Unix98 pts driver");
47877
47878 /* Now create the /dev/ptmx special device */
47879 + pax_open_kernel();
47880 tty_default_fops(&ptmx_fops);
47881 - ptmx_fops.open = ptmx_open;
47882 + *(void **)&ptmx_fops.open = ptmx_open;
47883 + pax_close_kernel();
47884
47885 cdev_init(&ptmx_cdev, &ptmx_fops);
47886 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47887 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47888 index 354564e..fe50d9a 100644
47889 --- a/drivers/tty/rocket.c
47890 +++ b/drivers/tty/rocket.c
47891 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47892 tty->driver_data = info;
47893 tty_port_tty_set(port, tty);
47894
47895 - if (port->count++ == 0) {
47896 + if (atomic_inc_return(&port->count) == 1) {
47897 atomic_inc(&rp_num_ports_open);
47898
47899 #ifdef ROCKET_DEBUG_OPEN
47900 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47901 #endif
47902 }
47903 #ifdef ROCKET_DEBUG_OPEN
47904 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47905 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47906 #endif
47907
47908 /*
47909 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47910 spin_unlock_irqrestore(&info->port.lock, flags);
47911 return;
47912 }
47913 - if (info->port.count)
47914 + if (atomic_read(&info->port.count))
47915 atomic_dec(&rp_num_ports_open);
47916 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47917 spin_unlock_irqrestore(&info->port.lock, flags);
47918 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47919 index e2520ab..034e20b 100644
47920 --- a/drivers/tty/serial/ioc4_serial.c
47921 +++ b/drivers/tty/serial/ioc4_serial.c
47922 @@ -437,7 +437,7 @@ struct ioc4_soft {
47923 } is_intr_info[MAX_IOC4_INTR_ENTS];
47924
47925 /* Number of entries active in the above array */
47926 - atomic_t is_num_intrs;
47927 + atomic_unchecked_t is_num_intrs;
47928 } is_intr_type[IOC4_NUM_INTR_TYPES];
47929
47930 /* is_ir_lock must be held while
47931 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47932 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47933 || (type == IOC4_OTHER_INTR_TYPE)));
47934
47935 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47936 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47937 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47938
47939 /* Save off the lower level interrupt handler */
47940 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47941
47942 soft = arg;
47943 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47944 - num_intrs = (int)atomic_read(
47945 + num_intrs = (int)atomic_read_unchecked(
47946 &soft->is_intr_type[intr_type].is_num_intrs);
47947
47948 this_mir = this_ir = pending_intrs(soft, intr_type);
47949 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47950 index 1002054..dd644a8 100644
47951 --- a/drivers/tty/serial/kgdboc.c
47952 +++ b/drivers/tty/serial/kgdboc.c
47953 @@ -24,8 +24,9 @@
47954 #define MAX_CONFIG_LEN 40
47955
47956 static struct kgdb_io kgdboc_io_ops;
47957 +static struct kgdb_io kgdboc_io_ops_console;
47958
47959 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
47960 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
47961 static int configured = -1;
47962
47963 static char config[MAX_CONFIG_LEN];
47964 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
47965 kgdboc_unregister_kbd();
47966 if (configured == 1)
47967 kgdb_unregister_io_module(&kgdboc_io_ops);
47968 + else if (configured == 2)
47969 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
47970 }
47971
47972 static int configure_kgdboc(void)
47973 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
47974 int err;
47975 char *cptr = config;
47976 struct console *cons;
47977 + int is_console = 0;
47978
47979 err = kgdboc_option_setup(config);
47980 if (err || !strlen(config) || isspace(config[0]))
47981 goto noconfig;
47982
47983 err = -ENODEV;
47984 - kgdboc_io_ops.is_console = 0;
47985 kgdb_tty_driver = NULL;
47986
47987 kgdboc_use_kms = 0;
47988 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
47989 int idx;
47990 if (cons->device && cons->device(cons, &idx) == p &&
47991 idx == tty_line) {
47992 - kgdboc_io_ops.is_console = 1;
47993 + is_console = 1;
47994 break;
47995 }
47996 cons = cons->next;
47997 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
47998 kgdb_tty_line = tty_line;
47999
48000 do_register:
48001 - err = kgdb_register_io_module(&kgdboc_io_ops);
48002 + if (is_console) {
48003 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48004 + configured = 2;
48005 + } else {
48006 + err = kgdb_register_io_module(&kgdboc_io_ops);
48007 + configured = 1;
48008 + }
48009 if (err)
48010 goto noconfig;
48011
48012 @@ -205,8 +214,6 @@ do_register:
48013 if (err)
48014 goto nmi_con_failed;
48015
48016 - configured = 1;
48017 -
48018 return 0;
48019
48020 nmi_con_failed:
48021 @@ -223,7 +230,7 @@ noconfig:
48022 static int __init init_kgdboc(void)
48023 {
48024 /* Already configured? */
48025 - if (configured == 1)
48026 + if (configured >= 1)
48027 return 0;
48028
48029 return configure_kgdboc();
48030 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48031 if (config[len - 1] == '\n')
48032 config[len - 1] = '\0';
48033
48034 - if (configured == 1)
48035 + if (configured >= 1)
48036 cleanup_kgdboc();
48037
48038 /* Go and configure with the new params. */
48039 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48040 .post_exception = kgdboc_post_exp_handler,
48041 };
48042
48043 +static struct kgdb_io kgdboc_io_ops_console = {
48044 + .name = "kgdboc",
48045 + .read_char = kgdboc_get_char,
48046 + .write_char = kgdboc_put_char,
48047 + .pre_exception = kgdboc_pre_exp_handler,
48048 + .post_exception = kgdboc_post_exp_handler,
48049 + .is_console = 1
48050 +};
48051 +
48052 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48053 /* This is only available if kgdboc is a built in for early debugging */
48054 static int __init kgdboc_early_init(char *opt)
48055 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48056 index 2c6cfb3..048274e 100644
48057 --- a/drivers/tty/serial/msm_serial.c
48058 +++ b/drivers/tty/serial/msm_serial.c
48059 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48060 .cons = MSM_CONSOLE,
48061 };
48062
48063 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48064 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48065
48066 static int __init msm_serial_probe(struct platform_device *pdev)
48067 {
48068 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48069 int irq;
48070
48071 if (pdev->id == -1)
48072 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48073 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48074
48075 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48076 return -ENXIO;
48077 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48078 index 376079b..d8de7aa 100644
48079 --- a/drivers/tty/serial/samsung.c
48080 +++ b/drivers/tty/serial/samsung.c
48081 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48082 }
48083 }
48084
48085 +static int s3c64xx_serial_startup(struct uart_port *port);
48086 static int s3c24xx_serial_startup(struct uart_port *port)
48087 {
48088 struct s3c24xx_uart_port *ourport = to_ourport(port);
48089 int ret;
48090
48091 + /* Startup sequence is different for s3c64xx and higher SoC's */
48092 + if (s3c24xx_serial_has_interrupt_mask(port))
48093 + return s3c64xx_serial_startup(port);
48094 +
48095 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48096 port->mapbase, port->membase);
48097
48098 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48099 /* setup info for port */
48100 port->dev = &platdev->dev;
48101
48102 - /* Startup sequence is different for s3c64xx and higher SoC's */
48103 - if (s3c24xx_serial_has_interrupt_mask(port))
48104 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48105 -
48106 port->uartclk = 1;
48107
48108 if (cfg->uart_flags & UPF_CONS_FLOW) {
48109 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48110 index 28cdd28..56f1d60 100644
48111 --- a/drivers/tty/serial/serial_core.c
48112 +++ b/drivers/tty/serial/serial_core.c
48113 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48114 uart_flush_buffer(tty);
48115 uart_shutdown(tty, state);
48116 spin_lock_irqsave(&port->lock, flags);
48117 - port->count = 0;
48118 + atomic_set(&port->count, 0);
48119 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48120 spin_unlock_irqrestore(&port->lock, flags);
48121 tty_port_tty_set(port, NULL);
48122 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48123 goto end;
48124 }
48125
48126 - port->count++;
48127 + atomic_inc(&port->count);
48128 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48129 retval = -ENXIO;
48130 goto err_dec_count;
48131 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48132 /*
48133 * Make sure the device is in D0 state.
48134 */
48135 - if (port->count == 1)
48136 + if (atomic_read(&port->count) == 1)
48137 uart_change_pm(state, UART_PM_STATE_ON);
48138
48139 /*
48140 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48141 end:
48142 return retval;
48143 err_dec_count:
48144 - port->count--;
48145 + atomic_inc(&port->count);
48146 mutex_unlock(&port->mutex);
48147 goto end;
48148 }
48149 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48150 index 8eaf1ab..85c030d 100644
48151 --- a/drivers/tty/synclink.c
48152 +++ b/drivers/tty/synclink.c
48153 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48154
48155 if (debug_level >= DEBUG_LEVEL_INFO)
48156 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48157 - __FILE__,__LINE__, info->device_name, info->port.count);
48158 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48159
48160 if (tty_port_close_start(&info->port, tty, filp) == 0)
48161 goto cleanup;
48162 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48163 cleanup:
48164 if (debug_level >= DEBUG_LEVEL_INFO)
48165 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48166 - tty->driver->name, info->port.count);
48167 + tty->driver->name, atomic_read(&info->port.count));
48168
48169 } /* end of mgsl_close() */
48170
48171 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48172
48173 mgsl_flush_buffer(tty);
48174 shutdown(info);
48175 -
48176 - info->port.count = 0;
48177 +
48178 + atomic_set(&info->port.count, 0);
48179 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48180 info->port.tty = NULL;
48181
48182 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48183
48184 if (debug_level >= DEBUG_LEVEL_INFO)
48185 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48186 - __FILE__,__LINE__, tty->driver->name, port->count );
48187 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48188
48189 spin_lock_irqsave(&info->irq_spinlock, flags);
48190 if (!tty_hung_up_p(filp)) {
48191 extra_count = true;
48192 - port->count--;
48193 + atomic_dec(&port->count);
48194 }
48195 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48196 port->blocked_open++;
48197 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48198
48199 if (debug_level >= DEBUG_LEVEL_INFO)
48200 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48201 - __FILE__,__LINE__, tty->driver->name, port->count );
48202 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48203
48204 tty_unlock(tty);
48205 schedule();
48206 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48207
48208 /* FIXME: Racy on hangup during close wait */
48209 if (extra_count)
48210 - port->count++;
48211 + atomic_inc(&port->count);
48212 port->blocked_open--;
48213
48214 if (debug_level >= DEBUG_LEVEL_INFO)
48215 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48216 - __FILE__,__LINE__, tty->driver->name, port->count );
48217 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48218
48219 if (!retval)
48220 port->flags |= ASYNC_NORMAL_ACTIVE;
48221 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48222
48223 if (debug_level >= DEBUG_LEVEL_INFO)
48224 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48225 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48226 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48227
48228 /* If port is closing, signal caller to try again */
48229 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48230 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48231 spin_unlock_irqrestore(&info->netlock, flags);
48232 goto cleanup;
48233 }
48234 - info->port.count++;
48235 + atomic_inc(&info->port.count);
48236 spin_unlock_irqrestore(&info->netlock, flags);
48237
48238 - if (info->port.count == 1) {
48239 + if (atomic_read(&info->port.count) == 1) {
48240 /* 1st open on this device, init hardware */
48241 retval = startup(info);
48242 if (retval < 0)
48243 @@ -3446,8 +3446,8 @@ cleanup:
48244 if (retval) {
48245 if (tty->count == 1)
48246 info->port.tty = NULL; /* tty layer will release tty struct */
48247 - if(info->port.count)
48248 - info->port.count--;
48249 + if (atomic_read(&info->port.count))
48250 + atomic_dec(&info->port.count);
48251 }
48252
48253 return retval;
48254 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48255 unsigned short new_crctype;
48256
48257 /* return error if TTY interface open */
48258 - if (info->port.count)
48259 + if (atomic_read(&info->port.count))
48260 return -EBUSY;
48261
48262 switch (encoding)
48263 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48264
48265 /* arbitrate between network and tty opens */
48266 spin_lock_irqsave(&info->netlock, flags);
48267 - if (info->port.count != 0 || info->netcount != 0) {
48268 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48269 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48270 spin_unlock_irqrestore(&info->netlock, flags);
48271 return -EBUSY;
48272 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48273 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48274
48275 /* return error if TTY interface open */
48276 - if (info->port.count)
48277 + if (atomic_read(&info->port.count))
48278 return -EBUSY;
48279
48280 if (cmd != SIOCWANDEV)
48281 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48282 index 1abf946..1ee34fc 100644
48283 --- a/drivers/tty/synclink_gt.c
48284 +++ b/drivers/tty/synclink_gt.c
48285 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48286 tty->driver_data = info;
48287 info->port.tty = tty;
48288
48289 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48290 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48291
48292 /* If port is closing, signal caller to try again */
48293 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48294 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48295 mutex_unlock(&info->port.mutex);
48296 goto cleanup;
48297 }
48298 - info->port.count++;
48299 + atomic_inc(&info->port.count);
48300 spin_unlock_irqrestore(&info->netlock, flags);
48301
48302 - if (info->port.count == 1) {
48303 + if (atomic_read(&info->port.count) == 1) {
48304 /* 1st open on this device, init hardware */
48305 retval = startup(info);
48306 if (retval < 0) {
48307 @@ -715,8 +715,8 @@ cleanup:
48308 if (retval) {
48309 if (tty->count == 1)
48310 info->port.tty = NULL; /* tty layer will release tty struct */
48311 - if(info->port.count)
48312 - info->port.count--;
48313 + if(atomic_read(&info->port.count))
48314 + atomic_dec(&info->port.count);
48315 }
48316
48317 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48318 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48319
48320 if (sanity_check(info, tty->name, "close"))
48321 return;
48322 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48323 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48324
48325 if (tty_port_close_start(&info->port, tty, filp) == 0)
48326 goto cleanup;
48327 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48328 tty_port_close_end(&info->port, tty);
48329 info->port.tty = NULL;
48330 cleanup:
48331 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48332 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48333 }
48334
48335 static void hangup(struct tty_struct *tty)
48336 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48337 shutdown(info);
48338
48339 spin_lock_irqsave(&info->port.lock, flags);
48340 - info->port.count = 0;
48341 + atomic_set(&info->port.count, 0);
48342 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48343 info->port.tty = NULL;
48344 spin_unlock_irqrestore(&info->port.lock, flags);
48345 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48346 unsigned short new_crctype;
48347
48348 /* return error if TTY interface open */
48349 - if (info->port.count)
48350 + if (atomic_read(&info->port.count))
48351 return -EBUSY;
48352
48353 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48354 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48355
48356 /* arbitrate between network and tty opens */
48357 spin_lock_irqsave(&info->netlock, flags);
48358 - if (info->port.count != 0 || info->netcount != 0) {
48359 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48360 DBGINFO(("%s hdlc_open busy\n", dev->name));
48361 spin_unlock_irqrestore(&info->netlock, flags);
48362 return -EBUSY;
48363 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48364 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48365
48366 /* return error if TTY interface open */
48367 - if (info->port.count)
48368 + if (atomic_read(&info->port.count))
48369 return -EBUSY;
48370
48371 if (cmd != SIOCWANDEV)
48372 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48373 if (port == NULL)
48374 continue;
48375 spin_lock(&port->lock);
48376 - if ((port->port.count || port->netcount) &&
48377 + if ((atomic_read(&port->port.count) || port->netcount) &&
48378 port->pending_bh && !port->bh_running &&
48379 !port->bh_requested) {
48380 DBGISR(("%s bh queued\n", port->device_name));
48381 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48382 spin_lock_irqsave(&info->lock, flags);
48383 if (!tty_hung_up_p(filp)) {
48384 extra_count = true;
48385 - port->count--;
48386 + atomic_dec(&port->count);
48387 }
48388 spin_unlock_irqrestore(&info->lock, flags);
48389 port->blocked_open++;
48390 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48391 remove_wait_queue(&port->open_wait, &wait);
48392
48393 if (extra_count)
48394 - port->count++;
48395 + atomic_inc(&port->count);
48396 port->blocked_open--;
48397
48398 if (!retval)
48399 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48400 index dc6e969..5dc8786 100644
48401 --- a/drivers/tty/synclinkmp.c
48402 +++ b/drivers/tty/synclinkmp.c
48403 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48404
48405 if (debug_level >= DEBUG_LEVEL_INFO)
48406 printk("%s(%d):%s open(), old ref count = %d\n",
48407 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48408 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48409
48410 /* If port is closing, signal caller to try again */
48411 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48412 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48413 spin_unlock_irqrestore(&info->netlock, flags);
48414 goto cleanup;
48415 }
48416 - info->port.count++;
48417 + atomic_inc(&info->port.count);
48418 spin_unlock_irqrestore(&info->netlock, flags);
48419
48420 - if (info->port.count == 1) {
48421 + if (atomic_read(&info->port.count) == 1) {
48422 /* 1st open on this device, init hardware */
48423 retval = startup(info);
48424 if (retval < 0)
48425 @@ -796,8 +796,8 @@ cleanup:
48426 if (retval) {
48427 if (tty->count == 1)
48428 info->port.tty = NULL; /* tty layer will release tty struct */
48429 - if(info->port.count)
48430 - info->port.count--;
48431 + if(atomic_read(&info->port.count))
48432 + atomic_dec(&info->port.count);
48433 }
48434
48435 return retval;
48436 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48437
48438 if (debug_level >= DEBUG_LEVEL_INFO)
48439 printk("%s(%d):%s close() entry, count=%d\n",
48440 - __FILE__,__LINE__, info->device_name, info->port.count);
48441 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48442
48443 if (tty_port_close_start(&info->port, tty, filp) == 0)
48444 goto cleanup;
48445 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48446 cleanup:
48447 if (debug_level >= DEBUG_LEVEL_INFO)
48448 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48449 - tty->driver->name, info->port.count);
48450 + tty->driver->name, atomic_read(&info->port.count));
48451 }
48452
48453 /* Called by tty_hangup() when a hangup is signaled.
48454 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48455 shutdown(info);
48456
48457 spin_lock_irqsave(&info->port.lock, flags);
48458 - info->port.count = 0;
48459 + atomic_set(&info->port.count, 0);
48460 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48461 info->port.tty = NULL;
48462 spin_unlock_irqrestore(&info->port.lock, flags);
48463 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48464 unsigned short new_crctype;
48465
48466 /* return error if TTY interface open */
48467 - if (info->port.count)
48468 + if (atomic_read(&info->port.count))
48469 return -EBUSY;
48470
48471 switch (encoding)
48472 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48473
48474 /* arbitrate between network and tty opens */
48475 spin_lock_irqsave(&info->netlock, flags);
48476 - if (info->port.count != 0 || info->netcount != 0) {
48477 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48478 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48479 spin_unlock_irqrestore(&info->netlock, flags);
48480 return -EBUSY;
48481 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48482 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48483
48484 /* return error if TTY interface open */
48485 - if (info->port.count)
48486 + if (atomic_read(&info->port.count))
48487 return -EBUSY;
48488
48489 if (cmd != SIOCWANDEV)
48490 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48491 * do not request bottom half processing if the
48492 * device is not open in a normal mode.
48493 */
48494 - if ( port && (port->port.count || port->netcount) &&
48495 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48496 port->pending_bh && !port->bh_running &&
48497 !port->bh_requested ) {
48498 if ( debug_level >= DEBUG_LEVEL_ISR )
48499 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48500
48501 if (debug_level >= DEBUG_LEVEL_INFO)
48502 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48503 - __FILE__,__LINE__, tty->driver->name, port->count );
48504 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48505
48506 spin_lock_irqsave(&info->lock, flags);
48507 if (!tty_hung_up_p(filp)) {
48508 extra_count = true;
48509 - port->count--;
48510 + atomic_dec(&port->count);
48511 }
48512 spin_unlock_irqrestore(&info->lock, flags);
48513 port->blocked_open++;
48514 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48515
48516 if (debug_level >= DEBUG_LEVEL_INFO)
48517 printk("%s(%d):%s block_til_ready() count=%d\n",
48518 - __FILE__,__LINE__, tty->driver->name, port->count );
48519 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48520
48521 tty_unlock(tty);
48522 schedule();
48523 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48524 remove_wait_queue(&port->open_wait, &wait);
48525
48526 if (extra_count)
48527 - port->count++;
48528 + atomic_inc(&port->count);
48529 port->blocked_open--;
48530
48531 if (debug_level >= DEBUG_LEVEL_INFO)
48532 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48533 - __FILE__,__LINE__, tty->driver->name, port->count );
48534 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48535
48536 if (!retval)
48537 port->flags |= ASYNC_NORMAL_ACTIVE;
48538 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48539 index d5cc3ac..3263411 100644
48540 --- a/drivers/tty/sysrq.c
48541 +++ b/drivers/tty/sysrq.c
48542 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48543 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48544 size_t count, loff_t *ppos)
48545 {
48546 - if (count) {
48547 + if (count && capable(CAP_SYS_ADMIN)) {
48548 char c;
48549
48550 if (get_user(c, buf))
48551 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48552 index 20689b9..7fd3a31 100644
48553 --- a/drivers/tty/tty_io.c
48554 +++ b/drivers/tty/tty_io.c
48555 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48556
48557 void tty_default_fops(struct file_operations *fops)
48558 {
48559 - *fops = tty_fops;
48560 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48561 }
48562
48563 /*
48564 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48565 index 1afe192..73d2c20 100644
48566 --- a/drivers/tty/tty_ldisc.c
48567 +++ b/drivers/tty/tty_ldisc.c
48568 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48569 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48570 tty_ldiscs[disc] = new_ldisc;
48571 new_ldisc->num = disc;
48572 - new_ldisc->refcount = 0;
48573 + atomic_set(&new_ldisc->refcount, 0);
48574 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48575
48576 return ret;
48577 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48578 return -EINVAL;
48579
48580 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48581 - if (tty_ldiscs[disc]->refcount)
48582 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48583 ret = -EBUSY;
48584 else
48585 tty_ldiscs[disc] = NULL;
48586 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48587 if (ldops) {
48588 ret = ERR_PTR(-EAGAIN);
48589 if (try_module_get(ldops->owner)) {
48590 - ldops->refcount++;
48591 + atomic_inc(&ldops->refcount);
48592 ret = ldops;
48593 }
48594 }
48595 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48596 unsigned long flags;
48597
48598 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48599 - ldops->refcount--;
48600 + atomic_dec(&ldops->refcount);
48601 module_put(ldops->owner);
48602 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48603 }
48604 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48605 /* unreleased reader reference(s) will cause this WARN */
48606 WARN_ON(!atomic_dec_and_test(&ld->users));
48607
48608 - ld->ops->refcount--;
48609 + atomic_dec(&ld->ops->refcount);
48610 module_put(ld->ops->owner);
48611 kfree(ld);
48612 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48613 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48614 index f597e88..b7f68ed 100644
48615 --- a/drivers/tty/tty_port.c
48616 +++ b/drivers/tty/tty_port.c
48617 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48618 unsigned long flags;
48619
48620 spin_lock_irqsave(&port->lock, flags);
48621 - port->count = 0;
48622 + atomic_set(&port->count, 0);
48623 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48624 tty = port->tty;
48625 if (tty)
48626 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48627 /* The port lock protects the port counts */
48628 spin_lock_irqsave(&port->lock, flags);
48629 if (!tty_hung_up_p(filp))
48630 - port->count--;
48631 + atomic_dec(&port->count);
48632 port->blocked_open++;
48633 spin_unlock_irqrestore(&port->lock, flags);
48634
48635 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48636 we must not mess that up further */
48637 spin_lock_irqsave(&port->lock, flags);
48638 if (!tty_hung_up_p(filp))
48639 - port->count++;
48640 + atomic_inc(&port->count);
48641 port->blocked_open--;
48642 if (retval == 0)
48643 port->flags |= ASYNC_NORMAL_ACTIVE;
48644 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48645 return 0;
48646 }
48647
48648 - if (tty->count == 1 && port->count != 1) {
48649 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48650 printk(KERN_WARNING
48651 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48652 - port->count);
48653 - port->count = 1;
48654 + atomic_read(&port->count));
48655 + atomic_set(&port->count, 1);
48656 }
48657 - if (--port->count < 0) {
48658 + if (atomic_dec_return(&port->count) < 0) {
48659 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48660 - port->count);
48661 - port->count = 0;
48662 + atomic_read(&port->count));
48663 + atomic_set(&port->count, 0);
48664 }
48665
48666 - if (port->count) {
48667 + if (atomic_read(&port->count)) {
48668 spin_unlock_irqrestore(&port->lock, flags);
48669 if (port->ops->drop)
48670 port->ops->drop(port);
48671 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48672 {
48673 spin_lock_irq(&port->lock);
48674 if (!tty_hung_up_p(filp))
48675 - ++port->count;
48676 + atomic_inc(&port->count);
48677 spin_unlock_irq(&port->lock);
48678 tty_port_tty_set(port, tty);
48679
48680 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48681 index a9af1b9a..1e08e7f 100644
48682 --- a/drivers/tty/vt/keyboard.c
48683 +++ b/drivers/tty/vt/keyboard.c
48684 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48685 kbd->kbdmode == VC_OFF) &&
48686 value != KVAL(K_SAK))
48687 return; /* SAK is allowed even in raw mode */
48688 +
48689 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48690 + {
48691 + void *func = fn_handler[value];
48692 + if (func == fn_show_state || func == fn_show_ptregs ||
48693 + func == fn_show_mem)
48694 + return;
48695 + }
48696 +#endif
48697 +
48698 fn_handler[value](vc);
48699 }
48700
48701 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48702 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48703 return -EFAULT;
48704
48705 - if (!capable(CAP_SYS_TTY_CONFIG))
48706 - perm = 0;
48707 -
48708 switch (cmd) {
48709 case KDGKBENT:
48710 /* Ensure another thread doesn't free it under us */
48711 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48712 spin_unlock_irqrestore(&kbd_event_lock, flags);
48713 return put_user(val, &user_kbe->kb_value);
48714 case KDSKBENT:
48715 + if (!capable(CAP_SYS_TTY_CONFIG))
48716 + perm = 0;
48717 +
48718 if (!perm)
48719 return -EPERM;
48720 if (!i && v == K_NOSUCHMAP) {
48721 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48722 int i, j, k;
48723 int ret;
48724
48725 - if (!capable(CAP_SYS_TTY_CONFIG))
48726 - perm = 0;
48727 -
48728 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48729 if (!kbs) {
48730 ret = -ENOMEM;
48731 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48732 kfree(kbs);
48733 return ((p && *p) ? -EOVERFLOW : 0);
48734 case KDSKBSENT:
48735 + if (!capable(CAP_SYS_TTY_CONFIG))
48736 + perm = 0;
48737 +
48738 if (!perm) {
48739 ret = -EPERM;
48740 goto reterr;
48741 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48742 index 3b96f18..026a9bf 100644
48743 --- a/drivers/uio/uio.c
48744 +++ b/drivers/uio/uio.c
48745 @@ -25,6 +25,7 @@
48746 #include <linux/kobject.h>
48747 #include <linux/cdev.h>
48748 #include <linux/uio_driver.h>
48749 +#include <asm/local.h>
48750
48751 #define UIO_MAX_DEVICES (1U << MINORBITS)
48752
48753 @@ -32,10 +33,10 @@ struct uio_device {
48754 struct module *owner;
48755 struct device *dev;
48756 int minor;
48757 - atomic_t event;
48758 + atomic_unchecked_t event;
48759 struct fasync_struct *async_queue;
48760 wait_queue_head_t wait;
48761 - int vma_count;
48762 + local_t vma_count;
48763 struct uio_info *info;
48764 struct kobject *map_dir;
48765 struct kobject *portio_dir;
48766 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48767 struct device_attribute *attr, char *buf)
48768 {
48769 struct uio_device *idev = dev_get_drvdata(dev);
48770 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48771 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48772 }
48773
48774 static struct device_attribute uio_class_attributes[] = {
48775 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48776 {
48777 struct uio_device *idev = info->uio_dev;
48778
48779 - atomic_inc(&idev->event);
48780 + atomic_inc_unchecked(&idev->event);
48781 wake_up_interruptible(&idev->wait);
48782 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48783 }
48784 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48785 }
48786
48787 listener->dev = idev;
48788 - listener->event_count = atomic_read(&idev->event);
48789 + listener->event_count = atomic_read_unchecked(&idev->event);
48790 filep->private_data = listener;
48791
48792 if (idev->info->open) {
48793 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48794 return -EIO;
48795
48796 poll_wait(filep, &idev->wait, wait);
48797 - if (listener->event_count != atomic_read(&idev->event))
48798 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48799 return POLLIN | POLLRDNORM;
48800 return 0;
48801 }
48802 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48803 do {
48804 set_current_state(TASK_INTERRUPTIBLE);
48805
48806 - event_count = atomic_read(&idev->event);
48807 + event_count = atomic_read_unchecked(&idev->event);
48808 if (event_count != listener->event_count) {
48809 if (copy_to_user(buf, &event_count, count))
48810 retval = -EFAULT;
48811 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48812 static void uio_vma_open(struct vm_area_struct *vma)
48813 {
48814 struct uio_device *idev = vma->vm_private_data;
48815 - idev->vma_count++;
48816 + local_inc(&idev->vma_count);
48817 }
48818
48819 static void uio_vma_close(struct vm_area_struct *vma)
48820 {
48821 struct uio_device *idev = vma->vm_private_data;
48822 - idev->vma_count--;
48823 + local_dec(&idev->vma_count);
48824 }
48825
48826 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48827 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
48828 idev->owner = owner;
48829 idev->info = info;
48830 init_waitqueue_head(&idev->wait);
48831 - atomic_set(&idev->event, 0);
48832 + atomic_set_unchecked(&idev->event, 0);
48833
48834 ret = uio_get_minor(idev);
48835 if (ret)
48836 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48837 index 8a7eb77..c00402f 100644
48838 --- a/drivers/usb/atm/cxacru.c
48839 +++ b/drivers/usb/atm/cxacru.c
48840 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48841 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48842 if (ret < 2)
48843 return -EINVAL;
48844 - if (index < 0 || index > 0x7f)
48845 + if (index > 0x7f)
48846 return -EINVAL;
48847 pos += tmp;
48848
48849 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48850 index 5e0d33a..cc10579 100644
48851 --- a/drivers/usb/atm/usbatm.c
48852 +++ b/drivers/usb/atm/usbatm.c
48853 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48854 if (printk_ratelimit())
48855 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48856 __func__, vpi, vci);
48857 - atomic_inc(&vcc->stats->rx_err);
48858 + atomic_inc_unchecked(&vcc->stats->rx_err);
48859 return;
48860 }
48861
48862 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48863 if (length > ATM_MAX_AAL5_PDU) {
48864 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48865 __func__, length, vcc);
48866 - atomic_inc(&vcc->stats->rx_err);
48867 + atomic_inc_unchecked(&vcc->stats->rx_err);
48868 goto out;
48869 }
48870
48871 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48872 if (sarb->len < pdu_length) {
48873 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48874 __func__, pdu_length, sarb->len, vcc);
48875 - atomic_inc(&vcc->stats->rx_err);
48876 + atomic_inc_unchecked(&vcc->stats->rx_err);
48877 goto out;
48878 }
48879
48880 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48881 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48882 __func__, vcc);
48883 - atomic_inc(&vcc->stats->rx_err);
48884 + atomic_inc_unchecked(&vcc->stats->rx_err);
48885 goto out;
48886 }
48887
48888 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48889 if (printk_ratelimit())
48890 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48891 __func__, length);
48892 - atomic_inc(&vcc->stats->rx_drop);
48893 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48894 goto out;
48895 }
48896
48897 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48898
48899 vcc->push(vcc, skb);
48900
48901 - atomic_inc(&vcc->stats->rx);
48902 + atomic_inc_unchecked(&vcc->stats->rx);
48903 out:
48904 skb_trim(sarb, 0);
48905 }
48906 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
48907 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48908
48909 usbatm_pop(vcc, skb);
48910 - atomic_inc(&vcc->stats->tx);
48911 + atomic_inc_unchecked(&vcc->stats->tx);
48912
48913 skb = skb_dequeue(&instance->sndqueue);
48914 }
48915 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48916 if (!left--)
48917 return sprintf(page,
48918 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48919 - atomic_read(&atm_dev->stats.aal5.tx),
48920 - atomic_read(&atm_dev->stats.aal5.tx_err),
48921 - atomic_read(&atm_dev->stats.aal5.rx),
48922 - atomic_read(&atm_dev->stats.aal5.rx_err),
48923 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48924 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48925 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48926 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48927 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48928 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48929
48930 if (!left--) {
48931 if (instance->disconnected)
48932 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48933 index 2a3bbdf..91d72cf 100644
48934 --- a/drivers/usb/core/devices.c
48935 +++ b/drivers/usb/core/devices.c
48936 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48937 * time it gets called.
48938 */
48939 static struct device_connect_event {
48940 - atomic_t count;
48941 + atomic_unchecked_t count;
48942 wait_queue_head_t wait;
48943 } device_event = {
48944 .count = ATOMIC_INIT(1),
48945 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
48946
48947 void usbfs_conn_disc_event(void)
48948 {
48949 - atomic_add(2, &device_event.count);
48950 + atomic_add_unchecked(2, &device_event.count);
48951 wake_up(&device_event.wait);
48952 }
48953
48954 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
48955
48956 poll_wait(file, &device_event.wait, wait);
48957
48958 - event_count = atomic_read(&device_event.count);
48959 + event_count = atomic_read_unchecked(&device_event.count);
48960 if (file->f_version != event_count) {
48961 file->f_version = event_count;
48962 return POLLIN | POLLRDNORM;
48963 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
48964 index 014dc99..4d25fd7 100644
48965 --- a/drivers/usb/core/hcd.c
48966 +++ b/drivers/usb/core/hcd.c
48967 @@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48968 */
48969 usb_get_urb(urb);
48970 atomic_inc(&urb->use_count);
48971 - atomic_inc(&urb->dev->urbnum);
48972 + atomic_inc_unchecked(&urb->dev->urbnum);
48973 usbmon_urb_submit(&hcd->self, urb);
48974
48975 /* NOTE requirements on root-hub callers (usbfs and the hub
48976 @@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48977 urb->hcpriv = NULL;
48978 INIT_LIST_HEAD(&urb->urb_list);
48979 atomic_dec(&urb->use_count);
48980 - atomic_dec(&urb->dev->urbnum);
48981 + atomic_dec_unchecked(&urb->dev->urbnum);
48982 if (atomic_read(&urb->reject))
48983 wake_up(&usb_kill_urb_queue);
48984 usb_put_urb(urb);
48985 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
48986 index 17c3785..deffb11 100644
48987 --- a/drivers/usb/core/hub.c
48988 +++ b/drivers/usb/core/hub.c
48989 @@ -27,6 +27,7 @@
48990 #include <linux/freezer.h>
48991 #include <linux/random.h>
48992 #include <linux/pm_qos.h>
48993 +#include <linux/grsecurity.h>
48994
48995 #include <asm/uaccess.h>
48996 #include <asm/byteorder.h>
48997 @@ -4421,6 +4422,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
48998 goto done;
48999 return;
49000 }
49001 +
49002 + if (gr_handle_new_usb())
49003 + goto done;
49004 +
49005 if (hub_is_superspeed(hub->hdev))
49006 unit_load = 150;
49007 else
49008 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49009 index e7ee1e4..1dfc9ea4 100644
49010 --- a/drivers/usb/core/message.c
49011 +++ b/drivers/usb/core/message.c
49012 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49013 * method can wait for it to complete. Since you don't have a handle on the
49014 * URB used, you can't cancel the request.
49015 */
49016 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49017 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49018 __u8 requesttype, __u16 value, __u16 index, void *data,
49019 __u16 size, int timeout)
49020 {
49021 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49022 index d9284b9..17023c7 100644
49023 --- a/drivers/usb/core/sysfs.c
49024 +++ b/drivers/usb/core/sysfs.c
49025 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49026 struct usb_device *udev;
49027
49028 udev = to_usb_device(dev);
49029 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49030 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49031 }
49032 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49033
49034 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49035 index 7dad603..350f7a9 100644
49036 --- a/drivers/usb/core/usb.c
49037 +++ b/drivers/usb/core/usb.c
49038 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49039 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49040 dev->state = USB_STATE_ATTACHED;
49041 dev->lpm_disable_count = 1;
49042 - atomic_set(&dev->urbnum, 0);
49043 + atomic_set_unchecked(&dev->urbnum, 0);
49044
49045 INIT_LIST_HEAD(&dev->ep0.urb_list);
49046 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49047 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49048 index 14d28d6..5f511ac 100644
49049 --- a/drivers/usb/dwc3/gadget.c
49050 +++ b/drivers/usb/dwc3/gadget.c
49051 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49052 if (!usb_endpoint_xfer_isoc(desc))
49053 return 0;
49054
49055 - memset(&trb_link, 0, sizeof(trb_link));
49056 -
49057 /* Link TRB for ISOC. The HWO bit is never reset */
49058 trb_st_hw = &dep->trb_pool[0];
49059
49060 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49061 index 5e29dde..eca992f 100644
49062 --- a/drivers/usb/early/ehci-dbgp.c
49063 +++ b/drivers/usb/early/ehci-dbgp.c
49064 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49065
49066 #ifdef CONFIG_KGDB
49067 static struct kgdb_io kgdbdbgp_io_ops;
49068 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49069 +static struct kgdb_io kgdbdbgp_io_ops_console;
49070 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49071 #else
49072 #define dbgp_kgdb_mode (0)
49073 #endif
49074 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49075 .write_char = kgdbdbgp_write_char,
49076 };
49077
49078 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49079 + .name = "kgdbdbgp",
49080 + .read_char = kgdbdbgp_read_char,
49081 + .write_char = kgdbdbgp_write_char,
49082 + .is_console = 1
49083 +};
49084 +
49085 static int kgdbdbgp_wait_time;
49086
49087 static int __init kgdbdbgp_parse_config(char *str)
49088 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49089 ptr++;
49090 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49091 }
49092 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49093 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49094 + if (early_dbgp_console.index != -1)
49095 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49096 + else
49097 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49098
49099 return 0;
49100 }
49101 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49102 index b369292..9f3ba40 100644
49103 --- a/drivers/usb/gadget/u_serial.c
49104 +++ b/drivers/usb/gadget/u_serial.c
49105 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49106 spin_lock_irq(&port->port_lock);
49107
49108 /* already open? Great. */
49109 - if (port->port.count) {
49110 + if (atomic_read(&port->port.count)) {
49111 status = 0;
49112 - port->port.count++;
49113 + atomic_inc(&port->port.count);
49114
49115 /* currently opening/closing? wait ... */
49116 } else if (port->openclose) {
49117 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49118 tty->driver_data = port;
49119 port->port.tty = tty;
49120
49121 - port->port.count = 1;
49122 + atomic_set(&port->port.count, 1);
49123 port->openclose = false;
49124
49125 /* if connected, start the I/O stream */
49126 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49127
49128 spin_lock_irq(&port->port_lock);
49129
49130 - if (port->port.count != 1) {
49131 - if (port->port.count == 0)
49132 + if (atomic_read(&port->port.count) != 1) {
49133 + if (atomic_read(&port->port.count) == 0)
49134 WARN_ON(1);
49135 else
49136 - --port->port.count;
49137 + atomic_dec(&port->port.count);
49138 goto exit;
49139 }
49140
49141 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49142 * and sleep if necessary
49143 */
49144 port->openclose = true;
49145 - port->port.count = 0;
49146 + atomic_set(&port->port.count, 0);
49147
49148 gser = port->port_usb;
49149 if (gser && gser->disconnect)
49150 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49151 int cond;
49152
49153 spin_lock_irq(&port->port_lock);
49154 - cond = (port->port.count == 0) && !port->openclose;
49155 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49156 spin_unlock_irq(&port->port_lock);
49157 return cond;
49158 }
49159 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49160 /* if it's already open, start I/O ... and notify the serial
49161 * protocol about open/close status (connect/disconnect).
49162 */
49163 - if (port->port.count) {
49164 + if (atomic_read(&port->port.count)) {
49165 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49166 gs_start_io(port);
49167 if (gser->connect)
49168 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49169
49170 port->port_usb = NULL;
49171 gser->ioport = NULL;
49172 - if (port->port.count > 0 || port->openclose) {
49173 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49174 wake_up_interruptible(&port->drain_wait);
49175 if (port->port.tty)
49176 tty_hangup(port->port.tty);
49177 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49178
49179 /* finally, free any unused/unusable I/O buffers */
49180 spin_lock_irqsave(&port->port_lock, flags);
49181 - if (port->port.count == 0 && !port->openclose)
49182 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49183 gs_buf_free(&port->port_write_buf);
49184 gs_free_requests(gser->out, &port->read_pool, NULL);
49185 gs_free_requests(gser->out, &port->read_queue, NULL);
49186 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49187 index ba6a5d6..f88f7f3 100644
49188 --- a/drivers/usb/misc/appledisplay.c
49189 +++ b/drivers/usb/misc/appledisplay.c
49190 @@ -83,7 +83,7 @@ struct appledisplay {
49191 spinlock_t lock;
49192 };
49193
49194 -static atomic_t count_displays = ATOMIC_INIT(0);
49195 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49196 static struct workqueue_struct *wq;
49197
49198 static void appledisplay_complete(struct urb *urb)
49199 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49200
49201 /* Register backlight device */
49202 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49203 - atomic_inc_return(&count_displays) - 1);
49204 + atomic_inc_return_unchecked(&count_displays) - 1);
49205 memset(&props, 0, sizeof(struct backlight_properties));
49206 props.type = BACKLIGHT_RAW;
49207 props.max_brightness = 0xff;
49208 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49209 index afb50ea..7b0b1cf 100644
49210 --- a/drivers/usb/serial/console.c
49211 +++ b/drivers/usb/serial/console.c
49212 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49213
49214 info->port = port;
49215
49216 - ++port->port.count;
49217 + atomic_inc(&port->port.count);
49218 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49219 if (serial->type->set_termios) {
49220 /*
49221 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49222 }
49223 /* Now that any required fake tty operations are completed restore
49224 * the tty port count */
49225 - --port->port.count;
49226 + atomic_dec(&port->port.count);
49227 /* The console is special in terms of closing the device so
49228 * indicate this port is now acting as a system console. */
49229 port->port.console = 1;
49230 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49231 free_tty:
49232 kfree(tty);
49233 reset_open_count:
49234 - port->port.count = 0;
49235 + atomic_set(&port->port.count, 0);
49236 usb_autopm_put_interface(serial->interface);
49237 error_get_interface:
49238 usb_serial_put(serial);
49239 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49240 index 75f70f0..d467e1a 100644
49241 --- a/drivers/usb/storage/usb.h
49242 +++ b/drivers/usb/storage/usb.h
49243 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49244 __u8 useProtocol;
49245 __u8 useTransport;
49246 int (*initFunction)(struct us_data *);
49247 -};
49248 +} __do_const;
49249
49250
49251 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49252 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49253 index d6bea3e..60b250e 100644
49254 --- a/drivers/usb/wusbcore/wa-hc.h
49255 +++ b/drivers/usb/wusbcore/wa-hc.h
49256 @@ -192,7 +192,7 @@ struct wahc {
49257 struct list_head xfer_delayed_list;
49258 spinlock_t xfer_list_lock;
49259 struct work_struct xfer_work;
49260 - atomic_t xfer_id_count;
49261 + atomic_unchecked_t xfer_id_count;
49262 };
49263
49264
49265 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49266 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49267 spin_lock_init(&wa->xfer_list_lock);
49268 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49269 - atomic_set(&wa->xfer_id_count, 1);
49270 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49271 }
49272
49273 /**
49274 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49275 index d3493ca..0c33b7e 100644
49276 --- a/drivers/usb/wusbcore/wa-xfer.c
49277 +++ b/drivers/usb/wusbcore/wa-xfer.c
49278 @@ -297,7 +297,7 @@ out:
49279 */
49280 static void wa_xfer_id_init(struct wa_xfer *xfer)
49281 {
49282 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49283 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49284 }
49285
49286 /*
49287 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49288 index 842f450..d1d7409 100644
49289 --- a/drivers/vfio/vfio.c
49290 +++ b/drivers/vfio/vfio.c
49291 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49292 return 0;
49293
49294 /* TODO Prevent device auto probing */
49295 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49296 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49297 iommu_group_id(group->iommu_group));
49298
49299 return 0;
49300 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49301 index 5174eba..86e764a 100644
49302 --- a/drivers/vhost/vringh.c
49303 +++ b/drivers/vhost/vringh.c
49304 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49305
49306 static inline int putu16_kern(u16 *p, u16 val)
49307 {
49308 - ACCESS_ONCE(*p) = val;
49309 + ACCESS_ONCE_RW(*p) = val;
49310 return 0;
49311 }
49312
49313 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49314 index a4dfe8c..297ddd9 100644
49315 --- a/drivers/video/aty/aty128fb.c
49316 +++ b/drivers/video/aty/aty128fb.c
49317 @@ -149,7 +149,7 @@ enum {
49318 };
49319
49320 /* Must match above enum */
49321 -static char * const r128_family[] = {
49322 +static const char * const r128_family[] = {
49323 "AGP",
49324 "PCI",
49325 "PRO AGP",
49326 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49327 index 9b0f12c..024673d 100644
49328 --- a/drivers/video/aty/atyfb_base.c
49329 +++ b/drivers/video/aty/atyfb_base.c
49330 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49331 par->accel_flags = var->accel_flags; /* hack */
49332
49333 if (var->accel_flags) {
49334 - info->fbops->fb_sync = atyfb_sync;
49335 + pax_open_kernel();
49336 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49337 + pax_close_kernel();
49338 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49339 } else {
49340 - info->fbops->fb_sync = NULL;
49341 + pax_open_kernel();
49342 + *(void **)&info->fbops->fb_sync = NULL;
49343 + pax_close_kernel();
49344 info->flags |= FBINFO_HWACCEL_DISABLED;
49345 }
49346
49347 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49348 index 95ec042..e6affdd 100644
49349 --- a/drivers/video/aty/mach64_cursor.c
49350 +++ b/drivers/video/aty/mach64_cursor.c
49351 @@ -7,6 +7,7 @@
49352 #include <linux/string.h>
49353
49354 #include <asm/io.h>
49355 +#include <asm/pgtable.h>
49356
49357 #ifdef __sparc__
49358 #include <asm/fbio.h>
49359 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49360 info->sprite.buf_align = 16; /* and 64 lines tall. */
49361 info->sprite.flags = FB_PIXMAP_IO;
49362
49363 - info->fbops->fb_cursor = atyfb_cursor;
49364 + pax_open_kernel();
49365 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49366 + pax_close_kernel();
49367
49368 return 0;
49369 }
49370 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49371 index bca6ccc..252107e 100644
49372 --- a/drivers/video/backlight/kb3886_bl.c
49373 +++ b/drivers/video/backlight/kb3886_bl.c
49374 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49375 static unsigned long kb3886bl_flags;
49376 #define KB3886BL_SUSPENDED 0x01
49377
49378 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49379 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49380 {
49381 .ident = "Sahara Touch-iT",
49382 .matches = {
49383 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49384 index 900aa4e..6d49418 100644
49385 --- a/drivers/video/fb_defio.c
49386 +++ b/drivers/video/fb_defio.c
49387 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49388
49389 BUG_ON(!fbdefio);
49390 mutex_init(&fbdefio->lock);
49391 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49392 + pax_open_kernel();
49393 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49394 + pax_close_kernel();
49395 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49396 INIT_LIST_HEAD(&fbdefio->pagelist);
49397 if (fbdefio->delay == 0) /* set a default of 1 s */
49398 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49399 page->mapping = NULL;
49400 }
49401
49402 - info->fbops->fb_mmap = NULL;
49403 + *(void **)&info->fbops->fb_mmap = NULL;
49404 mutex_destroy(&fbdefio->lock);
49405 }
49406 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49407 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49408 index 5c3960d..15cf8fc 100644
49409 --- a/drivers/video/fbcmap.c
49410 +++ b/drivers/video/fbcmap.c
49411 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49412 rc = -ENODEV;
49413 goto out;
49414 }
49415 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49416 - !info->fbops->fb_setcmap)) {
49417 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49418 rc = -EINVAL;
49419 goto out1;
49420 }
49421 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49422 index 36e1fe2..c744820 100644
49423 --- a/drivers/video/fbmem.c
49424 +++ b/drivers/video/fbmem.c
49425 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49426 image->dx += image->width + 8;
49427 }
49428 } else if (rotate == FB_ROTATE_UD) {
49429 - for (x = 0; x < num && image->dx >= 0; x++) {
49430 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49431 info->fbops->fb_imageblit(info, image);
49432 image->dx -= image->width + 8;
49433 }
49434 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49435 image->dy += image->height + 8;
49436 }
49437 } else if (rotate == FB_ROTATE_CCW) {
49438 - for (x = 0; x < num && image->dy >= 0; x++) {
49439 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49440 info->fbops->fb_imageblit(info, image);
49441 image->dy -= image->height + 8;
49442 }
49443 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49444 return -EFAULT;
49445 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49446 return -EINVAL;
49447 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49448 + if (con2fb.framebuffer >= FB_MAX)
49449 return -EINVAL;
49450 if (!registered_fb[con2fb.framebuffer])
49451 request_module("fb%d", con2fb.framebuffer);
49452 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49453 index d4d2c5f..ebbd113 100644
49454 --- a/drivers/video/hyperv_fb.c
49455 +++ b/drivers/video/hyperv_fb.c
49456 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49457 static inline int synthvid_send(struct hv_device *hdev,
49458 struct synthvid_msg *msg)
49459 {
49460 - static atomic64_t request_id = ATOMIC64_INIT(0);
49461 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49462 int ret;
49463
49464 msg->pipe_hdr.type = PIPE_MSG_DATA;
49465 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49466
49467 ret = vmbus_sendpacket(hdev->channel, msg,
49468 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49469 - atomic64_inc_return(&request_id),
49470 + atomic64_inc_return_unchecked(&request_id),
49471 VM_PKT_DATA_INBAND, 0);
49472
49473 if (ret)
49474 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49475 index 7672d2e..b56437f 100644
49476 --- a/drivers/video/i810/i810_accel.c
49477 +++ b/drivers/video/i810/i810_accel.c
49478 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49479 }
49480 }
49481 printk("ringbuffer lockup!!!\n");
49482 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49483 i810_report_error(mmio);
49484 par->dev_flags |= LOCKUP;
49485 info->pixmap.scan_align = 1;
49486 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49487 index 285d552..eafa544 100644
49488 --- a/drivers/video/logo/logo_linux_clut224.ppm
49489 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49490 @@ -1,883 +1,1123 @@
49491 P3
49492 80 80
49493 255
49494 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49495 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49496 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49497 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49498 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49499 -10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49500 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49501 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49502 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49503 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49504 -
49505 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49506 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49507 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49508 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49509 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49510 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0
49511 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49512 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49513 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49514 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49515 -
49516 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49517 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49518 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0
49519 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49520 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49521 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49522 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49523 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49524 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49525 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49526 -
49527 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49528 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49529 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0
49530 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49531 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49532 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49533 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49534 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49535 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49536 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49537 -
49538 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49539 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49540 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49541 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49542 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49543 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49544 -38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49545 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49546 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49547 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49548 -
49549 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49550 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49551 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49552 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49553 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49554 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49555 -78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49556 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49557 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49558 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49559 -
49560 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49561 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49562 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49563 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49564 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49565 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49566 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49567 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49568 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49569 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49570 -
49571 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49572 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49573 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49574 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49575 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49576 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49577 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49578 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49579 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49580 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49581 -
49582 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49583 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49584 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49585 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49586 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49587 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49588 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0
49589 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49590 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49591 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49592 -
49593 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49594 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49595 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49596 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49597 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49598 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49599 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0
49600 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49601 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49602 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49603 -
49604 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49605 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49606 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49607 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49608 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49609 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49610 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0
49611 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49612 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49613 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49614 -
49615 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49616 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49617 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49618 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49619 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49620 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49621 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0
49622 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49623 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49624 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49625 -
49626 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49627 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49628 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49629 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49630 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49631 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49632 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0
49633 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49634 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49635 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49636 -
49637 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49638 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49639 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49640 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49641 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49642 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49643 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0
49644 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49645 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49646 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49647 -
49648 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49649 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49650 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49651 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49652 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49653 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49654 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0
49655 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49656 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49657 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49658 -
49659 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49660 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49661 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49662 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49663 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49664 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49665 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49666 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49667 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49668 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49669 -
49670 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49671 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49672 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49673 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49674 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49675 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49676 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49677 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49678 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49679 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49680 -
49681 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49682 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49683 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49684 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49685 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49686 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49687 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49688 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49689 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49690 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49691 -
49692 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49693 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49694 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49695 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49696 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49697 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49698 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49699 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49700 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49701 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49702 -
49703 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49704 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49705 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49706 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49707 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49708 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49709 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49710 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49711 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49712 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49713 -
49714 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49715 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49716 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49717 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49718 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49719 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49720 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
49721 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49722 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49723 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49724 -
49725 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49726 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49727 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49728 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49729 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49730 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49731 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
49732 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49733 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49734 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49735 -
49736 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49737 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49738 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49739 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49740 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49741 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49742 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
49743 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49744 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49745 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49746 -
49747 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49748 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49749 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49750 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49751 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49752 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49753 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
49754 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49755 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49756 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49757 -
49758 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49759 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49760 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49761 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49762 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49763 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49764 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49765 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49766 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49767 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49768 -
49769 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49770 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49771 -3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49772 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49773 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49774 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49775 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49776 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49777 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49778 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49779 -
49780 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49781 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0
49782 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49783 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49784 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49785 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49786 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49787 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49788 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49789 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49790 -
49791 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49792 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0
49793 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49794 -0 0 0 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
49795 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49796 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49797 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49798 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49799 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49800 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49801 -
49802 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49803 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0
49804 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49805 -0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49806 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49807 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49808 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49809 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49810 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49811 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49812 -
49813 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
49814 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0
49815 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49816 -0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
49817 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
49818 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
49819 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
49820 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49821 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49822 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49823 -
49824 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
49825 -18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49826 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49827 -0 0 0 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
49828 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
49829 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49830 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
49831 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49832 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49833 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49834 -
49835 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
49836 -52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49837 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49838 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
49839 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
49840 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49841 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49842 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49843 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49844 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49845 -
49846 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
49847 -36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49848 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
49849 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
49850 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
49851 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49852 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49853 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
49854 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49855 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49856 -
49857 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49858 -21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49859 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
49860 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
49861 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
49862 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49863 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49864 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
49865 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49866 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49867 -
49868 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49869 -12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49870 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49871 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
49872 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
49873 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49874 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49875 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
49876 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49877 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49878 -
49879 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49880 -0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0
49881 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49882 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
49883 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49884 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49885 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49886 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
49887 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49888 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49889 -
49890 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49891 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
49892 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
49893 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
49894 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
49895 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
49896 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49897 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
49898 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49899 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49900 -
49901 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49902 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
49903 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
49904 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
49905 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
49906 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
49907 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
49908 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
49909 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49910 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49911 -
49912 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49913 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
49914 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
49915 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
49916 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
49917 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
49918 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
49919 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
49920 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49921 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49922 -
49923 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49924 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
49925 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
49926 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
49927 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
49928 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
49929 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
49930 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
49931 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49932 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49933 -
49934 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49935 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
49936 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
49937 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
49938 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49939 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49940 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
49941 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
49942 -42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49943 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49944 -
49945 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49946 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
49947 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
49948 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
49949 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49950 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49951 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
49952 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
49953 -58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49954 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49955 -
49956 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49957 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
49958 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
49959 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49960 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49961 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49962 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
49963 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
49964 -78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49965 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49966 -
49967 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49968 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33
49969 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
49970 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49971 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
49972 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49973 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
49974 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
49975 -86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49976 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49977 -
49978 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49979 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49980 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
49981 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49982 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
49983 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49984 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
49985 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
49986 -74 74 74 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49987 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49988 -
49989 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49990 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49991 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
49992 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49993 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49994 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49995 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
49996 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
49997 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
49998 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49999 -
50000 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50001 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50002 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50003 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50004 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50005 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50006 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
50007 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50008 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50009 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50010 -
50011 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50012 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50013 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50014 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50015 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50016 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50017 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50018 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50019 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
50020 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50021 -
50022 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50023 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50024 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50025 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50026 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50027 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50028 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
50029 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50030 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50031 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50032 -
50033 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50034 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50035 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50036 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50037 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50038 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50039 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
50040 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50041 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50042 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50043 -
50044 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50045 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50046 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50047 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50048 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50049 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50050 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
50051 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50052 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50053 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50054 -
50055 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50056 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50057 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50058 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50059 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50060 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50061 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
50062 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50063 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50064 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50065 -
50066 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50067 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50068 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50069 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50070 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50071 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50072 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
50073 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50074 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50075 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50076 -
50077 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50078 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50079 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
50080 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50081 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50082 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50083 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50084 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50085 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50086 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50087 -
50088 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50089 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
50090 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50091 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50092 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50093 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50094 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
50095 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50096 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50097 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50098 -
50099 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50100 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50101 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50102 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50103 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50104 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50105 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50106 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50107 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50108 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50109 -
50110 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50111 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50112 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50113 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50114 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50115 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50116 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50117 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50118 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
50119 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50120 -
50121 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50122 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50123 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50124 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50125 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50126 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50127 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50128 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50129 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
50130 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50131 -
50132 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50133 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50134 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50135 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50136 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50137 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50138 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50139 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50140 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
50141 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50142 -
50143 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50144 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50145 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50146 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50147 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50148 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50149 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50150 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50151 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
50152 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50153 -
50154 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50155 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50156 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50157 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
50158 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50159 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50160 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50161 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50162 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
50163 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50164 -
50165 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50166 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
50167 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50168 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50169 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50170 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50171 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50172 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50173 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
50174 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50175 -
50176 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50177 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14
50178 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50179 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50180 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50181 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50182 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50183 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50184 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50185 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50186 -
50187 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50188 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
50189 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50190 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50191 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50192 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50193 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50194 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50195 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50196 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50197 -
50198 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50199 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50200 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50201 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50202 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50203 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50204 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50205 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50206 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50207 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50208 -
50209 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50210 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50211 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50212 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50213 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50214 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50215 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50216 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50217 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50218 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50219 -
50220 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50221 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50222 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50223 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50224 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50225 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50226 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50227 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50228 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50229 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50230 -
50231 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50232 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50233 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50234 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50235 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50236 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50237 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50238 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50239 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50240 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50241 -
50242 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50243 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50244 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50245 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50246 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50247 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50248 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50249 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50250 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50251 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50252 -
50253 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50254 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50255 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50256 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50257 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50258 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50259 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50260 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50261 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50262 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50263 -
50264 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50265 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50266 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50267 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50268 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50269 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50270 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50271 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50272 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50273 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50274 -
50275 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50276 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50277 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50278 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50279 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50280 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50281 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50282 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50283 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50284 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50285 -
50286 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50287 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50288 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50289 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50290 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50291 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50292 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50293 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50294 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50295 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50296 -
50297 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50298 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50299 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50300 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50301 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50302 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50303 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50304 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50305 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50306 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50307 -
50308 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50309 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50310 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50311 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50312 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50313 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50314 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50315 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50316 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50317 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50318 -
50319 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50320 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50321 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50322 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50323 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50324 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50325 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50326 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50327 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50328 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50329 -
50330 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50331 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50332 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50333 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50334 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50335 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50336 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50337 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50338 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50339 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50340 -
50341 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50342 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50343 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50344 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50345 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50346 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50347 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50348 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50349 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50350 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50351 -
50352 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50353 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50354 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50355 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50356 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50357 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50358 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50359 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50360 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50361 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50362 -
50363 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50364 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50365 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50366 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50367 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50368 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50369 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50370 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50371 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50372 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50373 -
50374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50387 +4 4 4 4 4 4
50388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50401 +4 4 4 4 4 4
50402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50415 +4 4 4 4 4 4
50416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50429 +4 4 4 4 4 4
50430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50443 +4 4 4 4 4 4
50444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50457 +4 4 4 4 4 4
50458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50462 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50463 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
50464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50467 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
50468 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50469 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50471 +4 4 4 4 4 4
50472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50476 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50477 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50478 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50481 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
50482 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50483 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50484 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50485 +4 4 4 4 4 4
50486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50490 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50491 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50492 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50495 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
50496 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50497 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50498 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50499 +4 4 4 4 4 4
50500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50503 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50504 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50505 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50506 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
50507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50508 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50509 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50510 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50511 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50512 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50513 +4 4 4 4 4 4
50514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50517 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50518 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50519 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50520 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50521 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50522 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50523 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50524 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50525 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50526 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50527 +4 4 4 4 4 4
50528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
50531 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50532 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50533 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50534 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50535 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50536 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50537 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50538 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50539 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50540 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50541 +4 4 4 4 4 4
50542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50544 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50545 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50546 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50547 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50548 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50549 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50550 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50551 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50552 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50553 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50554 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50555 +4 4 4 4 4 4
50556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50558 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50559 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50560 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50561 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50562 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50563 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50564 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50565 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50566 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50567 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50568 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50569 +4 4 4 4 4 4
50570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50572 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50573 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50574 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50575 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50576 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50577 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50578 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50579 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50580 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50581 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50582 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50583 +4 4 4 4 4 4
50584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50586 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50587 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50588 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50589 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50590 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50591 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50592 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50593 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50594 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50595 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50596 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50597 +4 4 4 4 4 4
50598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50599 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50600 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50601 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50602 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50603 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50604 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50605 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50606 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50607 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50608 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50609 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50610 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50611 +4 4 4 4 4 4
50612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50613 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50614 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50615 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50616 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50617 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50618 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50619 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50620 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50621 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50622 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50623 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50624 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50625 +0 0 0 4 4 4
50626 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50627 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50628 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50629 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50630 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50631 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50632 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50633 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50634 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50635 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50636 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50637 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50638 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50639 +2 0 0 0 0 0
50640 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50641 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50642 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50643 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50644 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50645 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50646 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50647 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50648 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50649 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50650 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50651 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50652 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50653 +37 38 37 0 0 0
50654 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50655 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50656 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50657 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50658 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50659 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50660 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50661 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50662 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50663 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50664 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50665 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50666 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50667 +85 115 134 4 0 0
50668 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50669 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50670 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50671 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50672 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50673 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50674 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50675 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50676 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50677 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50678 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50679 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50680 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50681 +60 73 81 4 0 0
50682 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50683 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50684 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50685 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50686 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50687 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50688 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50689 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50690 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50691 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50692 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50693 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50694 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50695 +16 19 21 4 0 0
50696 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50697 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50698 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50699 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50700 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50701 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50702 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50703 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50704 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50705 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50706 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50707 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50708 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50709 +4 0 0 4 3 3
50710 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50711 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50712 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50714 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50715 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50716 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50717 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50718 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50719 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50720 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50721 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50722 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50723 +3 2 2 4 4 4
50724 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50725 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50726 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50727 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50728 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50729 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50730 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50731 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50732 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50733 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50734 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50735 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50736 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50737 +4 4 4 4 4 4
50738 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50739 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50740 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50741 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50742 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50743 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50744 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50745 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50746 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50747 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50748 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50749 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50750 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50751 +4 4 4 4 4 4
50752 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50753 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50754 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50755 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50756 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50757 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50758 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50759 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50760 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50761 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50762 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50763 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50764 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50765 +5 5 5 5 5 5
50766 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50767 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50768 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50769 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50770 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50771 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50772 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50773 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50774 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50775 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50776 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50777 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50778 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50779 +5 5 5 4 4 4
50780 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50781 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50782 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50783 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50784 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50785 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50786 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50787 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50788 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50789 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50790 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50791 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50793 +4 4 4 4 4 4
50794 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50795 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50796 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50797 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50798 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50799 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50800 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50801 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50802 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50803 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50804 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50805 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50807 +4 4 4 4 4 4
50808 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50809 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50810 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50811 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
50812 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50813 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
50814 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
50815 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
50816 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
50817 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
50818 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
50819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50821 +4 4 4 4 4 4
50822 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
50823 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
50824 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
50825 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
50826 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50827 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50828 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50829 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
50830 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
50831 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
50832 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
50833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50835 +4 4 4 4 4 4
50836 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
50837 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
50838 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
50839 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
50840 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50841 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
50842 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50843 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
50844 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
50845 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
50846 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50849 +4 4 4 4 4 4
50850 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
50851 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
50852 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
50853 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
50854 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50855 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
50856 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
50857 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
50858 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
50859 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
50860 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
50861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50863 +4 4 4 4 4 4
50864 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
50865 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
50866 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
50867 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
50868 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50869 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
50870 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
50871 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
50872 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
50873 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
50874 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
50875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50877 +4 4 4 4 4 4
50878 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
50879 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
50880 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
50881 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50882 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
50883 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
50884 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
50885 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
50886 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
50887 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
50888 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50891 +4 4 4 4 4 4
50892 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
50893 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
50894 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
50895 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50896 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50897 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
50898 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
50899 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
50900 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
50901 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
50902 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50905 +4 4 4 4 4 4
50906 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
50907 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
50908 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
50909 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50910 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50911 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
50912 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
50913 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
50914 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
50915 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
50916 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50919 +4 4 4 4 4 4
50920 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
50921 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
50922 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
50923 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50924 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50925 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
50926 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
50927 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
50928 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
50929 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50930 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50933 +4 4 4 4 4 4
50934 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
50935 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
50936 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
50937 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
50938 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
50939 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
50940 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
50941 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
50942 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
50943 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50944 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50947 +4 4 4 4 4 4
50948 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
50949 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
50950 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
50951 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
50952 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50953 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
50954 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
50955 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
50956 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
50957 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50958 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50961 +4 4 4 4 4 4
50962 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
50963 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
50964 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
50965 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
50966 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
50967 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
50968 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
50969 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
50970 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
50971 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50972 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50975 +4 4 4 4 4 4
50976 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
50977 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
50978 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
50979 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
50980 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
50981 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
50982 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
50983 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
50984 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
50985 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50986 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50989 +4 4 4 4 4 4
50990 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
50991 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
50992 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
50993 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
50994 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
50995 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
50996 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
50997 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
50998 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
50999 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51000 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51003 +4 4 4 4 4 4
51004 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51005 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51006 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51007 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51008 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51009 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51010 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51011 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51012 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51013 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51014 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51017 +4 4 4 4 4 4
51018 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51019 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51020 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51021 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51022 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51023 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51024 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51025 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51026 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51027 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51028 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51031 +4 4 4 4 4 4
51032 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51033 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51034 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51035 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51036 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51037 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51038 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51039 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51040 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51041 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51042 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51045 +4 4 4 4 4 4
51046 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51047 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51048 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51049 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51050 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51051 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51052 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51053 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51054 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51055 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51056 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51058 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51059 +4 4 4 4 4 4
51060 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51061 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51062 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51063 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51064 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51065 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51066 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51067 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51068 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51069 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51070 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51072 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51073 +4 4 4 4 4 4
51074 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51075 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51076 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51077 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51078 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51079 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51080 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51081 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51082 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51083 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51084 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51086 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51087 +4 4 4 4 4 4
51088 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51089 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51090 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51091 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51092 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51093 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51094 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51095 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51096 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51097 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51098 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51101 +4 4 4 4 4 4
51102 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51103 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51104 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51105 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51106 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51107 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51108 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51109 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51110 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51111 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51112 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51115 +4 4 4 4 4 4
51116 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51117 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51118 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51119 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51120 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51121 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51122 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51123 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51124 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51125 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51126 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51127 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51129 +4 4 4 4 4 4
51130 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51131 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51132 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51133 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51134 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51135 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51136 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51137 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51138 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51139 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51140 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51141 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51143 +4 4 4 4 4 4
51144 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51145 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51146 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51147 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51148 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51149 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51150 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51151 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51152 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51153 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51154 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51155 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51157 +4 4 4 4 4 4
51158 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51159 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51160 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51161 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51162 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51163 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51164 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51165 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51166 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51167 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51168 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51169 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51171 +4 4 4 4 4 4
51172 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51173 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51174 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51175 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51176 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51177 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51178 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51179 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51180 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51181 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51182 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51185 +4 4 4 4 4 4
51186 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51187 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51188 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51189 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51190 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51191 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51192 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51193 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51194 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51195 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51196 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51199 +4 4 4 4 4 4
51200 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51201 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51202 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51203 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51204 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51205 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51206 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51207 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51208 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51209 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51213 +4 4 4 4 4 4
51214 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51215 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51216 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51217 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51218 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51219 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51220 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51221 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51222 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51223 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51227 +4 4 4 4 4 4
51228 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51229 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51230 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51231 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51232 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51233 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51234 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51235 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51236 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51237 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51241 +4 4 4 4 4 4
51242 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51243 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51244 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51245 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51246 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51247 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51248 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51249 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51250 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51251 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51255 +4 4 4 4 4 4
51256 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51257 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51258 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51259 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51260 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51261 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51262 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51263 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51264 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51269 +4 4 4 4 4 4
51270 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51271 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51272 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51273 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51274 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51275 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51276 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51277 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51278 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51283 +4 4 4 4 4 4
51284 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51285 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51286 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51287 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51288 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51289 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51290 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51291 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51293 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51297 +4 4 4 4 4 4
51298 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51299 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51300 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51301 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51302 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51303 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51304 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51305 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51307 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51311 +4 4 4 4 4 4
51312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51313 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51314 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51315 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51316 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51317 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51318 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51319 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51325 +4 4 4 4 4 4
51326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51327 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51328 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51329 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51330 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51331 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51332 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51333 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51339 +4 4 4 4 4 4
51340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51341 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51342 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51343 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51344 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51345 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51346 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51347 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51349 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51353 +4 4 4 4 4 4
51354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51355 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51356 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51357 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51358 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51359 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51360 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51361 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51367 +4 4 4 4 4 4
51368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51369 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51371 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51372 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51373 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51374 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51381 +4 4 4 4 4 4
51382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51385 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51386 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51387 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51388 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51395 +4 4 4 4 4 4
51396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51399 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51400 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51401 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51402 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51409 +4 4 4 4 4 4
51410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51413 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51414 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51415 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51416 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51423 +4 4 4 4 4 4
51424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51428 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51429 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51430 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51437 +4 4 4 4 4 4
51438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51442 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51443 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51444 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51451 +4 4 4 4 4 4
51452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51456 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51457 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51458 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51465 +4 4 4 4 4 4
51466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51470 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51471 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51479 +4 4 4 4 4 4
51480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51484 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51485 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51493 +4 4 4 4 4 4
51494 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51495 index fe92eed..106e085 100644
51496 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51497 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51498 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51499 struct mb862xxfb_par *par = info->par;
51500
51501 if (info->var.bits_per_pixel == 32) {
51502 - info->fbops->fb_fillrect = cfb_fillrect;
51503 - info->fbops->fb_copyarea = cfb_copyarea;
51504 - info->fbops->fb_imageblit = cfb_imageblit;
51505 + pax_open_kernel();
51506 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51507 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51508 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51509 + pax_close_kernel();
51510 } else {
51511 outreg(disp, GC_L0EM, 3);
51512 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51513 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51514 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51515 + pax_open_kernel();
51516 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51517 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51518 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51519 + pax_close_kernel();
51520 }
51521 outreg(draw, GDC_REG_DRAW_BASE, 0);
51522 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51523 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51524 index ff22871..b129bed 100644
51525 --- a/drivers/video/nvidia/nvidia.c
51526 +++ b/drivers/video/nvidia/nvidia.c
51527 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51528 info->fix.line_length = (info->var.xres_virtual *
51529 info->var.bits_per_pixel) >> 3;
51530 if (info->var.accel_flags) {
51531 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51532 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51533 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51534 - info->fbops->fb_sync = nvidiafb_sync;
51535 + pax_open_kernel();
51536 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51537 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51538 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51539 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51540 + pax_close_kernel();
51541 info->pixmap.scan_align = 4;
51542 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51543 info->flags |= FBINFO_READS_FAST;
51544 NVResetGraphics(info);
51545 } else {
51546 - info->fbops->fb_imageblit = cfb_imageblit;
51547 - info->fbops->fb_fillrect = cfb_fillrect;
51548 - info->fbops->fb_copyarea = cfb_copyarea;
51549 - info->fbops->fb_sync = NULL;
51550 + pax_open_kernel();
51551 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51552 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51553 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51554 + *(void **)&info->fbops->fb_sync = NULL;
51555 + pax_close_kernel();
51556 info->pixmap.scan_align = 1;
51557 info->flags |= FBINFO_HWACCEL_DISABLED;
51558 info->flags &= ~FBINFO_READS_FAST;
51559 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51560 info->pixmap.size = 8 * 1024;
51561 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51562
51563 - if (!hwcur)
51564 - info->fbops->fb_cursor = NULL;
51565 + if (!hwcur) {
51566 + pax_open_kernel();
51567 + *(void **)&info->fbops->fb_cursor = NULL;
51568 + pax_close_kernel();
51569 + }
51570
51571 info->var.accel_flags = (!noaccel);
51572
51573 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51574 index 05c2dc3..ea1f391 100644
51575 --- a/drivers/video/s1d13xxxfb.c
51576 +++ b/drivers/video/s1d13xxxfb.c
51577 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51578
51579 switch(prod_id) {
51580 case S1D13506_PROD_ID: /* activate acceleration */
51581 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51582 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51583 + pax_open_kernel();
51584 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51585 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51586 + pax_close_kernel();
51587 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51588 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51589 break;
51590 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51591 index e188ada..aac63c8 100644
51592 --- a/drivers/video/smscufx.c
51593 +++ b/drivers/video/smscufx.c
51594 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51595 fb_deferred_io_cleanup(info);
51596 kfree(info->fbdefio);
51597 info->fbdefio = NULL;
51598 - info->fbops->fb_mmap = ufx_ops_mmap;
51599 + pax_open_kernel();
51600 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51601 + pax_close_kernel();
51602 }
51603
51604 pr_debug("released /dev/fb%d user=%d count=%d",
51605 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51606 index d2e5bc3..4cb05d1 100644
51607 --- a/drivers/video/udlfb.c
51608 +++ b/drivers/video/udlfb.c
51609 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51610 dlfb_urb_completion(urb);
51611
51612 error:
51613 - atomic_add(bytes_sent, &dev->bytes_sent);
51614 - atomic_add(bytes_identical, &dev->bytes_identical);
51615 - atomic_add(width*height*2, &dev->bytes_rendered);
51616 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51617 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51618 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51619 end_cycles = get_cycles();
51620 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51621 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51622 >> 10)), /* Kcycles */
51623 &dev->cpu_kcycles_used);
51624
51625 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51626 dlfb_urb_completion(urb);
51627
51628 error:
51629 - atomic_add(bytes_sent, &dev->bytes_sent);
51630 - atomic_add(bytes_identical, &dev->bytes_identical);
51631 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51632 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51633 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51634 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51635 end_cycles = get_cycles();
51636 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51637 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51638 >> 10)), /* Kcycles */
51639 &dev->cpu_kcycles_used);
51640 }
51641 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51642 fb_deferred_io_cleanup(info);
51643 kfree(info->fbdefio);
51644 info->fbdefio = NULL;
51645 - info->fbops->fb_mmap = dlfb_ops_mmap;
51646 + pax_open_kernel();
51647 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51648 + pax_close_kernel();
51649 }
51650
51651 pr_warn("released /dev/fb%d user=%d count=%d\n",
51652 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51653 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51654 struct dlfb_data *dev = fb_info->par;
51655 return snprintf(buf, PAGE_SIZE, "%u\n",
51656 - atomic_read(&dev->bytes_rendered));
51657 + atomic_read_unchecked(&dev->bytes_rendered));
51658 }
51659
51660 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51661 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51662 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51663 struct dlfb_data *dev = fb_info->par;
51664 return snprintf(buf, PAGE_SIZE, "%u\n",
51665 - atomic_read(&dev->bytes_identical));
51666 + atomic_read_unchecked(&dev->bytes_identical));
51667 }
51668
51669 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51670 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51671 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51672 struct dlfb_data *dev = fb_info->par;
51673 return snprintf(buf, PAGE_SIZE, "%u\n",
51674 - atomic_read(&dev->bytes_sent));
51675 + atomic_read_unchecked(&dev->bytes_sent));
51676 }
51677
51678 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51679 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51680 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51681 struct dlfb_data *dev = fb_info->par;
51682 return snprintf(buf, PAGE_SIZE, "%u\n",
51683 - atomic_read(&dev->cpu_kcycles_used));
51684 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51685 }
51686
51687 static ssize_t edid_show(
51688 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51689 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51690 struct dlfb_data *dev = fb_info->par;
51691
51692 - atomic_set(&dev->bytes_rendered, 0);
51693 - atomic_set(&dev->bytes_identical, 0);
51694 - atomic_set(&dev->bytes_sent, 0);
51695 - atomic_set(&dev->cpu_kcycles_used, 0);
51696 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51697 + atomic_set_unchecked(&dev->bytes_identical, 0);
51698 + atomic_set_unchecked(&dev->bytes_sent, 0);
51699 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51700
51701 return count;
51702 }
51703 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51704 index 7aec6f3..e3b2d55 100644
51705 --- a/drivers/video/uvesafb.c
51706 +++ b/drivers/video/uvesafb.c
51707 @@ -19,6 +19,7 @@
51708 #include <linux/io.h>
51709 #include <linux/mutex.h>
51710 #include <linux/slab.h>
51711 +#include <linux/moduleloader.h>
51712 #include <video/edid.h>
51713 #include <video/uvesafb.h>
51714 #ifdef CONFIG_X86
51715 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51716 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51717 par->pmi_setpal = par->ypan = 0;
51718 } else {
51719 +
51720 +#ifdef CONFIG_PAX_KERNEXEC
51721 +#ifdef CONFIG_MODULES
51722 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51723 +#endif
51724 + if (!par->pmi_code) {
51725 + par->pmi_setpal = par->ypan = 0;
51726 + return 0;
51727 + }
51728 +#endif
51729 +
51730 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51731 + task->t.regs.edi);
51732 +
51733 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51734 + pax_open_kernel();
51735 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51736 + pax_close_kernel();
51737 +
51738 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51739 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51740 +#else
51741 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51742 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51743 +#endif
51744 +
51745 printk(KERN_INFO "uvesafb: protected mode interface info at "
51746 "%04x:%04x\n",
51747 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51748 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51749 par->ypan = ypan;
51750
51751 if (par->pmi_setpal || par->ypan) {
51752 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51753 if (__supported_pte_mask & _PAGE_NX) {
51754 par->pmi_setpal = par->ypan = 0;
51755 printk(KERN_WARNING "uvesafb: NX protection is active, "
51756 "better not use the PMI.\n");
51757 - } else {
51758 + } else
51759 +#endif
51760 uvesafb_vbe_getpmi(task, par);
51761 - }
51762 }
51763 #else
51764 /* The protected mode interface is not available on non-x86. */
51765 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51766 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51767
51768 /* Disable blanking if the user requested so. */
51769 - if (!blank)
51770 - info->fbops->fb_blank = NULL;
51771 + if (!blank) {
51772 + pax_open_kernel();
51773 + *(void **)&info->fbops->fb_blank = NULL;
51774 + pax_close_kernel();
51775 + }
51776
51777 /*
51778 * Find out how much IO memory is required for the mode with
51779 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51780 info->flags = FBINFO_FLAG_DEFAULT |
51781 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51782
51783 - if (!par->ypan)
51784 - info->fbops->fb_pan_display = NULL;
51785 + if (!par->ypan) {
51786 + pax_open_kernel();
51787 + *(void **)&info->fbops->fb_pan_display = NULL;
51788 + pax_close_kernel();
51789 + }
51790 }
51791
51792 static void uvesafb_init_mtrr(struct fb_info *info)
51793 @@ -1796,6 +1826,11 @@ out:
51794 if (par->vbe_modes)
51795 kfree(par->vbe_modes);
51796
51797 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51798 + if (par->pmi_code)
51799 + module_free_exec(NULL, par->pmi_code);
51800 +#endif
51801 +
51802 framebuffer_release(info);
51803 return err;
51804 }
51805 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51806 kfree(par->vbe_state_orig);
51807 if (par->vbe_state_saved)
51808 kfree(par->vbe_state_saved);
51809 +
51810 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51811 + if (par->pmi_code)
51812 + module_free_exec(NULL, par->pmi_code);
51813 +#endif
51814 +
51815 }
51816
51817 framebuffer_release(info);
51818 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
51819 index 501b340..d80aa17 100644
51820 --- a/drivers/video/vesafb.c
51821 +++ b/drivers/video/vesafb.c
51822 @@ -9,6 +9,7 @@
51823 */
51824
51825 #include <linux/module.h>
51826 +#include <linux/moduleloader.h>
51827 #include <linux/kernel.h>
51828 #include <linux/errno.h>
51829 #include <linux/string.h>
51830 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
51831 static int vram_total __initdata; /* Set total amount of memory */
51832 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
51833 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
51834 -static void (*pmi_start)(void) __read_mostly;
51835 -static void (*pmi_pal) (void) __read_mostly;
51836 +static void (*pmi_start)(void) __read_only;
51837 +static void (*pmi_pal) (void) __read_only;
51838 static int depth __read_mostly;
51839 static int vga_compat __read_mostly;
51840 /* --------------------------------------------------------------------- */
51841 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
51842 unsigned int size_vmode;
51843 unsigned int size_remap;
51844 unsigned int size_total;
51845 + void *pmi_code = NULL;
51846
51847 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
51848 return -ENODEV;
51849 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
51850 size_remap = size_total;
51851 vesafb_fix.smem_len = size_remap;
51852
51853 -#ifndef __i386__
51854 - screen_info.vesapm_seg = 0;
51855 -#endif
51856 -
51857 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
51858 printk(KERN_WARNING
51859 "vesafb: cannot reserve video memory at 0x%lx\n",
51860 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
51861 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
51862 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
51863
51864 +#ifdef __i386__
51865 +
51866 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51867 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
51868 + if (!pmi_code)
51869 +#elif !defined(CONFIG_PAX_KERNEXEC)
51870 + if (0)
51871 +#endif
51872 +
51873 +#endif
51874 + screen_info.vesapm_seg = 0;
51875 +
51876 if (screen_info.vesapm_seg) {
51877 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
51878 - screen_info.vesapm_seg,screen_info.vesapm_off);
51879 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
51880 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
51881 }
51882
51883 if (screen_info.vesapm_seg < 0xc000)
51884 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
51885
51886 if (ypan || pmi_setpal) {
51887 unsigned short *pmi_base;
51888 +
51889 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
51890 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
51891 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
51892 +
51893 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51894 + pax_open_kernel();
51895 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
51896 +#else
51897 + pmi_code = pmi_base;
51898 +#endif
51899 +
51900 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
51901 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
51902 +
51903 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51904 + pmi_start = ktva_ktla(pmi_start);
51905 + pmi_pal = ktva_ktla(pmi_pal);
51906 + pax_close_kernel();
51907 +#endif
51908 +
51909 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
51910 if (pmi_base[3]) {
51911 printk(KERN_INFO "vesafb: pmi: ports = ");
51912 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
51913 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
51914 (ypan ? FBINFO_HWACCEL_YPAN : 0);
51915
51916 - if (!ypan)
51917 - info->fbops->fb_pan_display = NULL;
51918 + if (!ypan) {
51919 + pax_open_kernel();
51920 + *(void **)&info->fbops->fb_pan_display = NULL;
51921 + pax_close_kernel();
51922 + }
51923
51924 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
51925 err = -ENOMEM;
51926 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
51927 info->node, info->fix.id);
51928 return 0;
51929 err:
51930 +
51931 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51932 + module_free_exec(NULL, pmi_code);
51933 +#endif
51934 +
51935 if (info->screen_base)
51936 iounmap(info->screen_base);
51937 framebuffer_release(info);
51938 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
51939 index 88714ae..16c2e11 100644
51940 --- a/drivers/video/via/via_clock.h
51941 +++ b/drivers/video/via/via_clock.h
51942 @@ -56,7 +56,7 @@ struct via_clock {
51943
51944 void (*set_engine_pll_state)(u8 state);
51945 void (*set_engine_pll)(struct via_pll_config config);
51946 -};
51947 +} __no_const;
51948
51949
51950 static inline u32 get_pll_internal_frequency(u32 ref_freq,
51951 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
51952 index fef20db..d28b1ab 100644
51953 --- a/drivers/xen/xenfs/xenstored.c
51954 +++ b/drivers/xen/xenfs/xenstored.c
51955 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
51956 static int xsd_kva_open(struct inode *inode, struct file *file)
51957 {
51958 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
51959 +#ifdef CONFIG_GRKERNSEC_HIDESYM
51960 + NULL);
51961 +#else
51962 xen_store_interface);
51963 +#endif
51964 +
51965 if (!file->private_data)
51966 return -ENOMEM;
51967 return 0;
51968 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
51969 index 9ff073f..05cef23 100644
51970 --- a/fs/9p/vfs_addr.c
51971 +++ b/fs/9p/vfs_addr.c
51972 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
51973
51974 retval = v9fs_file_write_internal(inode,
51975 v9inode->writeback_fid,
51976 - (__force const char __user *)buffer,
51977 + (const char __force_user *)buffer,
51978 len, &offset, 0);
51979 if (retval > 0)
51980 retval = 0;
51981 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
51982 index 25b018e..b941525 100644
51983 --- a/fs/9p/vfs_inode.c
51984 +++ b/fs/9p/vfs_inode.c
51985 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
51986 void
51987 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
51988 {
51989 - char *s = nd_get_link(nd);
51990 + const char *s = nd_get_link(nd);
51991
51992 p9_debug(P9_DEBUG_VFS, " %s %s\n",
51993 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
51994 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
51995 index 370b24c..ff0be7b 100644
51996 --- a/fs/Kconfig.binfmt
51997 +++ b/fs/Kconfig.binfmt
51998 @@ -103,7 +103,7 @@ config HAVE_AOUT
51999
52000 config BINFMT_AOUT
52001 tristate "Kernel support for a.out and ECOFF binaries"
52002 - depends on HAVE_AOUT
52003 + depends on HAVE_AOUT && BROKEN
52004 ---help---
52005 A.out (Assembler.OUTput) is a set of formats for libraries and
52006 executables used in the earliest versions of UNIX. Linux used
52007 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52008 index 789bc25..fafaeea 100644
52009 --- a/fs/afs/inode.c
52010 +++ b/fs/afs/inode.c
52011 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52012 struct afs_vnode *vnode;
52013 struct super_block *sb;
52014 struct inode *inode;
52015 - static atomic_t afs_autocell_ino;
52016 + static atomic_unchecked_t afs_autocell_ino;
52017
52018 _enter("{%x:%u},%*.*s,",
52019 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52020 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52021 data.fid.unique = 0;
52022 data.fid.vnode = 0;
52023
52024 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52025 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52026 afs_iget5_autocell_test, afs_iget5_set,
52027 &data);
52028 if (!inode) {
52029 diff --git a/fs/aio.c b/fs/aio.c
52030 index 9b5ca11..c530886 100644
52031 --- a/fs/aio.c
52032 +++ b/fs/aio.c
52033 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52034 size += sizeof(struct io_event) * nr_events;
52035 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52036
52037 - if (nr_pages < 0)
52038 + if (nr_pages <= 0)
52039 return -EINVAL;
52040
52041 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52042 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52043 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52044 {
52045 ssize_t ret;
52046 + struct iovec iovstack;
52047
52048 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52049
52050 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52051 if (compat)
52052 ret = compat_rw_copy_check_uvector(rw,
52053 (struct compat_iovec __user *)kiocb->ki_buf,
52054 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52055 + kiocb->ki_nr_segs, 1, &iovstack,
52056 &kiocb->ki_iovec);
52057 else
52058 #endif
52059 ret = rw_copy_check_uvector(rw,
52060 (struct iovec __user *)kiocb->ki_buf,
52061 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52062 + kiocb->ki_nr_segs, 1, &iovstack,
52063 &kiocb->ki_iovec);
52064 if (ret < 0)
52065 return ret;
52066
52067 + if (kiocb->ki_iovec == &iovstack) {
52068 + kiocb->ki_inline_vec = iovstack;
52069 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52070 + }
52071 +
52072 /* ki_nbytes now reflect bytes instead of segs */
52073 kiocb->ki_nbytes = ret;
52074 return 0;
52075 diff --git a/fs/attr.c b/fs/attr.c
52076 index 1449adb..a2038c2 100644
52077 --- a/fs/attr.c
52078 +++ b/fs/attr.c
52079 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52080 unsigned long limit;
52081
52082 limit = rlimit(RLIMIT_FSIZE);
52083 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52084 if (limit != RLIM_INFINITY && offset > limit)
52085 goto out_sig;
52086 if (offset > inode->i_sb->s_maxbytes)
52087 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52088 index 3db70da..7aeec5b 100644
52089 --- a/fs/autofs4/waitq.c
52090 +++ b/fs/autofs4/waitq.c
52091 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52092 {
52093 unsigned long sigpipe, flags;
52094 mm_segment_t fs;
52095 - const char *data = (const char *)addr;
52096 + const char __user *data = (const char __force_user *)addr;
52097 ssize_t wr = 0;
52098
52099 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52100 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52101 return 1;
52102 }
52103
52104 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52105 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52106 +#endif
52107 +
52108 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52109 enum autofs_notify notify)
52110 {
52111 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52112
52113 /* If this is a direct mount request create a dummy name */
52114 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52115 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52116 + /* this name does get written to userland via autofs4_write() */
52117 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52118 +#else
52119 qstr.len = sprintf(name, "%p", dentry);
52120 +#endif
52121 else {
52122 qstr.len = autofs4_getpath(sbi, dentry, &name);
52123 if (!qstr.len) {
52124 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52125 index 2722387..c8dd2a7 100644
52126 --- a/fs/befs/endian.h
52127 +++ b/fs/befs/endian.h
52128 @@ -11,7 +11,7 @@
52129
52130 #include <asm/byteorder.h>
52131
52132 -static inline u64
52133 +static inline u64 __intentional_overflow(-1)
52134 fs64_to_cpu(const struct super_block *sb, fs64 n)
52135 {
52136 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52137 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52138 return (__force fs64)cpu_to_be64(n);
52139 }
52140
52141 -static inline u32
52142 +static inline u32 __intentional_overflow(-1)
52143 fs32_to_cpu(const struct super_block *sb, fs32 n)
52144 {
52145 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52146 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52147 index e9c75e2..1baece1 100644
52148 --- a/fs/befs/linuxvfs.c
52149 +++ b/fs/befs/linuxvfs.c
52150 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52151 {
52152 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52153 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52154 - char *link = nd_get_link(nd);
52155 + const char *link = nd_get_link(nd);
52156 if (!IS_ERR(link))
52157 kfree(link);
52158 }
52159 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52160 index 89dec7f..361b0d75 100644
52161 --- a/fs/binfmt_aout.c
52162 +++ b/fs/binfmt_aout.c
52163 @@ -16,6 +16,7 @@
52164 #include <linux/string.h>
52165 #include <linux/fs.h>
52166 #include <linux/file.h>
52167 +#include <linux/security.h>
52168 #include <linux/stat.h>
52169 #include <linux/fcntl.h>
52170 #include <linux/ptrace.h>
52171 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52172 #endif
52173 # define START_STACK(u) ((void __user *)u.start_stack)
52174
52175 + memset(&dump, 0, sizeof(dump));
52176 +
52177 fs = get_fs();
52178 set_fs(KERNEL_DS);
52179 has_dumped = 1;
52180 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52181
52182 /* If the size of the dump file exceeds the rlimit, then see what would happen
52183 if we wrote the stack, but not the data area. */
52184 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52185 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52186 dump.u_dsize = 0;
52187
52188 /* Make sure we have enough room to write the stack and data areas. */
52189 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52190 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52191 dump.u_ssize = 0;
52192
52193 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52194 rlim = rlimit(RLIMIT_DATA);
52195 if (rlim >= RLIM_INFINITY)
52196 rlim = ~0;
52197 +
52198 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52199 if (ex.a_data + ex.a_bss > rlim)
52200 return -ENOMEM;
52201
52202 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52203
52204 install_exec_creds(bprm);
52205
52206 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52207 + current->mm->pax_flags = 0UL;
52208 +#endif
52209 +
52210 +#ifdef CONFIG_PAX_PAGEEXEC
52211 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52212 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52213 +
52214 +#ifdef CONFIG_PAX_EMUTRAMP
52215 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52216 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52217 +#endif
52218 +
52219 +#ifdef CONFIG_PAX_MPROTECT
52220 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52221 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52222 +#endif
52223 +
52224 + }
52225 +#endif
52226 +
52227 if (N_MAGIC(ex) == OMAGIC) {
52228 unsigned long text_addr, map_size;
52229 loff_t pos;
52230 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52231 }
52232
52233 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52234 - PROT_READ | PROT_WRITE | PROT_EXEC,
52235 + PROT_READ | PROT_WRITE,
52236 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52237 fd_offset + ex.a_text);
52238 if (error != N_DATADDR(ex)) {
52239 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52240 index 4c94a79..f428019 100644
52241 --- a/fs/binfmt_elf.c
52242 +++ b/fs/binfmt_elf.c
52243 @@ -34,6 +34,7 @@
52244 #include <linux/utsname.h>
52245 #include <linux/coredump.h>
52246 #include <linux/sched.h>
52247 +#include <linux/xattr.h>
52248 #include <asm/uaccess.h>
52249 #include <asm/param.h>
52250 #include <asm/page.h>
52251 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52252 #define elf_core_dump NULL
52253 #endif
52254
52255 +#ifdef CONFIG_PAX_MPROTECT
52256 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52257 +#endif
52258 +
52259 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52260 +static void elf_handle_mmap(struct file *file);
52261 +#endif
52262 +
52263 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52264 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52265 #else
52266 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52267 .load_binary = load_elf_binary,
52268 .load_shlib = load_elf_library,
52269 .core_dump = elf_core_dump,
52270 +
52271 +#ifdef CONFIG_PAX_MPROTECT
52272 + .handle_mprotect= elf_handle_mprotect,
52273 +#endif
52274 +
52275 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52276 + .handle_mmap = elf_handle_mmap,
52277 +#endif
52278 +
52279 .min_coredump = ELF_EXEC_PAGESIZE,
52280 };
52281
52282 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52283
52284 static int set_brk(unsigned long start, unsigned long end)
52285 {
52286 + unsigned long e = end;
52287 +
52288 start = ELF_PAGEALIGN(start);
52289 end = ELF_PAGEALIGN(end);
52290 if (end > start) {
52291 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52292 if (BAD_ADDR(addr))
52293 return addr;
52294 }
52295 - current->mm->start_brk = current->mm->brk = end;
52296 + current->mm->start_brk = current->mm->brk = e;
52297 return 0;
52298 }
52299
52300 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52301 elf_addr_t __user *u_rand_bytes;
52302 const char *k_platform = ELF_PLATFORM;
52303 const char *k_base_platform = ELF_BASE_PLATFORM;
52304 - unsigned char k_rand_bytes[16];
52305 + u32 k_rand_bytes[4];
52306 int items;
52307 elf_addr_t *elf_info;
52308 int ei_index = 0;
52309 const struct cred *cred = current_cred();
52310 struct vm_area_struct *vma;
52311 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52312
52313 /*
52314 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52315 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52316 * Generate 16 random bytes for userspace PRNG seeding.
52317 */
52318 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52319 - u_rand_bytes = (elf_addr_t __user *)
52320 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52321 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52322 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52323 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52324 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52325 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52326 + u_rand_bytes = (elf_addr_t __user *) p;
52327 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52328 return -EFAULT;
52329
52330 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52331 return -EFAULT;
52332 current->mm->env_end = p;
52333
52334 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52335 +
52336 /* Put the elf_info on the stack in the right place. */
52337 sp = (elf_addr_t __user *)envp + 1;
52338 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52339 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52340 return -EFAULT;
52341 return 0;
52342 }
52343 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52344 an ELF header */
52345
52346 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52347 - struct file *interpreter, unsigned long *interp_map_addr,
52348 - unsigned long no_base)
52349 + struct file *interpreter, unsigned long no_base)
52350 {
52351 struct elf_phdr *elf_phdata;
52352 struct elf_phdr *eppnt;
52353 - unsigned long load_addr = 0;
52354 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52355 int load_addr_set = 0;
52356 unsigned long last_bss = 0, elf_bss = 0;
52357 - unsigned long error = ~0UL;
52358 + unsigned long error = -EINVAL;
52359 unsigned long total_size;
52360 int retval, i, size;
52361
52362 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52363 goto out_close;
52364 }
52365
52366 +#ifdef CONFIG_PAX_SEGMEXEC
52367 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52368 + pax_task_size = SEGMEXEC_TASK_SIZE;
52369 +#endif
52370 +
52371 eppnt = elf_phdata;
52372 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52373 if (eppnt->p_type == PT_LOAD) {
52374 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52375 map_addr = elf_map(interpreter, load_addr + vaddr,
52376 eppnt, elf_prot, elf_type, total_size);
52377 total_size = 0;
52378 - if (!*interp_map_addr)
52379 - *interp_map_addr = map_addr;
52380 error = map_addr;
52381 if (BAD_ADDR(map_addr))
52382 goto out_close;
52383 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52384 k = load_addr + eppnt->p_vaddr;
52385 if (BAD_ADDR(k) ||
52386 eppnt->p_filesz > eppnt->p_memsz ||
52387 - eppnt->p_memsz > TASK_SIZE ||
52388 - TASK_SIZE - eppnt->p_memsz < k) {
52389 + eppnt->p_memsz > pax_task_size ||
52390 + pax_task_size - eppnt->p_memsz < k) {
52391 error = -ENOMEM;
52392 goto out_close;
52393 }
52394 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52395 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52396
52397 /* Map the last of the bss segment */
52398 - error = vm_brk(elf_bss, last_bss - elf_bss);
52399 - if (BAD_ADDR(error))
52400 - goto out_close;
52401 + if (last_bss > elf_bss) {
52402 + error = vm_brk(elf_bss, last_bss - elf_bss);
52403 + if (BAD_ADDR(error))
52404 + goto out_close;
52405 + }
52406 }
52407
52408 error = load_addr;
52409 @@ -538,6 +569,315 @@ out:
52410 return error;
52411 }
52412
52413 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52414 +#ifdef CONFIG_PAX_SOFTMODE
52415 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52416 +{
52417 + unsigned long pax_flags = 0UL;
52418 +
52419 +#ifdef CONFIG_PAX_PAGEEXEC
52420 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52421 + pax_flags |= MF_PAX_PAGEEXEC;
52422 +#endif
52423 +
52424 +#ifdef CONFIG_PAX_SEGMEXEC
52425 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52426 + pax_flags |= MF_PAX_SEGMEXEC;
52427 +#endif
52428 +
52429 +#ifdef CONFIG_PAX_EMUTRAMP
52430 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52431 + pax_flags |= MF_PAX_EMUTRAMP;
52432 +#endif
52433 +
52434 +#ifdef CONFIG_PAX_MPROTECT
52435 + if (elf_phdata->p_flags & PF_MPROTECT)
52436 + pax_flags |= MF_PAX_MPROTECT;
52437 +#endif
52438 +
52439 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52440 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52441 + pax_flags |= MF_PAX_RANDMMAP;
52442 +#endif
52443 +
52444 + return pax_flags;
52445 +}
52446 +#endif
52447 +
52448 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52449 +{
52450 + unsigned long pax_flags = 0UL;
52451 +
52452 +#ifdef CONFIG_PAX_PAGEEXEC
52453 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52454 + pax_flags |= MF_PAX_PAGEEXEC;
52455 +#endif
52456 +
52457 +#ifdef CONFIG_PAX_SEGMEXEC
52458 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52459 + pax_flags |= MF_PAX_SEGMEXEC;
52460 +#endif
52461 +
52462 +#ifdef CONFIG_PAX_EMUTRAMP
52463 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52464 + pax_flags |= MF_PAX_EMUTRAMP;
52465 +#endif
52466 +
52467 +#ifdef CONFIG_PAX_MPROTECT
52468 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52469 + pax_flags |= MF_PAX_MPROTECT;
52470 +#endif
52471 +
52472 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52473 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52474 + pax_flags |= MF_PAX_RANDMMAP;
52475 +#endif
52476 +
52477 + return pax_flags;
52478 +}
52479 +#endif
52480 +
52481 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52482 +#ifdef CONFIG_PAX_SOFTMODE
52483 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52484 +{
52485 + unsigned long pax_flags = 0UL;
52486 +
52487 +#ifdef CONFIG_PAX_PAGEEXEC
52488 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52489 + pax_flags |= MF_PAX_PAGEEXEC;
52490 +#endif
52491 +
52492 +#ifdef CONFIG_PAX_SEGMEXEC
52493 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52494 + pax_flags |= MF_PAX_SEGMEXEC;
52495 +#endif
52496 +
52497 +#ifdef CONFIG_PAX_EMUTRAMP
52498 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52499 + pax_flags |= MF_PAX_EMUTRAMP;
52500 +#endif
52501 +
52502 +#ifdef CONFIG_PAX_MPROTECT
52503 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52504 + pax_flags |= MF_PAX_MPROTECT;
52505 +#endif
52506 +
52507 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52508 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52509 + pax_flags |= MF_PAX_RANDMMAP;
52510 +#endif
52511 +
52512 + return pax_flags;
52513 +}
52514 +#endif
52515 +
52516 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52517 +{
52518 + unsigned long pax_flags = 0UL;
52519 +
52520 +#ifdef CONFIG_PAX_PAGEEXEC
52521 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52522 + pax_flags |= MF_PAX_PAGEEXEC;
52523 +#endif
52524 +
52525 +#ifdef CONFIG_PAX_SEGMEXEC
52526 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52527 + pax_flags |= MF_PAX_SEGMEXEC;
52528 +#endif
52529 +
52530 +#ifdef CONFIG_PAX_EMUTRAMP
52531 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52532 + pax_flags |= MF_PAX_EMUTRAMP;
52533 +#endif
52534 +
52535 +#ifdef CONFIG_PAX_MPROTECT
52536 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52537 + pax_flags |= MF_PAX_MPROTECT;
52538 +#endif
52539 +
52540 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52541 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52542 + pax_flags |= MF_PAX_RANDMMAP;
52543 +#endif
52544 +
52545 + return pax_flags;
52546 +}
52547 +#endif
52548 +
52549 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52550 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52551 +{
52552 + unsigned long pax_flags = 0UL;
52553 +
52554 +#ifdef CONFIG_PAX_EI_PAX
52555 +
52556 +#ifdef CONFIG_PAX_PAGEEXEC
52557 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52558 + pax_flags |= MF_PAX_PAGEEXEC;
52559 +#endif
52560 +
52561 +#ifdef CONFIG_PAX_SEGMEXEC
52562 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52563 + pax_flags |= MF_PAX_SEGMEXEC;
52564 +#endif
52565 +
52566 +#ifdef CONFIG_PAX_EMUTRAMP
52567 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52568 + pax_flags |= MF_PAX_EMUTRAMP;
52569 +#endif
52570 +
52571 +#ifdef CONFIG_PAX_MPROTECT
52572 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52573 + pax_flags |= MF_PAX_MPROTECT;
52574 +#endif
52575 +
52576 +#ifdef CONFIG_PAX_ASLR
52577 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52578 + pax_flags |= MF_PAX_RANDMMAP;
52579 +#endif
52580 +
52581 +#else
52582 +
52583 +#ifdef CONFIG_PAX_PAGEEXEC
52584 + pax_flags |= MF_PAX_PAGEEXEC;
52585 +#endif
52586 +
52587 +#ifdef CONFIG_PAX_SEGMEXEC
52588 + pax_flags |= MF_PAX_SEGMEXEC;
52589 +#endif
52590 +
52591 +#ifdef CONFIG_PAX_MPROTECT
52592 + pax_flags |= MF_PAX_MPROTECT;
52593 +#endif
52594 +
52595 +#ifdef CONFIG_PAX_RANDMMAP
52596 + if (randomize_va_space)
52597 + pax_flags |= MF_PAX_RANDMMAP;
52598 +#endif
52599 +
52600 +#endif
52601 +
52602 + return pax_flags;
52603 +}
52604 +
52605 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52606 +{
52607 +
52608 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52609 + unsigned long i;
52610 +
52611 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52612 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52613 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52614 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52615 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52616 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52617 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52618 + return ~0UL;
52619 +
52620 +#ifdef CONFIG_PAX_SOFTMODE
52621 + if (pax_softmode)
52622 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52623 + else
52624 +#endif
52625 +
52626 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52627 + break;
52628 + }
52629 +#endif
52630 +
52631 + return ~0UL;
52632 +}
52633 +
52634 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52635 +{
52636 +
52637 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52638 + ssize_t xattr_size, i;
52639 + unsigned char xattr_value[sizeof("pemrs") - 1];
52640 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52641 +
52642 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52643 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52644 + return ~0UL;
52645 +
52646 + for (i = 0; i < xattr_size; i++)
52647 + switch (xattr_value[i]) {
52648 + default:
52649 + return ~0UL;
52650 +
52651 +#define parse_flag(option1, option2, flag) \
52652 + case option1: \
52653 + if (pax_flags_hardmode & MF_PAX_##flag) \
52654 + return ~0UL; \
52655 + pax_flags_hardmode |= MF_PAX_##flag; \
52656 + break; \
52657 + case option2: \
52658 + if (pax_flags_softmode & MF_PAX_##flag) \
52659 + return ~0UL; \
52660 + pax_flags_softmode |= MF_PAX_##flag; \
52661 + break;
52662 +
52663 + parse_flag('p', 'P', PAGEEXEC);
52664 + parse_flag('e', 'E', EMUTRAMP);
52665 + parse_flag('m', 'M', MPROTECT);
52666 + parse_flag('r', 'R', RANDMMAP);
52667 + parse_flag('s', 'S', SEGMEXEC);
52668 +
52669 +#undef parse_flag
52670 + }
52671 +
52672 + if (pax_flags_hardmode & pax_flags_softmode)
52673 + return ~0UL;
52674 +
52675 +#ifdef CONFIG_PAX_SOFTMODE
52676 + if (pax_softmode)
52677 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52678 + else
52679 +#endif
52680 +
52681 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52682 +#else
52683 + return ~0UL;
52684 +#endif
52685 +
52686 +}
52687 +
52688 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52689 +{
52690 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52691 +
52692 + pax_flags = pax_parse_ei_pax(elf_ex);
52693 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52694 + xattr_pax_flags = pax_parse_xattr_pax(file);
52695 +
52696 + if (pt_pax_flags == ~0UL)
52697 + pt_pax_flags = xattr_pax_flags;
52698 + else if (xattr_pax_flags == ~0UL)
52699 + xattr_pax_flags = pt_pax_flags;
52700 + if (pt_pax_flags != xattr_pax_flags)
52701 + return -EINVAL;
52702 + if (pt_pax_flags != ~0UL)
52703 + pax_flags = pt_pax_flags;
52704 +
52705 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52706 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52707 + if ((__supported_pte_mask & _PAGE_NX))
52708 + pax_flags &= ~MF_PAX_SEGMEXEC;
52709 + else
52710 + pax_flags &= ~MF_PAX_PAGEEXEC;
52711 + }
52712 +#endif
52713 +
52714 + if (0 > pax_check_flags(&pax_flags))
52715 + return -EINVAL;
52716 +
52717 + current->mm->pax_flags = pax_flags;
52718 + return 0;
52719 +}
52720 +#endif
52721 +
52722 /*
52723 * These are the functions used to load ELF style executables and shared
52724 * libraries. There is no binary dependent code anywhere else.
52725 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52726 {
52727 unsigned int random_variable = 0;
52728
52729 +#ifdef CONFIG_PAX_RANDUSTACK
52730 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52731 + return stack_top - current->mm->delta_stack;
52732 +#endif
52733 +
52734 if ((current->flags & PF_RANDOMIZE) &&
52735 !(current->personality & ADDR_NO_RANDOMIZE)) {
52736 random_variable = get_random_int() & STACK_RND_MASK;
52737 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52738 unsigned long load_addr = 0, load_bias = 0;
52739 int load_addr_set = 0;
52740 char * elf_interpreter = NULL;
52741 - unsigned long error;
52742 + unsigned long error = 0;
52743 struct elf_phdr *elf_ppnt, *elf_phdata;
52744 unsigned long elf_bss, elf_brk;
52745 int retval, i;
52746 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52747 unsigned long start_code, end_code, start_data, end_data;
52748 unsigned long reloc_func_desc __maybe_unused = 0;
52749 int executable_stack = EXSTACK_DEFAULT;
52750 - unsigned long def_flags = 0;
52751 struct pt_regs *regs = current_pt_regs();
52752 struct {
52753 struct elfhdr elf_ex;
52754 struct elfhdr interp_elf_ex;
52755 } *loc;
52756 + unsigned long pax_task_size = TASK_SIZE;
52757
52758 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52759 if (!loc) {
52760 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52761 goto out_free_dentry;
52762
52763 /* OK, This is the point of no return */
52764 - current->mm->def_flags = def_flags;
52765 +
52766 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52767 + current->mm->pax_flags = 0UL;
52768 +#endif
52769 +
52770 +#ifdef CONFIG_PAX_DLRESOLVE
52771 + current->mm->call_dl_resolve = 0UL;
52772 +#endif
52773 +
52774 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52775 + current->mm->call_syscall = 0UL;
52776 +#endif
52777 +
52778 +#ifdef CONFIG_PAX_ASLR
52779 + current->mm->delta_mmap = 0UL;
52780 + current->mm->delta_stack = 0UL;
52781 +#endif
52782 +
52783 + current->mm->def_flags = 0;
52784 +
52785 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52786 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52787 + send_sig(SIGKILL, current, 0);
52788 + goto out_free_dentry;
52789 + }
52790 +#endif
52791 +
52792 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52793 + pax_set_initial_flags(bprm);
52794 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52795 + if (pax_set_initial_flags_func)
52796 + (pax_set_initial_flags_func)(bprm);
52797 +#endif
52798 +
52799 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52800 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52801 + current->mm->context.user_cs_limit = PAGE_SIZE;
52802 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52803 + }
52804 +#endif
52805 +
52806 +#ifdef CONFIG_PAX_SEGMEXEC
52807 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52808 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52809 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52810 + pax_task_size = SEGMEXEC_TASK_SIZE;
52811 + current->mm->def_flags |= VM_NOHUGEPAGE;
52812 + }
52813 +#endif
52814 +
52815 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
52816 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52817 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
52818 + put_cpu();
52819 + }
52820 +#endif
52821
52822 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
52823 may depend on the personality. */
52824 SET_PERSONALITY(loc->elf_ex);
52825 +
52826 +#ifdef CONFIG_PAX_ASLR
52827 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52828 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
52829 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
52830 + }
52831 +#endif
52832 +
52833 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52834 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52835 + executable_stack = EXSTACK_DISABLE_X;
52836 + current->personality &= ~READ_IMPLIES_EXEC;
52837 + } else
52838 +#endif
52839 +
52840 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
52841 current->personality |= READ_IMPLIES_EXEC;
52842
52843 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
52844 #else
52845 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
52846 #endif
52847 +
52848 +#ifdef CONFIG_PAX_RANDMMAP
52849 + /* PaX: randomize base address at the default exe base if requested */
52850 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
52851 +#ifdef CONFIG_SPARC64
52852 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
52853 +#else
52854 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
52855 +#endif
52856 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
52857 + elf_flags |= MAP_FIXED;
52858 + }
52859 +#endif
52860 +
52861 }
52862
52863 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
52864 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
52865 * allowed task size. Note that p_filesz must always be
52866 * <= p_memsz so it is only necessary to check p_memsz.
52867 */
52868 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52869 - elf_ppnt->p_memsz > TASK_SIZE ||
52870 - TASK_SIZE - elf_ppnt->p_memsz < k) {
52871 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52872 + elf_ppnt->p_memsz > pax_task_size ||
52873 + pax_task_size - elf_ppnt->p_memsz < k) {
52874 /* set_brk can never work. Avoid overflows. */
52875 send_sig(SIGKILL, current, 0);
52876 retval = -EINVAL;
52877 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
52878 goto out_free_dentry;
52879 }
52880 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
52881 - send_sig(SIGSEGV, current, 0);
52882 - retval = -EFAULT; /* Nobody gets to see this, but.. */
52883 - goto out_free_dentry;
52884 + /*
52885 + * This bss-zeroing can fail if the ELF
52886 + * file specifies odd protections. So
52887 + * we don't check the return value
52888 + */
52889 }
52890
52891 +#ifdef CONFIG_PAX_RANDMMAP
52892 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52893 + unsigned long start, size, flags;
52894 + vm_flags_t vm_flags;
52895 +
52896 + start = ELF_PAGEALIGN(elf_brk);
52897 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
52898 + flags = MAP_FIXED | MAP_PRIVATE;
52899 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
52900 +
52901 + down_write(&current->mm->mmap_sem);
52902 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
52903 + retval = -ENOMEM;
52904 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
52905 +// if (current->personality & ADDR_NO_RANDOMIZE)
52906 +// vm_flags |= VM_READ | VM_MAYREAD;
52907 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
52908 + retval = IS_ERR_VALUE(start) ? start : 0;
52909 + }
52910 + up_write(&current->mm->mmap_sem);
52911 + if (retval == 0)
52912 + retval = set_brk(start + size, start + size + PAGE_SIZE);
52913 + if (retval < 0) {
52914 + send_sig(SIGKILL, current, 0);
52915 + goto out_free_dentry;
52916 + }
52917 + }
52918 +#endif
52919 +
52920 if (elf_interpreter) {
52921 - unsigned long interp_map_addr = 0;
52922 -
52923 elf_entry = load_elf_interp(&loc->interp_elf_ex,
52924 interpreter,
52925 - &interp_map_addr,
52926 load_bias);
52927 if (!IS_ERR((void *)elf_entry)) {
52928 /*
52929 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
52930 * Decide what to dump of a segment, part, all or none.
52931 */
52932 static unsigned long vma_dump_size(struct vm_area_struct *vma,
52933 - unsigned long mm_flags)
52934 + unsigned long mm_flags, long signr)
52935 {
52936 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
52937
52938 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
52939 if (vma->vm_file == NULL)
52940 return 0;
52941
52942 - if (FILTER(MAPPED_PRIVATE))
52943 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
52944 goto whole;
52945
52946 /*
52947 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
52948 {
52949 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
52950 int i = 0;
52951 - do
52952 + do {
52953 i += 2;
52954 - while (auxv[i - 2] != AT_NULL);
52955 + } while (auxv[i - 2] != AT_NULL);
52956 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
52957 }
52958
52959 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
52960 {
52961 mm_segment_t old_fs = get_fs();
52962 set_fs(KERNEL_DS);
52963 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
52964 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
52965 set_fs(old_fs);
52966 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
52967 }
52968 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
52969 }
52970
52971 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
52972 - unsigned long mm_flags)
52973 + struct coredump_params *cprm)
52974 {
52975 struct vm_area_struct *vma;
52976 size_t size = 0;
52977
52978 for (vma = first_vma(current, gate_vma); vma != NULL;
52979 vma = next_vma(vma, gate_vma))
52980 - size += vma_dump_size(vma, mm_flags);
52981 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
52982 return size;
52983 }
52984
52985 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
52986
52987 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
52988
52989 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
52990 + offset += elf_core_vma_data_size(gate_vma, cprm);
52991 offset += elf_core_extra_data_size();
52992 e_shoff = offset;
52993
52994 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
52995 offset = dataoff;
52996
52997 size += sizeof(*elf);
52998 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
52999 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53000 goto end_coredump;
53001
53002 size += sizeof(*phdr4note);
53003 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53004 if (size > cprm->limit
53005 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53006 goto end_coredump;
53007 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53008 phdr.p_offset = offset;
53009 phdr.p_vaddr = vma->vm_start;
53010 phdr.p_paddr = 0;
53011 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53012 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53013 phdr.p_memsz = vma->vm_end - vma->vm_start;
53014 offset += phdr.p_filesz;
53015 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53016 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53017 phdr.p_align = ELF_EXEC_PAGESIZE;
53018
53019 size += sizeof(phdr);
53020 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53021 if (size > cprm->limit
53022 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53023 goto end_coredump;
53024 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53025 unsigned long addr;
53026 unsigned long end;
53027
53028 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53029 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53030
53031 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53032 struct page *page;
53033 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53034 page = get_dump_page(addr);
53035 if (page) {
53036 void *kaddr = kmap(page);
53037 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53038 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53039 !dump_write(cprm->file, kaddr,
53040 PAGE_SIZE);
53041 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53042
53043 if (e_phnum == PN_XNUM) {
53044 size += sizeof(*shdr4extnum);
53045 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53046 if (size > cprm->limit
53047 || !dump_write(cprm->file, shdr4extnum,
53048 sizeof(*shdr4extnum)))
53049 @@ -2235,6 +2697,167 @@ out:
53050
53051 #endif /* CONFIG_ELF_CORE */
53052
53053 +#ifdef CONFIG_PAX_MPROTECT
53054 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53055 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53056 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53057 + *
53058 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53059 + * basis because we want to allow the common case and not the special ones.
53060 + */
53061 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53062 +{
53063 + struct elfhdr elf_h;
53064 + struct elf_phdr elf_p;
53065 + unsigned long i;
53066 + unsigned long oldflags;
53067 + bool is_textrel_rw, is_textrel_rx, is_relro;
53068 +
53069 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53070 + return;
53071 +
53072 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53073 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53074 +
53075 +#ifdef CONFIG_PAX_ELFRELOCS
53076 + /* possible TEXTREL */
53077 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53078 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53079 +#else
53080 + is_textrel_rw = false;
53081 + is_textrel_rx = false;
53082 +#endif
53083 +
53084 + /* possible RELRO */
53085 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53086 +
53087 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53088 + return;
53089 +
53090 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53091 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53092 +
53093 +#ifdef CONFIG_PAX_ETEXECRELOCS
53094 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53095 +#else
53096 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53097 +#endif
53098 +
53099 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53100 + !elf_check_arch(&elf_h) ||
53101 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53102 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53103 + return;
53104 +
53105 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53106 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53107 + return;
53108 + switch (elf_p.p_type) {
53109 + case PT_DYNAMIC:
53110 + if (!is_textrel_rw && !is_textrel_rx)
53111 + continue;
53112 + i = 0UL;
53113 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53114 + elf_dyn dyn;
53115 +
53116 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53117 + break;
53118 + if (dyn.d_tag == DT_NULL)
53119 + break;
53120 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53121 + gr_log_textrel(vma);
53122 + if (is_textrel_rw)
53123 + vma->vm_flags |= VM_MAYWRITE;
53124 + else
53125 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53126 + vma->vm_flags &= ~VM_MAYWRITE;
53127 + break;
53128 + }
53129 + i++;
53130 + }
53131 + is_textrel_rw = false;
53132 + is_textrel_rx = false;
53133 + continue;
53134 +
53135 + case PT_GNU_RELRO:
53136 + if (!is_relro)
53137 + continue;
53138 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53139 + vma->vm_flags &= ~VM_MAYWRITE;
53140 + is_relro = false;
53141 + continue;
53142 +
53143 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53144 + case PT_PAX_FLAGS: {
53145 + const char *msg_mprotect = "", *msg_emutramp = "";
53146 + char *buffer_lib, *buffer_exe;
53147 +
53148 + if (elf_p.p_flags & PF_NOMPROTECT)
53149 + msg_mprotect = "MPROTECT disabled";
53150 +
53151 +#ifdef CONFIG_PAX_EMUTRAMP
53152 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53153 + msg_emutramp = "EMUTRAMP enabled";
53154 +#endif
53155 +
53156 + if (!msg_mprotect[0] && !msg_emutramp[0])
53157 + continue;
53158 +
53159 + if (!printk_ratelimit())
53160 + continue;
53161 +
53162 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53163 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53164 + if (buffer_lib && buffer_exe) {
53165 + char *path_lib, *path_exe;
53166 +
53167 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53168 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53169 +
53170 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53171 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53172 +
53173 + }
53174 + free_page((unsigned long)buffer_exe);
53175 + free_page((unsigned long)buffer_lib);
53176 + continue;
53177 + }
53178 +#endif
53179 +
53180 + }
53181 + }
53182 +}
53183 +#endif
53184 +
53185 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53186 +
53187 +extern int grsec_enable_log_rwxmaps;
53188 +
53189 +static void elf_handle_mmap(struct file *file)
53190 +{
53191 + struct elfhdr elf_h;
53192 + struct elf_phdr elf_p;
53193 + unsigned long i;
53194 +
53195 + if (!grsec_enable_log_rwxmaps)
53196 + return;
53197 +
53198 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53199 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53200 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53201 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53202 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53203 + return;
53204 +
53205 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53206 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53207 + return;
53208 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53209 + gr_log_ptgnustack(file);
53210 + }
53211 +}
53212 +#endif
53213 +
53214 static int __init init_elf_binfmt(void)
53215 {
53216 register_binfmt(&elf_format);
53217 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53218 index d50bbe5..af3b649 100644
53219 --- a/fs/binfmt_flat.c
53220 +++ b/fs/binfmt_flat.c
53221 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53222 realdatastart = (unsigned long) -ENOMEM;
53223 printk("Unable to allocate RAM for process data, errno %d\n",
53224 (int)-realdatastart);
53225 + down_write(&current->mm->mmap_sem);
53226 vm_munmap(textpos, text_len);
53227 + up_write(&current->mm->mmap_sem);
53228 ret = realdatastart;
53229 goto err;
53230 }
53231 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53232 }
53233 if (IS_ERR_VALUE(result)) {
53234 printk("Unable to read data+bss, errno %d\n", (int)-result);
53235 + down_write(&current->mm->mmap_sem);
53236 vm_munmap(textpos, text_len);
53237 vm_munmap(realdatastart, len);
53238 + up_write(&current->mm->mmap_sem);
53239 ret = result;
53240 goto err;
53241 }
53242 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53243 }
53244 if (IS_ERR_VALUE(result)) {
53245 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53246 + down_write(&current->mm->mmap_sem);
53247 vm_munmap(textpos, text_len + data_len + extra +
53248 MAX_SHARED_LIBS * sizeof(unsigned long));
53249 + up_write(&current->mm->mmap_sem);
53250 ret = result;
53251 goto err;
53252 }
53253 diff --git a/fs/bio.c b/fs/bio.c
53254 index 5e7507d..418c639 100644
53255 --- a/fs/bio.c
53256 +++ b/fs/bio.c
53257 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53258 /*
53259 * Overflow, abort
53260 */
53261 - if (end < start)
53262 + if (end < start || end - start > INT_MAX - nr_pages)
53263 return ERR_PTR(-EINVAL);
53264
53265 nr_pages += end - start;
53266 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53267 /*
53268 * Overflow, abort
53269 */
53270 - if (end < start)
53271 + if (end < start || end - start > INT_MAX - nr_pages)
53272 return ERR_PTR(-EINVAL);
53273
53274 nr_pages += end - start;
53275 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53276 const int read = bio_data_dir(bio) == READ;
53277 struct bio_map_data *bmd = bio->bi_private;
53278 int i;
53279 - char *p = bmd->sgvecs[0].iov_base;
53280 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53281
53282 bio_for_each_segment_all(bvec, bio, i) {
53283 char *addr = page_address(bvec->bv_page);
53284 diff --git a/fs/block_dev.c b/fs/block_dev.c
53285 index c7bda5c..2121e94 100644
53286 --- a/fs/block_dev.c
53287 +++ b/fs/block_dev.c
53288 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53289 else if (bdev->bd_contains == bdev)
53290 return true; /* is a whole device which isn't held */
53291
53292 - else if (whole->bd_holder == bd_may_claim)
53293 + else if (whole->bd_holder == (void *)bd_may_claim)
53294 return true; /* is a partition of a device that is being partitioned */
53295 else if (whole->bd_holder != NULL)
53296 return false; /* is a partition of a held device */
53297 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53298 index ed50460..fe84385 100644
53299 --- a/fs/btrfs/ctree.c
53300 +++ b/fs/btrfs/ctree.c
53301 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53302 free_extent_buffer(buf);
53303 add_root_to_dirty_list(root);
53304 } else {
53305 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53306 - parent_start = parent->start;
53307 - else
53308 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53309 + if (parent)
53310 + parent_start = parent->start;
53311 + else
53312 + parent_start = 0;
53313 + } else
53314 parent_start = 0;
53315
53316 WARN_ON(trans->transid != btrfs_header_generation(parent));
53317 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53318 index 3755109..e3d457f 100644
53319 --- a/fs/btrfs/delayed-inode.c
53320 +++ b/fs/btrfs/delayed-inode.c
53321 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53322
53323 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53324 {
53325 - int seq = atomic_inc_return(&delayed_root->items_seq);
53326 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53327 if ((atomic_dec_return(&delayed_root->items) <
53328 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53329 waitqueue_active(&delayed_root->wait))
53330 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53331 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53332 int seq, int count)
53333 {
53334 - int val = atomic_read(&delayed_root->items_seq);
53335 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53336
53337 if (val < seq || val >= seq + count)
53338 return 1;
53339 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53340 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53341 return;
53342
53343 - seq = atomic_read(&delayed_root->items_seq);
53344 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53345
53346 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53347 int ret;
53348 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53349 index a4b38f9..f86a509 100644
53350 --- a/fs/btrfs/delayed-inode.h
53351 +++ b/fs/btrfs/delayed-inode.h
53352 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53353 */
53354 struct list_head prepare_list;
53355 atomic_t items; /* for delayed items */
53356 - atomic_t items_seq; /* for delayed items */
53357 + atomic_unchecked_t items_seq; /* for delayed items */
53358 int nodes; /* for delayed nodes */
53359 wait_queue_head_t wait;
53360 };
53361 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53362 struct btrfs_delayed_root *delayed_root)
53363 {
53364 atomic_set(&delayed_root->items, 0);
53365 - atomic_set(&delayed_root->items_seq, 0);
53366 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53367 delayed_root->nodes = 0;
53368 spin_lock_init(&delayed_root->lock);
53369 init_waitqueue_head(&delayed_root->wait);
53370 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53371 index 9877a2a..7ebf9ab 100644
53372 --- a/fs/btrfs/ioctl.c
53373 +++ b/fs/btrfs/ioctl.c
53374 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53375 for (i = 0; i < num_types; i++) {
53376 struct btrfs_space_info *tmp;
53377
53378 + /* Don't copy in more than we allocated */
53379 if (!slot_count)
53380 break;
53381
53382 + slot_count--;
53383 +
53384 info = NULL;
53385 rcu_read_lock();
53386 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53387 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53388 memcpy(dest, &space, sizeof(space));
53389 dest++;
53390 space_args.total_spaces++;
53391 - slot_count--;
53392 }
53393 - if (!slot_count)
53394 - break;
53395 }
53396 up_read(&info->groups_sem);
53397 }
53398 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53399 index 8eb6191..eda91e2 100644
53400 --- a/fs/btrfs/super.c
53401 +++ b/fs/btrfs/super.c
53402 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53403 function, line, errstr);
53404 return;
53405 }
53406 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53407 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53408 /* Wake up anybody who may be waiting on this transaction */
53409 wake_up(&root->fs_info->transaction_wait);
53410 wake_up(&root->fs_info->transaction_blocked_wait);
53411 diff --git a/fs/buffer.c b/fs/buffer.c
53412 index 4d74335..b0df7f9 100644
53413 --- a/fs/buffer.c
53414 +++ b/fs/buffer.c
53415 @@ -3416,7 +3416,7 @@ void __init buffer_init(void)
53416 bh_cachep = kmem_cache_create("buffer_head",
53417 sizeof(struct buffer_head), 0,
53418 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53419 - SLAB_MEM_SPREAD),
53420 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53421 NULL);
53422
53423 /*
53424 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53425 index 622f469..e8d2d55 100644
53426 --- a/fs/cachefiles/bind.c
53427 +++ b/fs/cachefiles/bind.c
53428 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53429 args);
53430
53431 /* start by checking things over */
53432 - ASSERT(cache->fstop_percent >= 0 &&
53433 - cache->fstop_percent < cache->fcull_percent &&
53434 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53435 cache->fcull_percent < cache->frun_percent &&
53436 cache->frun_percent < 100);
53437
53438 - ASSERT(cache->bstop_percent >= 0 &&
53439 - cache->bstop_percent < cache->bcull_percent &&
53440 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53441 cache->bcull_percent < cache->brun_percent &&
53442 cache->brun_percent < 100);
53443
53444 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53445 index 0a1467b..6a53245 100644
53446 --- a/fs/cachefiles/daemon.c
53447 +++ b/fs/cachefiles/daemon.c
53448 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53449 if (n > buflen)
53450 return -EMSGSIZE;
53451
53452 - if (copy_to_user(_buffer, buffer, n) != 0)
53453 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53454 return -EFAULT;
53455
53456 return n;
53457 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53458 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53459 return -EIO;
53460
53461 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53462 + if (datalen > PAGE_SIZE - 1)
53463 return -EOPNOTSUPP;
53464
53465 /* drag the command string into the kernel so we can parse it */
53466 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53467 if (args[0] != '%' || args[1] != '\0')
53468 return -EINVAL;
53469
53470 - if (fstop < 0 || fstop >= cache->fcull_percent)
53471 + if (fstop >= cache->fcull_percent)
53472 return cachefiles_daemon_range_error(cache, args);
53473
53474 cache->fstop_percent = fstop;
53475 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53476 if (args[0] != '%' || args[1] != '\0')
53477 return -EINVAL;
53478
53479 - if (bstop < 0 || bstop >= cache->bcull_percent)
53480 + if (bstop >= cache->bcull_percent)
53481 return cachefiles_daemon_range_error(cache, args);
53482
53483 cache->bstop_percent = bstop;
53484 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53485 index 4938251..7e01445 100644
53486 --- a/fs/cachefiles/internal.h
53487 +++ b/fs/cachefiles/internal.h
53488 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53489 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53490 struct rb_root active_nodes; /* active nodes (can't be culled) */
53491 rwlock_t active_lock; /* lock for active_nodes */
53492 - atomic_t gravecounter; /* graveyard uniquifier */
53493 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53494 unsigned frun_percent; /* when to stop culling (% files) */
53495 unsigned fcull_percent; /* when to start culling (% files) */
53496 unsigned fstop_percent; /* when to stop allocating (% files) */
53497 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53498 * proc.c
53499 */
53500 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53501 -extern atomic_t cachefiles_lookup_histogram[HZ];
53502 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53503 -extern atomic_t cachefiles_create_histogram[HZ];
53504 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53505 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53506 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53507
53508 extern int __init cachefiles_proc_init(void);
53509 extern void cachefiles_proc_cleanup(void);
53510 static inline
53511 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53512 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53513 {
53514 unsigned long jif = jiffies - start_jif;
53515 if (jif >= HZ)
53516 jif = HZ - 1;
53517 - atomic_inc(&histogram[jif]);
53518 + atomic_inc_unchecked(&histogram[jif]);
53519 }
53520
53521 #else
53522 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53523 index 25badd1..d70d918 100644
53524 --- a/fs/cachefiles/namei.c
53525 +++ b/fs/cachefiles/namei.c
53526 @@ -317,7 +317,7 @@ try_again:
53527 /* first step is to make up a grave dentry in the graveyard */
53528 sprintf(nbuffer, "%08x%08x",
53529 (uint32_t) get_seconds(),
53530 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53531 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53532
53533 /* do the multiway lock magic */
53534 trap = lock_rename(cache->graveyard, dir);
53535 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53536 index eccd339..4c1d995 100644
53537 --- a/fs/cachefiles/proc.c
53538 +++ b/fs/cachefiles/proc.c
53539 @@ -14,9 +14,9 @@
53540 #include <linux/seq_file.h>
53541 #include "internal.h"
53542
53543 -atomic_t cachefiles_lookup_histogram[HZ];
53544 -atomic_t cachefiles_mkdir_histogram[HZ];
53545 -atomic_t cachefiles_create_histogram[HZ];
53546 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53547 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53548 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53549
53550 /*
53551 * display the latency histogram
53552 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53553 return 0;
53554 default:
53555 index = (unsigned long) v - 3;
53556 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53557 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53558 - z = atomic_read(&cachefiles_create_histogram[index]);
53559 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53560 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53561 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53562 if (x == 0 && y == 0 && z == 0)
53563 return 0;
53564
53565 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53566 index ebaff36..7e3ea26 100644
53567 --- a/fs/cachefiles/rdwr.c
53568 +++ b/fs/cachefiles/rdwr.c
53569 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53570 old_fs = get_fs();
53571 set_fs(KERNEL_DS);
53572 ret = file->f_op->write(
53573 - file, (const void __user *) data, len, &pos);
53574 + file, (const void __force_user *) data, len, &pos);
53575 set_fs(old_fs);
53576 kunmap(page);
53577 file_end_write(file);
53578 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53579 index a40ceda..f43d17c 100644
53580 --- a/fs/ceph/dir.c
53581 +++ b/fs/ceph/dir.c
53582 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53583 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53584 struct ceph_mds_client *mdsc = fsc->mdsc;
53585 unsigned frag = fpos_frag(ctx->pos);
53586 - int off = fpos_off(ctx->pos);
53587 + unsigned int off = fpos_off(ctx->pos);
53588 int err;
53589 u32 ftype;
53590 struct ceph_mds_reply_info_parsed *rinfo;
53591 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53592 index 6627b26..634ec4b 100644
53593 --- a/fs/ceph/super.c
53594 +++ b/fs/ceph/super.c
53595 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53596 /*
53597 * construct our own bdi so we can control readahead, etc.
53598 */
53599 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53600 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53601
53602 static int ceph_register_bdi(struct super_block *sb,
53603 struct ceph_fs_client *fsc)
53604 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53605 default_backing_dev_info.ra_pages;
53606
53607 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53608 - atomic_long_inc_return(&bdi_seq));
53609 + atomic_long_inc_return_unchecked(&bdi_seq));
53610 if (!err)
53611 sb->s_bdi = &fsc->backing_dev_info;
53612 return err;
53613 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53614 index f3ac415..3d2420c 100644
53615 --- a/fs/cifs/cifs_debug.c
53616 +++ b/fs/cifs/cifs_debug.c
53617 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53618
53619 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53620 #ifdef CONFIG_CIFS_STATS2
53621 - atomic_set(&totBufAllocCount, 0);
53622 - atomic_set(&totSmBufAllocCount, 0);
53623 + atomic_set_unchecked(&totBufAllocCount, 0);
53624 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53625 #endif /* CONFIG_CIFS_STATS2 */
53626 spin_lock(&cifs_tcp_ses_lock);
53627 list_for_each(tmp1, &cifs_tcp_ses_list) {
53628 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53629 tcon = list_entry(tmp3,
53630 struct cifs_tcon,
53631 tcon_list);
53632 - atomic_set(&tcon->num_smbs_sent, 0);
53633 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53634 if (server->ops->clear_stats)
53635 server->ops->clear_stats(tcon);
53636 }
53637 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53638 smBufAllocCount.counter, cifs_min_small);
53639 #ifdef CONFIG_CIFS_STATS2
53640 seq_printf(m, "Total Large %d Small %d Allocations\n",
53641 - atomic_read(&totBufAllocCount),
53642 - atomic_read(&totSmBufAllocCount));
53643 + atomic_read_unchecked(&totBufAllocCount),
53644 + atomic_read_unchecked(&totSmBufAllocCount));
53645 #endif /* CONFIG_CIFS_STATS2 */
53646
53647 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53648 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53649 if (tcon->need_reconnect)
53650 seq_puts(m, "\tDISCONNECTED ");
53651 seq_printf(m, "\nSMBs: %d",
53652 - atomic_read(&tcon->num_smbs_sent));
53653 + atomic_read_unchecked(&tcon->num_smbs_sent));
53654 if (server->ops->print_stats)
53655 server->ops->print_stats(m, tcon);
53656 }
53657 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53658 index 85ea98d..b3ed4d6 100644
53659 --- a/fs/cifs/cifsfs.c
53660 +++ b/fs/cifs/cifsfs.c
53661 @@ -1037,7 +1037,7 @@ cifs_init_request_bufs(void)
53662 */
53663 cifs_req_cachep = kmem_cache_create("cifs_request",
53664 CIFSMaxBufSize + max_hdr_size, 0,
53665 - SLAB_HWCACHE_ALIGN, NULL);
53666 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53667 if (cifs_req_cachep == NULL)
53668 return -ENOMEM;
53669
53670 @@ -1064,7 +1064,7 @@ cifs_init_request_bufs(void)
53671 efficient to alloc 1 per page off the slab compared to 17K (5page)
53672 alloc of large cifs buffers even when page debugging is on */
53673 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53674 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53675 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53676 NULL);
53677 if (cifs_sm_req_cachep == NULL) {
53678 mempool_destroy(cifs_req_poolp);
53679 @@ -1149,8 +1149,8 @@ init_cifs(void)
53680 atomic_set(&bufAllocCount, 0);
53681 atomic_set(&smBufAllocCount, 0);
53682 #ifdef CONFIG_CIFS_STATS2
53683 - atomic_set(&totBufAllocCount, 0);
53684 - atomic_set(&totSmBufAllocCount, 0);
53685 + atomic_set_unchecked(&totBufAllocCount, 0);
53686 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53687 #endif /* CONFIG_CIFS_STATS2 */
53688
53689 atomic_set(&midCount, 0);
53690 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53691 index 52ca861..47f309c 100644
53692 --- a/fs/cifs/cifsglob.h
53693 +++ b/fs/cifs/cifsglob.h
53694 @@ -756,35 +756,35 @@ struct cifs_tcon {
53695 __u16 Flags; /* optional support bits */
53696 enum statusEnum tidStatus;
53697 #ifdef CONFIG_CIFS_STATS
53698 - atomic_t num_smbs_sent;
53699 + atomic_unchecked_t num_smbs_sent;
53700 union {
53701 struct {
53702 - atomic_t num_writes;
53703 - atomic_t num_reads;
53704 - atomic_t num_flushes;
53705 - atomic_t num_oplock_brks;
53706 - atomic_t num_opens;
53707 - atomic_t num_closes;
53708 - atomic_t num_deletes;
53709 - atomic_t num_mkdirs;
53710 - atomic_t num_posixopens;
53711 - atomic_t num_posixmkdirs;
53712 - atomic_t num_rmdirs;
53713 - atomic_t num_renames;
53714 - atomic_t num_t2renames;
53715 - atomic_t num_ffirst;
53716 - atomic_t num_fnext;
53717 - atomic_t num_fclose;
53718 - atomic_t num_hardlinks;
53719 - atomic_t num_symlinks;
53720 - atomic_t num_locks;
53721 - atomic_t num_acl_get;
53722 - atomic_t num_acl_set;
53723 + atomic_unchecked_t num_writes;
53724 + atomic_unchecked_t num_reads;
53725 + atomic_unchecked_t num_flushes;
53726 + atomic_unchecked_t num_oplock_brks;
53727 + atomic_unchecked_t num_opens;
53728 + atomic_unchecked_t num_closes;
53729 + atomic_unchecked_t num_deletes;
53730 + atomic_unchecked_t num_mkdirs;
53731 + atomic_unchecked_t num_posixopens;
53732 + atomic_unchecked_t num_posixmkdirs;
53733 + atomic_unchecked_t num_rmdirs;
53734 + atomic_unchecked_t num_renames;
53735 + atomic_unchecked_t num_t2renames;
53736 + atomic_unchecked_t num_ffirst;
53737 + atomic_unchecked_t num_fnext;
53738 + atomic_unchecked_t num_fclose;
53739 + atomic_unchecked_t num_hardlinks;
53740 + atomic_unchecked_t num_symlinks;
53741 + atomic_unchecked_t num_locks;
53742 + atomic_unchecked_t num_acl_get;
53743 + atomic_unchecked_t num_acl_set;
53744 } cifs_stats;
53745 #ifdef CONFIG_CIFS_SMB2
53746 struct {
53747 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53748 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53749 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53750 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53751 } smb2_stats;
53752 #endif /* CONFIG_CIFS_SMB2 */
53753 } stats;
53754 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53755 }
53756
53757 #ifdef CONFIG_CIFS_STATS
53758 -#define cifs_stats_inc atomic_inc
53759 +#define cifs_stats_inc atomic_inc_unchecked
53760
53761 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53762 unsigned int bytes)
53763 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53764 /* Various Debug counters */
53765 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53766 #ifdef CONFIG_CIFS_STATS2
53767 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53768 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53769 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53770 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53771 #endif
53772 GLOBAL_EXTERN atomic_t smBufAllocCount;
53773 GLOBAL_EXTERN atomic_t midCount;
53774 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53775 index 562044f..4af6a17 100644
53776 --- a/fs/cifs/link.c
53777 +++ b/fs/cifs/link.c
53778 @@ -638,7 +638,7 @@ symlink_exit:
53779
53780 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53781 {
53782 - char *p = nd_get_link(nd);
53783 + const char *p = nd_get_link(nd);
53784 if (!IS_ERR(p))
53785 kfree(p);
53786 }
53787 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53788 index f7d4b22..1254377 100644
53789 --- a/fs/cifs/misc.c
53790 +++ b/fs/cifs/misc.c
53791 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53792 memset(ret_buf, 0, buf_size + 3);
53793 atomic_inc(&bufAllocCount);
53794 #ifdef CONFIG_CIFS_STATS2
53795 - atomic_inc(&totBufAllocCount);
53796 + atomic_inc_unchecked(&totBufAllocCount);
53797 #endif /* CONFIG_CIFS_STATS2 */
53798 }
53799
53800 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53801 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53802 atomic_inc(&smBufAllocCount);
53803 #ifdef CONFIG_CIFS_STATS2
53804 - atomic_inc(&totSmBufAllocCount);
53805 + atomic_inc_unchecked(&totSmBufAllocCount);
53806 #endif /* CONFIG_CIFS_STATS2 */
53807
53808 }
53809 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
53810 index 6094397..51e576f 100644
53811 --- a/fs/cifs/smb1ops.c
53812 +++ b/fs/cifs/smb1ops.c
53813 @@ -590,27 +590,27 @@ static void
53814 cifs_clear_stats(struct cifs_tcon *tcon)
53815 {
53816 #ifdef CONFIG_CIFS_STATS
53817 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
53818 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
53819 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
53820 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53821 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
53822 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
53823 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53824 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
53825 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
53826 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
53827 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
53828 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
53829 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
53830 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
53831 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
53832 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
53833 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
53834 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
53835 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
53836 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
53837 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
53838 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
53839 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
53840 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
53841 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53842 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
53843 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
53844 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53845 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
53846 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
53847 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
53848 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
53849 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
53850 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
53851 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
53852 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
53853 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
53854 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
53855 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
53856 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
53857 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
53858 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
53859 #endif
53860 }
53861
53862 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
53863 {
53864 #ifdef CONFIG_CIFS_STATS
53865 seq_printf(m, " Oplocks breaks: %d",
53866 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
53867 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
53868 seq_printf(m, "\nReads: %d Bytes: %llu",
53869 - atomic_read(&tcon->stats.cifs_stats.num_reads),
53870 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
53871 (long long)(tcon->bytes_read));
53872 seq_printf(m, "\nWrites: %d Bytes: %llu",
53873 - atomic_read(&tcon->stats.cifs_stats.num_writes),
53874 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
53875 (long long)(tcon->bytes_written));
53876 seq_printf(m, "\nFlushes: %d",
53877 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
53878 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
53879 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
53880 - atomic_read(&tcon->stats.cifs_stats.num_locks),
53881 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
53882 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
53883 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
53884 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
53885 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
53886 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
53887 - atomic_read(&tcon->stats.cifs_stats.num_opens),
53888 - atomic_read(&tcon->stats.cifs_stats.num_closes),
53889 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
53890 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
53891 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
53892 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
53893 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
53894 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
53895 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
53896 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
53897 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
53898 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
53899 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
53900 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
53901 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
53902 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
53903 seq_printf(m, "\nRenames: %d T2 Renames %d",
53904 - atomic_read(&tcon->stats.cifs_stats.num_renames),
53905 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
53906 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
53907 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
53908 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
53909 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
53910 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
53911 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
53912 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
53913 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
53914 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
53915 #endif
53916 }
53917
53918 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
53919 index f259e6c..ca948ff 100644
53920 --- a/fs/cifs/smb2ops.c
53921 +++ b/fs/cifs/smb2ops.c
53922 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
53923 #ifdef CONFIG_CIFS_STATS
53924 int i;
53925 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
53926 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
53927 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
53928 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
53929 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
53930 }
53931 #endif
53932 }
53933 @@ -310,65 +310,65 @@ static void
53934 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
53935 {
53936 #ifdef CONFIG_CIFS_STATS
53937 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
53938 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
53939 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
53940 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
53941 seq_printf(m, "\nNegotiates: %d sent %d failed",
53942 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
53943 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
53944 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
53945 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
53946 seq_printf(m, "\nSessionSetups: %d sent %d failed",
53947 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
53948 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
53949 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
53950 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
53951 seq_printf(m, "\nLogoffs: %d sent %d failed",
53952 - atomic_read(&sent[SMB2_LOGOFF_HE]),
53953 - atomic_read(&failed[SMB2_LOGOFF_HE]));
53954 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
53955 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
53956 seq_printf(m, "\nTreeConnects: %d sent %d failed",
53957 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
53958 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
53959 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
53960 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
53961 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
53962 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
53963 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
53964 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
53965 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
53966 seq_printf(m, "\nCreates: %d sent %d failed",
53967 - atomic_read(&sent[SMB2_CREATE_HE]),
53968 - atomic_read(&failed[SMB2_CREATE_HE]));
53969 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
53970 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
53971 seq_printf(m, "\nCloses: %d sent %d failed",
53972 - atomic_read(&sent[SMB2_CLOSE_HE]),
53973 - atomic_read(&failed[SMB2_CLOSE_HE]));
53974 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
53975 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
53976 seq_printf(m, "\nFlushes: %d sent %d failed",
53977 - atomic_read(&sent[SMB2_FLUSH_HE]),
53978 - atomic_read(&failed[SMB2_FLUSH_HE]));
53979 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
53980 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
53981 seq_printf(m, "\nReads: %d sent %d failed",
53982 - atomic_read(&sent[SMB2_READ_HE]),
53983 - atomic_read(&failed[SMB2_READ_HE]));
53984 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
53985 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
53986 seq_printf(m, "\nWrites: %d sent %d failed",
53987 - atomic_read(&sent[SMB2_WRITE_HE]),
53988 - atomic_read(&failed[SMB2_WRITE_HE]));
53989 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
53990 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
53991 seq_printf(m, "\nLocks: %d sent %d failed",
53992 - atomic_read(&sent[SMB2_LOCK_HE]),
53993 - atomic_read(&failed[SMB2_LOCK_HE]));
53994 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
53995 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
53996 seq_printf(m, "\nIOCTLs: %d sent %d failed",
53997 - atomic_read(&sent[SMB2_IOCTL_HE]),
53998 - atomic_read(&failed[SMB2_IOCTL_HE]));
53999 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54000 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54001 seq_printf(m, "\nCancels: %d sent %d failed",
54002 - atomic_read(&sent[SMB2_CANCEL_HE]),
54003 - atomic_read(&failed[SMB2_CANCEL_HE]));
54004 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54005 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54006 seq_printf(m, "\nEchos: %d sent %d failed",
54007 - atomic_read(&sent[SMB2_ECHO_HE]),
54008 - atomic_read(&failed[SMB2_ECHO_HE]));
54009 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54010 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54011 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54012 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54013 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54014 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54015 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54016 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54017 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54018 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54019 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54020 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54021 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54022 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54023 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54024 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54025 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54026 seq_printf(m, "\nSetInfos: %d sent %d failed",
54027 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54028 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54029 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54030 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54031 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54032 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54033 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54034 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54035 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54036 #endif
54037 }
54038
54039 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54040 index abc9c28..3fdae28 100644
54041 --- a/fs/cifs/smb2pdu.c
54042 +++ b/fs/cifs/smb2pdu.c
54043 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54044 default:
54045 cifs_dbg(VFS, "info level %u isn't supported\n",
54046 srch_inf->info_level);
54047 - rc = -EINVAL;
54048 - goto qdir_exit;
54049 + return -EINVAL;
54050 }
54051
54052 req->FileIndex = cpu_to_le32(index);
54053 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54054 index 1da168c..8bc7ff6 100644
54055 --- a/fs/coda/cache.c
54056 +++ b/fs/coda/cache.c
54057 @@ -24,7 +24,7 @@
54058 #include "coda_linux.h"
54059 #include "coda_cache.h"
54060
54061 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54062 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54063
54064 /* replace or extend an acl cache hit */
54065 void coda_cache_enter(struct inode *inode, int mask)
54066 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54067 struct coda_inode_info *cii = ITOC(inode);
54068
54069 spin_lock(&cii->c_lock);
54070 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54071 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54072 if (!uid_eq(cii->c_uid, current_fsuid())) {
54073 cii->c_uid = current_fsuid();
54074 cii->c_cached_perm = mask;
54075 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54076 {
54077 struct coda_inode_info *cii = ITOC(inode);
54078 spin_lock(&cii->c_lock);
54079 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54080 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54081 spin_unlock(&cii->c_lock);
54082 }
54083
54084 /* remove all acl caches */
54085 void coda_cache_clear_all(struct super_block *sb)
54086 {
54087 - atomic_inc(&permission_epoch);
54088 + atomic_inc_unchecked(&permission_epoch);
54089 }
54090
54091
54092 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54093 spin_lock(&cii->c_lock);
54094 hit = (mask & cii->c_cached_perm) == mask &&
54095 uid_eq(cii->c_uid, current_fsuid()) &&
54096 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54097 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54098 spin_unlock(&cii->c_lock);
54099
54100 return hit;
54101 diff --git a/fs/compat.c b/fs/compat.c
54102 index 6af20de..fec3fbb 100644
54103 --- a/fs/compat.c
54104 +++ b/fs/compat.c
54105 @@ -54,7 +54,7 @@
54106 #include <asm/ioctls.h>
54107 #include "internal.h"
54108
54109 -int compat_log = 1;
54110 +int compat_log = 0;
54111
54112 int compat_printk(const char *fmt, ...)
54113 {
54114 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54115
54116 set_fs(KERNEL_DS);
54117 /* The __user pointer cast is valid because of the set_fs() */
54118 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54119 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54120 set_fs(oldfs);
54121 /* truncating is ok because it's a user address */
54122 if (!ret)
54123 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54124 goto out;
54125
54126 ret = -EINVAL;
54127 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54128 + if (nr_segs > UIO_MAXIOV)
54129 goto out;
54130 if (nr_segs > fast_segs) {
54131 ret = -ENOMEM;
54132 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54133 struct compat_readdir_callback {
54134 struct dir_context ctx;
54135 struct compat_old_linux_dirent __user *dirent;
54136 + struct file * file;
54137 int result;
54138 };
54139
54140 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54141 buf->result = -EOVERFLOW;
54142 return -EOVERFLOW;
54143 }
54144 +
54145 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54146 + return 0;
54147 +
54148 buf->result++;
54149 dirent = buf->dirent;
54150 if (!access_ok(VERIFY_WRITE, dirent,
54151 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54152 if (!f.file)
54153 return -EBADF;
54154
54155 + buf.file = f.file;
54156 error = iterate_dir(f.file, &buf.ctx);
54157 if (buf.result)
54158 error = buf.result;
54159 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54160 struct dir_context ctx;
54161 struct compat_linux_dirent __user *current_dir;
54162 struct compat_linux_dirent __user *previous;
54163 + struct file * file;
54164 int count;
54165 int error;
54166 };
54167 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54168 buf->error = -EOVERFLOW;
54169 return -EOVERFLOW;
54170 }
54171 +
54172 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54173 + return 0;
54174 +
54175 dirent = buf->previous;
54176 if (dirent) {
54177 if (__put_user(offset, &dirent->d_off))
54178 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54179 if (!f.file)
54180 return -EBADF;
54181
54182 + buf.file = f.file;
54183 error = iterate_dir(f.file, &buf.ctx);
54184 if (error >= 0)
54185 error = buf.error;
54186 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54187 struct dir_context ctx;
54188 struct linux_dirent64 __user *current_dir;
54189 struct linux_dirent64 __user *previous;
54190 + struct file * file;
54191 int count;
54192 int error;
54193 };
54194 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54195 buf->error = -EINVAL; /* only used if we fail.. */
54196 if (reclen > buf->count)
54197 return -EINVAL;
54198 +
54199 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54200 + return 0;
54201 +
54202 dirent = buf->previous;
54203
54204 if (dirent) {
54205 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54206 if (!f.file)
54207 return -EBADF;
54208
54209 + buf.file = f.file;
54210 error = iterate_dir(f.file, &buf.ctx);
54211 if (error >= 0)
54212 error = buf.error;
54213 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54214 index a81147e..20bf2b5 100644
54215 --- a/fs/compat_binfmt_elf.c
54216 +++ b/fs/compat_binfmt_elf.c
54217 @@ -30,11 +30,13 @@
54218 #undef elf_phdr
54219 #undef elf_shdr
54220 #undef elf_note
54221 +#undef elf_dyn
54222 #undef elf_addr_t
54223 #define elfhdr elf32_hdr
54224 #define elf_phdr elf32_phdr
54225 #define elf_shdr elf32_shdr
54226 #define elf_note elf32_note
54227 +#define elf_dyn Elf32_Dyn
54228 #define elf_addr_t Elf32_Addr
54229
54230 /*
54231 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54232 index 5d19acf..9ab093b 100644
54233 --- a/fs/compat_ioctl.c
54234 +++ b/fs/compat_ioctl.c
54235 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54236 return -EFAULT;
54237 if (__get_user(udata, &ss32->iomem_base))
54238 return -EFAULT;
54239 - ss.iomem_base = compat_ptr(udata);
54240 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54241 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54242 __get_user(ss.port_high, &ss32->port_high))
54243 return -EFAULT;
54244 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54245 for (i = 0; i < nmsgs; i++) {
54246 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54247 return -EFAULT;
54248 - if (get_user(datap, &umsgs[i].buf) ||
54249 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54250 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54251 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54252 return -EFAULT;
54253 }
54254 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54255 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54256 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54257 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54258 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54259 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54260 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54261 return -EFAULT;
54262
54263 return ioctl_preallocate(file, p);
54264 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54265 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54266 {
54267 unsigned int a, b;
54268 - a = *(unsigned int *)p;
54269 - b = *(unsigned int *)q;
54270 + a = *(const unsigned int *)p;
54271 + b = *(const unsigned int *)q;
54272 if (a > b)
54273 return 1;
54274 if (a < b)
54275 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54276 index 277bd1b..f312c9e 100644
54277 --- a/fs/configfs/dir.c
54278 +++ b/fs/configfs/dir.c
54279 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54280 }
54281 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54282 struct configfs_dirent *next;
54283 - const char *name;
54284 + const unsigned char * name;
54285 + char d_name[sizeof(next->s_dentry->d_iname)];
54286 int len;
54287 struct inode *inode = NULL;
54288
54289 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54290 continue;
54291
54292 name = configfs_get_name(next);
54293 - len = strlen(name);
54294 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54295 + len = next->s_dentry->d_name.len;
54296 + memcpy(d_name, name, len);
54297 + name = d_name;
54298 + } else
54299 + len = strlen(name);
54300
54301 /*
54302 * We'll have a dentry and an inode for
54303 diff --git a/fs/coredump.c b/fs/coredump.c
54304 index 72f816d..1ba8eff 100644
54305 --- a/fs/coredump.c
54306 +++ b/fs/coredump.c
54307 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54308 struct pipe_inode_info *pipe = file->private_data;
54309
54310 pipe_lock(pipe);
54311 - pipe->readers++;
54312 - pipe->writers--;
54313 + atomic_inc(&pipe->readers);
54314 + atomic_dec(&pipe->writers);
54315 wake_up_interruptible_sync(&pipe->wait);
54316 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54317 pipe_unlock(pipe);
54318 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54319 * We actually want wait_event_freezable() but then we need
54320 * to clear TIF_SIGPENDING and improve dump_interrupted().
54321 */
54322 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54323 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54324
54325 pipe_lock(pipe);
54326 - pipe->readers--;
54327 - pipe->writers++;
54328 + atomic_dec(&pipe->readers);
54329 + atomic_inc(&pipe->writers);
54330 pipe_unlock(pipe);
54331 }
54332
54333 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54334 struct files_struct *displaced;
54335 bool need_nonrelative = false;
54336 bool core_dumped = false;
54337 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54338 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54339 + long signr = siginfo->si_signo;
54340 struct coredump_params cprm = {
54341 .siginfo = siginfo,
54342 .regs = signal_pt_regs(),
54343 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54344 .mm_flags = mm->flags,
54345 };
54346
54347 - audit_core_dumps(siginfo->si_signo);
54348 + audit_core_dumps(signr);
54349 +
54350 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54351 + gr_handle_brute_attach(cprm.mm_flags);
54352
54353 binfmt = mm->binfmt;
54354 if (!binfmt || !binfmt->core_dump)
54355 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54356 need_nonrelative = true;
54357 }
54358
54359 - retval = coredump_wait(siginfo->si_signo, &core_state);
54360 + retval = coredump_wait(signr, &core_state);
54361 if (retval < 0)
54362 goto fail_creds;
54363
54364 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54365 }
54366 cprm.limit = RLIM_INFINITY;
54367
54368 - dump_count = atomic_inc_return(&core_dump_count);
54369 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54370 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54371 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54372 task_tgid_vnr(current), current->comm);
54373 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54374 } else {
54375 struct inode *inode;
54376
54377 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54378 +
54379 if (cprm.limit < binfmt->min_coredump)
54380 goto fail_unlock;
54381
54382 @@ -664,7 +670,7 @@ close_fail:
54383 filp_close(cprm.file, NULL);
54384 fail_dropcount:
54385 if (ispipe)
54386 - atomic_dec(&core_dump_count);
54387 + atomic_dec_unchecked(&core_dump_count);
54388 fail_unlock:
54389 kfree(cn.corename);
54390 coredump_finish(mm, core_dumped);
54391 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54392 {
54393 return !dump_interrupted() &&
54394 access_ok(VERIFY_READ, addr, nr) &&
54395 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54396 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54397 }
54398 EXPORT_SYMBOL(dump_write);
54399
54400 diff --git a/fs/dcache.c b/fs/dcache.c
54401 index b949af8..5978926 100644
54402 --- a/fs/dcache.c
54403 +++ b/fs/dcache.c
54404 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54405 mempages -= reserve;
54406
54407 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54408 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54409 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54410 + SLAB_NO_SANITIZE, NULL);
54411
54412 dcache_init();
54413 inode_init();
54414 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54415 index c7c83ff..bda9461 100644
54416 --- a/fs/debugfs/inode.c
54417 +++ b/fs/debugfs/inode.c
54418 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54419 */
54420 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54421 {
54422 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54423 + return __create_file(name, S_IFDIR | S_IRWXU,
54424 +#else
54425 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54426 +#endif
54427 parent, NULL, NULL);
54428 }
54429 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54430 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54431 index 67e9b63..a9adb68 100644
54432 --- a/fs/ecryptfs/inode.c
54433 +++ b/fs/ecryptfs/inode.c
54434 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54435 old_fs = get_fs();
54436 set_fs(get_ds());
54437 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54438 - (char __user *)lower_buf,
54439 + (char __force_user *)lower_buf,
54440 PATH_MAX);
54441 set_fs(old_fs);
54442 if (rc < 0)
54443 @@ -706,7 +706,7 @@ out:
54444 static void
54445 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54446 {
54447 - char *buf = nd_get_link(nd);
54448 + const char *buf = nd_get_link(nd);
54449 if (!IS_ERR(buf)) {
54450 /* Free the char* */
54451 kfree(buf);
54452 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54453 index e4141f2..d8263e8 100644
54454 --- a/fs/ecryptfs/miscdev.c
54455 +++ b/fs/ecryptfs/miscdev.c
54456 @@ -304,7 +304,7 @@ check_list:
54457 goto out_unlock_msg_ctx;
54458 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54459 if (msg_ctx->msg) {
54460 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54461 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54462 goto out_unlock_msg_ctx;
54463 i += packet_length_size;
54464 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54465 diff --git a/fs/exec.c b/fs/exec.c
54466 index fd774c7..1c6a7bf 100644
54467 --- a/fs/exec.c
54468 +++ b/fs/exec.c
54469 @@ -55,8 +55,20 @@
54470 #include <linux/pipe_fs_i.h>
54471 #include <linux/oom.h>
54472 #include <linux/compat.h>
54473 +#include <linux/random.h>
54474 +#include <linux/seq_file.h>
54475 +#include <linux/coredump.h>
54476 +#include <linux/mman.h>
54477 +
54478 +#ifdef CONFIG_PAX_REFCOUNT
54479 +#include <linux/kallsyms.h>
54480 +#include <linux/kdebug.h>
54481 +#endif
54482 +
54483 +#include <trace/events/fs.h>
54484
54485 #include <asm/uaccess.h>
54486 +#include <asm/sections.h>
54487 #include <asm/mmu_context.h>
54488 #include <asm/tlb.h>
54489
54490 @@ -66,17 +78,32 @@
54491
54492 #include <trace/events/sched.h>
54493
54494 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54495 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54496 +{
54497 + 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");
54498 +}
54499 +#endif
54500 +
54501 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54502 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54503 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54504 +#endif
54505 +
54506 int suid_dumpable = 0;
54507
54508 static LIST_HEAD(formats);
54509 static DEFINE_RWLOCK(binfmt_lock);
54510
54511 +extern int gr_process_kernel_exec_ban(void);
54512 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54513 +
54514 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54515 {
54516 BUG_ON(!fmt);
54517 write_lock(&binfmt_lock);
54518 - insert ? list_add(&fmt->lh, &formats) :
54519 - list_add_tail(&fmt->lh, &formats);
54520 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54521 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54522 write_unlock(&binfmt_lock);
54523 }
54524
54525 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54526 void unregister_binfmt(struct linux_binfmt * fmt)
54527 {
54528 write_lock(&binfmt_lock);
54529 - list_del(&fmt->lh);
54530 + pax_list_del((struct list_head *)&fmt->lh);
54531 write_unlock(&binfmt_lock);
54532 }
54533
54534 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54535 int write)
54536 {
54537 struct page *page;
54538 - int ret;
54539
54540 -#ifdef CONFIG_STACK_GROWSUP
54541 - if (write) {
54542 - ret = expand_downwards(bprm->vma, pos);
54543 - if (ret < 0)
54544 - return NULL;
54545 - }
54546 -#endif
54547 - ret = get_user_pages(current, bprm->mm, pos,
54548 - 1, write, 1, &page, NULL);
54549 - if (ret <= 0)
54550 + if (0 > expand_downwards(bprm->vma, pos))
54551 + return NULL;
54552 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54553 return NULL;
54554
54555 if (write) {
54556 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54557 if (size <= ARG_MAX)
54558 return page;
54559
54560 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54561 + // only allow 512KB for argv+env on suid/sgid binaries
54562 + // to prevent easy ASLR exhaustion
54563 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54564 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54565 + (size > (512 * 1024))) {
54566 + put_page(page);
54567 + return NULL;
54568 + }
54569 +#endif
54570 +
54571 /*
54572 * Limit to 1/4-th the stack size for the argv+env strings.
54573 * This ensures that:
54574 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54575 vma->vm_end = STACK_TOP_MAX;
54576 vma->vm_start = vma->vm_end - PAGE_SIZE;
54577 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54578 +
54579 +#ifdef CONFIG_PAX_SEGMEXEC
54580 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54581 +#endif
54582 +
54583 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54584 INIT_LIST_HEAD(&vma->anon_vma_chain);
54585
54586 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54587 mm->stack_vm = mm->total_vm = 1;
54588 up_write(&mm->mmap_sem);
54589 bprm->p = vma->vm_end - sizeof(void *);
54590 +
54591 +#ifdef CONFIG_PAX_RANDUSTACK
54592 + if (randomize_va_space)
54593 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54594 +#endif
54595 +
54596 return 0;
54597 err:
54598 up_write(&mm->mmap_sem);
54599 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54600 } ptr;
54601 };
54602
54603 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54604 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54605 {
54606 const char __user *native;
54607
54608 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54609 compat_uptr_t compat;
54610
54611 if (get_user(compat, argv.ptr.compat + nr))
54612 - return ERR_PTR(-EFAULT);
54613 + return (const char __force_user *)ERR_PTR(-EFAULT);
54614
54615 return compat_ptr(compat);
54616 }
54617 #endif
54618
54619 if (get_user(native, argv.ptr.native + nr))
54620 - return ERR_PTR(-EFAULT);
54621 + return (const char __force_user *)ERR_PTR(-EFAULT);
54622
54623 return native;
54624 }
54625 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54626 if (!p)
54627 break;
54628
54629 - if (IS_ERR(p))
54630 + if (IS_ERR((const char __force_kernel *)p))
54631 return -EFAULT;
54632
54633 if (i >= max)
54634 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54635
54636 ret = -EFAULT;
54637 str = get_user_arg_ptr(argv, argc);
54638 - if (IS_ERR(str))
54639 + if (IS_ERR((const char __force_kernel *)str))
54640 goto out;
54641
54642 len = strnlen_user(str, MAX_ARG_STRLEN);
54643 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54644 int r;
54645 mm_segment_t oldfs = get_fs();
54646 struct user_arg_ptr argv = {
54647 - .ptr.native = (const char __user *const __user *)__argv,
54648 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54649 };
54650
54651 set_fs(KERNEL_DS);
54652 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54653 unsigned long new_end = old_end - shift;
54654 struct mmu_gather tlb;
54655
54656 - BUG_ON(new_start > new_end);
54657 + if (new_start >= new_end || new_start < mmap_min_addr)
54658 + return -ENOMEM;
54659
54660 /*
54661 * ensure there are no vmas between where we want to go
54662 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54663 if (vma != find_vma(mm, new_start))
54664 return -EFAULT;
54665
54666 +#ifdef CONFIG_PAX_SEGMEXEC
54667 + BUG_ON(pax_find_mirror_vma(vma));
54668 +#endif
54669 +
54670 /*
54671 * cover the whole range: [new_start, old_end)
54672 */
54673 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54674 stack_top = arch_align_stack(stack_top);
54675 stack_top = PAGE_ALIGN(stack_top);
54676
54677 - if (unlikely(stack_top < mmap_min_addr) ||
54678 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54679 - return -ENOMEM;
54680 -
54681 stack_shift = vma->vm_end - stack_top;
54682
54683 bprm->p -= stack_shift;
54684 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54685 bprm->exec -= stack_shift;
54686
54687 down_write(&mm->mmap_sem);
54688 +
54689 + /* Move stack pages down in memory. */
54690 + if (stack_shift) {
54691 + ret = shift_arg_pages(vma, stack_shift);
54692 + if (ret)
54693 + goto out_unlock;
54694 + }
54695 +
54696 vm_flags = VM_STACK_FLAGS;
54697
54698 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54699 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54700 + vm_flags &= ~VM_EXEC;
54701 +
54702 +#ifdef CONFIG_PAX_MPROTECT
54703 + if (mm->pax_flags & MF_PAX_MPROTECT)
54704 + vm_flags &= ~VM_MAYEXEC;
54705 +#endif
54706 +
54707 + }
54708 +#endif
54709 +
54710 /*
54711 * Adjust stack execute permissions; explicitly enable for
54712 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54713 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54714 goto out_unlock;
54715 BUG_ON(prev != vma);
54716
54717 - /* Move stack pages down in memory. */
54718 - if (stack_shift) {
54719 - ret = shift_arg_pages(vma, stack_shift);
54720 - if (ret)
54721 - goto out_unlock;
54722 - }
54723 -
54724 /* mprotect_fixup is overkill to remove the temporary stack flags */
54725 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54726
54727 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54728 #endif
54729 current->mm->start_stack = bprm->p;
54730 ret = expand_stack(vma, stack_base);
54731 +
54732 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54733 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54734 + unsigned long size;
54735 + vm_flags_t vm_flags;
54736 +
54737 + size = STACK_TOP - vma->vm_end;
54738 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54739 +
54740 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54741 +
54742 +#ifdef CONFIG_X86
54743 + if (!ret) {
54744 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54745 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54746 + }
54747 +#endif
54748 +
54749 + }
54750 +#endif
54751 +
54752 if (ret)
54753 ret = -EFAULT;
54754
54755 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54756
54757 fsnotify_open(file);
54758
54759 + trace_open_exec(name);
54760 +
54761 err = deny_write_access(file);
54762 if (err)
54763 goto exit;
54764 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54765 old_fs = get_fs();
54766 set_fs(get_ds());
54767 /* The cast to a user pointer is valid due to the set_fs() */
54768 - result = vfs_read(file, (void __user *)addr, count, &pos);
54769 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54770 set_fs(old_fs);
54771 return result;
54772 }
54773 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54774 }
54775 rcu_read_unlock();
54776
54777 - if (p->fs->users > n_fs) {
54778 + if (atomic_read(&p->fs->users) > n_fs) {
54779 bprm->unsafe |= LSM_UNSAFE_SHARE;
54780 } else {
54781 res = -EAGAIN;
54782 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54783
54784 EXPORT_SYMBOL(search_binary_handler);
54785
54786 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54787 +static DEFINE_PER_CPU(u64, exec_counter);
54788 +static int __init init_exec_counters(void)
54789 +{
54790 + unsigned int cpu;
54791 +
54792 + for_each_possible_cpu(cpu) {
54793 + per_cpu(exec_counter, cpu) = (u64)cpu;
54794 + }
54795 +
54796 + return 0;
54797 +}
54798 +early_initcall(init_exec_counters);
54799 +static inline void increment_exec_counter(void)
54800 +{
54801 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
54802 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
54803 +}
54804 +#else
54805 +static inline void increment_exec_counter(void) {}
54806 +#endif
54807 +
54808 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
54809 + struct user_arg_ptr argv);
54810 +
54811 /*
54812 * sys_execve() executes a new program.
54813 */
54814 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
54815 struct user_arg_ptr argv,
54816 struct user_arg_ptr envp)
54817 {
54818 +#ifdef CONFIG_GRKERNSEC
54819 + struct file *old_exec_file;
54820 + struct acl_subject_label *old_acl;
54821 + struct rlimit old_rlim[RLIM_NLIMITS];
54822 +#endif
54823 struct linux_binprm *bprm;
54824 struct file *file;
54825 struct files_struct *displaced;
54826 bool clear_in_exec;
54827 int retval;
54828
54829 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
54830 +
54831 /*
54832 * We move the actual failure in case of RLIMIT_NPROC excess from
54833 * set*uid() to execve() because too many poorly written programs
54834 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
54835 if (IS_ERR(file))
54836 goto out_unmark;
54837
54838 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
54839 + retval = -EPERM;
54840 + goto out_file;
54841 + }
54842 +
54843 sched_exec();
54844
54845 bprm->file = file;
54846 bprm->filename = filename;
54847 bprm->interp = filename;
54848
54849 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
54850 + retval = -EACCES;
54851 + goto out_file;
54852 + }
54853 +
54854 retval = bprm_mm_init(bprm);
54855 if (retval)
54856 goto out_file;
54857 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
54858 if (retval < 0)
54859 goto out;
54860
54861 +#ifdef CONFIG_GRKERNSEC
54862 + old_acl = current->acl;
54863 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
54864 + old_exec_file = current->exec_file;
54865 + get_file(file);
54866 + current->exec_file = file;
54867 +#endif
54868 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54869 + /* limit suid stack to 8MB
54870 + * we saved the old limits above and will restore them if this exec fails
54871 + */
54872 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
54873 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
54874 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
54875 +#endif
54876 +
54877 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
54878 + retval = -EPERM;
54879 + goto out_fail;
54880 + }
54881 +
54882 + if (!gr_tpe_allow(file)) {
54883 + retval = -EACCES;
54884 + goto out_fail;
54885 + }
54886 +
54887 + if (gr_check_crash_exec(file)) {
54888 + retval = -EACCES;
54889 + goto out_fail;
54890 + }
54891 +
54892 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
54893 + bprm->unsafe);
54894 + if (retval < 0)
54895 + goto out_fail;
54896 +
54897 retval = copy_strings_kernel(1, &bprm->filename, bprm);
54898 if (retval < 0)
54899 - goto out;
54900 + goto out_fail;
54901
54902 bprm->exec = bprm->p;
54903 retval = copy_strings(bprm->envc, envp, bprm);
54904 if (retval < 0)
54905 - goto out;
54906 + goto out_fail;
54907
54908 retval = copy_strings(bprm->argc, argv, bprm);
54909 if (retval < 0)
54910 - goto out;
54911 + goto out_fail;
54912 +
54913 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
54914 +
54915 + gr_handle_exec_args(bprm, argv);
54916
54917 retval = search_binary_handler(bprm);
54918 if (retval < 0)
54919 - goto out;
54920 + goto out_fail;
54921 +#ifdef CONFIG_GRKERNSEC
54922 + if (old_exec_file)
54923 + fput(old_exec_file);
54924 +#endif
54925
54926 /* execve succeeded */
54927 +
54928 + increment_exec_counter();
54929 current->fs->in_exec = 0;
54930 current->in_execve = 0;
54931 acct_update_integrals(current);
54932 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
54933 put_files_struct(displaced);
54934 return retval;
54935
54936 +out_fail:
54937 +#ifdef CONFIG_GRKERNSEC
54938 + current->acl = old_acl;
54939 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
54940 + fput(current->exec_file);
54941 + current->exec_file = old_exec_file;
54942 +#endif
54943 +
54944 out:
54945 if (bprm->mm) {
54946 acct_arg_size(bprm, 0);
54947 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
54948 return error;
54949 }
54950 #endif
54951 +
54952 +int pax_check_flags(unsigned long *flags)
54953 +{
54954 + int retval = 0;
54955 +
54956 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
54957 + if (*flags & MF_PAX_SEGMEXEC)
54958 + {
54959 + *flags &= ~MF_PAX_SEGMEXEC;
54960 + retval = -EINVAL;
54961 + }
54962 +#endif
54963 +
54964 + if ((*flags & MF_PAX_PAGEEXEC)
54965 +
54966 +#ifdef CONFIG_PAX_PAGEEXEC
54967 + && (*flags & MF_PAX_SEGMEXEC)
54968 +#endif
54969 +
54970 + )
54971 + {
54972 + *flags &= ~MF_PAX_PAGEEXEC;
54973 + retval = -EINVAL;
54974 + }
54975 +
54976 + if ((*flags & MF_PAX_MPROTECT)
54977 +
54978 +#ifdef CONFIG_PAX_MPROTECT
54979 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
54980 +#endif
54981 +
54982 + )
54983 + {
54984 + *flags &= ~MF_PAX_MPROTECT;
54985 + retval = -EINVAL;
54986 + }
54987 +
54988 + if ((*flags & MF_PAX_EMUTRAMP)
54989 +
54990 +#ifdef CONFIG_PAX_EMUTRAMP
54991 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
54992 +#endif
54993 +
54994 + )
54995 + {
54996 + *flags &= ~MF_PAX_EMUTRAMP;
54997 + retval = -EINVAL;
54998 + }
54999 +
55000 + return retval;
55001 +}
55002 +
55003 +EXPORT_SYMBOL(pax_check_flags);
55004 +
55005 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55006 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55007 +{
55008 + char *pathname = d_path(path, buf, buflen);
55009 +
55010 + if (IS_ERR(pathname))
55011 + goto toolong;
55012 +
55013 + pathname = mangle_path(buf, pathname, "\t\n\\");
55014 + if (!pathname)
55015 + goto toolong;
55016 +
55017 + *pathname = 0;
55018 + return buf;
55019 +
55020 +toolong:
55021 + return "<path too long>";
55022 +}
55023 +EXPORT_SYMBOL(pax_get_path);
55024 +
55025 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55026 +{
55027 + struct task_struct *tsk = current;
55028 + struct mm_struct *mm = current->mm;
55029 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55030 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55031 + char *path_exec = NULL;
55032 + char *path_fault = NULL;
55033 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55034 + siginfo_t info = { };
55035 +
55036 + if (buffer_exec && buffer_fault) {
55037 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55038 +
55039 + down_read(&mm->mmap_sem);
55040 + vma = mm->mmap;
55041 + while (vma && (!vma_exec || !vma_fault)) {
55042 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55043 + vma_exec = vma;
55044 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55045 + vma_fault = vma;
55046 + vma = vma->vm_next;
55047 + }
55048 + if (vma_exec)
55049 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55050 + if (vma_fault) {
55051 + start = vma_fault->vm_start;
55052 + end = vma_fault->vm_end;
55053 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55054 + if (vma_fault->vm_file)
55055 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55056 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55057 + path_fault = "<heap>";
55058 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55059 + path_fault = "<stack>";
55060 + else
55061 + path_fault = "<anonymous mapping>";
55062 + }
55063 + up_read(&mm->mmap_sem);
55064 + }
55065 + if (tsk->signal->curr_ip)
55066 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55067 + else
55068 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55069 + 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),
55070 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55071 + free_page((unsigned long)buffer_exec);
55072 + free_page((unsigned long)buffer_fault);
55073 + pax_report_insns(regs, pc, sp);
55074 + info.si_signo = SIGKILL;
55075 + info.si_errno = 0;
55076 + info.si_code = SI_KERNEL;
55077 + info.si_pid = 0;
55078 + info.si_uid = 0;
55079 + do_coredump(&info);
55080 +}
55081 +#endif
55082 +
55083 +#ifdef CONFIG_PAX_REFCOUNT
55084 +void pax_report_refcount_overflow(struct pt_regs *regs)
55085 +{
55086 + if (current->signal->curr_ip)
55087 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55088 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55089 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55090 + else
55091 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55092 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55093 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55094 + preempt_disable();
55095 + show_regs(regs);
55096 + preempt_enable();
55097 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55098 +}
55099 +#endif
55100 +
55101 +#ifdef CONFIG_PAX_USERCOPY
55102 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55103 +static noinline int check_stack_object(const void *obj, unsigned long len)
55104 +{
55105 + const void * const stack = task_stack_page(current);
55106 + const void * const stackend = stack + THREAD_SIZE;
55107 +
55108 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55109 + const void *frame = NULL;
55110 + const void *oldframe;
55111 +#endif
55112 +
55113 + if (obj + len < obj)
55114 + return -1;
55115 +
55116 + if (obj + len <= stack || stackend <= obj)
55117 + return 0;
55118 +
55119 + if (obj < stack || stackend < obj + len)
55120 + return -1;
55121 +
55122 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55123 + oldframe = __builtin_frame_address(1);
55124 + if (oldframe)
55125 + frame = __builtin_frame_address(2);
55126 + /*
55127 + low ----------------------------------------------> high
55128 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55129 + ^----------------^
55130 + allow copies only within here
55131 + */
55132 + while (stack <= frame && frame < stackend) {
55133 + /* if obj + len extends past the last frame, this
55134 + check won't pass and the next frame will be 0,
55135 + causing us to bail out and correctly report
55136 + the copy as invalid
55137 + */
55138 + if (obj + len <= frame)
55139 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55140 + oldframe = frame;
55141 + frame = *(const void * const *)frame;
55142 + }
55143 + return -1;
55144 +#else
55145 + return 1;
55146 +#endif
55147 +}
55148 +
55149 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55150 +{
55151 + if (current->signal->curr_ip)
55152 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55153 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55154 + else
55155 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55156 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55157 + dump_stack();
55158 + gr_handle_kernel_exploit();
55159 + do_group_exit(SIGKILL);
55160 +}
55161 +#endif
55162 +
55163 +#ifdef CONFIG_PAX_USERCOPY
55164 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55165 +{
55166 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55167 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55168 +#ifdef CONFIG_MODULES
55169 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55170 +#else
55171 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55172 +#endif
55173 +
55174 +#else
55175 + unsigned long textlow = (unsigned long)_stext;
55176 + unsigned long texthigh = (unsigned long)_etext;
55177 +#endif
55178 +
55179 + if (high <= textlow || low > texthigh)
55180 + return false;
55181 + else
55182 + return true;
55183 +}
55184 +#endif
55185 +
55186 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55187 +{
55188 +
55189 +#ifdef CONFIG_PAX_USERCOPY
55190 + const char *type;
55191 +
55192 + if (!n)
55193 + return;
55194 +
55195 + type = check_heap_object(ptr, n);
55196 + if (!type) {
55197 + int ret = check_stack_object(ptr, n);
55198 + if (ret == 1 || ret == 2)
55199 + return;
55200 + if (ret == 0) {
55201 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55202 + type = "<kernel text>";
55203 + else
55204 + return;
55205 + } else
55206 + type = "<process stack>";
55207 + }
55208 +
55209 + pax_report_usercopy(ptr, n, to_user, type);
55210 +#endif
55211 +
55212 +}
55213 +EXPORT_SYMBOL(__check_object_size);
55214 +
55215 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55216 +void pax_track_stack(void)
55217 +{
55218 + unsigned long sp = (unsigned long)&sp;
55219 + if (sp < current_thread_info()->lowest_stack &&
55220 + sp > (unsigned long)task_stack_page(current))
55221 + current_thread_info()->lowest_stack = sp;
55222 +}
55223 +EXPORT_SYMBOL(pax_track_stack);
55224 +#endif
55225 +
55226 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55227 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55228 +{
55229 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55230 + dump_stack();
55231 + do_group_exit(SIGKILL);
55232 +}
55233 +EXPORT_SYMBOL(report_size_overflow);
55234 +#endif
55235 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55236 index 9f9992b..8b59411 100644
55237 --- a/fs/ext2/balloc.c
55238 +++ b/fs/ext2/balloc.c
55239 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55240
55241 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55242 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55243 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55244 + if (free_blocks < root_blocks + 1 &&
55245 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55246 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55247 - !in_group_p (sbi->s_resgid))) {
55248 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55249 return 0;
55250 }
55251 return 1;
55252 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55253 index 22548f5..41521d8 100644
55254 --- a/fs/ext3/balloc.c
55255 +++ b/fs/ext3/balloc.c
55256 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55257
55258 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55259 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55260 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55261 + if (free_blocks < root_blocks + 1 &&
55262 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55263 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55264 - !in_group_p (sbi->s_resgid))) {
55265 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55266 return 0;
55267 }
55268 return 1;
55269 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55270 index ddd715e..c772f88 100644
55271 --- a/fs/ext4/balloc.c
55272 +++ b/fs/ext4/balloc.c
55273 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55274 /* Hm, nope. Are (enough) root reserved clusters available? */
55275 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55276 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55277 - capable(CAP_SYS_RESOURCE) ||
55278 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55279 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55280 + capable_nolog(CAP_SYS_RESOURCE)) {
55281
55282 if (free_clusters >= (nclusters + dirty_clusters +
55283 resv_clusters))
55284 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55285 index 0ab26fb..b6ecb39 100644
55286 --- a/fs/ext4/ext4.h
55287 +++ b/fs/ext4/ext4.h
55288 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55289 unsigned long s_mb_last_start;
55290
55291 /* stats for buddy allocator */
55292 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55293 - atomic_t s_bal_success; /* we found long enough chunks */
55294 - atomic_t s_bal_allocated; /* in blocks */
55295 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55296 - atomic_t s_bal_goals; /* goal hits */
55297 - atomic_t s_bal_breaks; /* too long searches */
55298 - atomic_t s_bal_2orders; /* 2^order hits */
55299 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55300 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55301 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55302 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55303 + atomic_unchecked_t s_bal_goals; /* goal hits */
55304 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55305 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55306 spinlock_t s_bal_lock;
55307 unsigned long s_mb_buddies_generated;
55308 unsigned long long s_mb_generation_time;
55309 - atomic_t s_mb_lost_chunks;
55310 - atomic_t s_mb_preallocated;
55311 - atomic_t s_mb_discarded;
55312 + atomic_unchecked_t s_mb_lost_chunks;
55313 + atomic_unchecked_t s_mb_preallocated;
55314 + atomic_unchecked_t s_mb_discarded;
55315 atomic_t s_lock_busy;
55316
55317 /* locality groups */
55318 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55319 index 4bbbf13b..dcceaeb 100644
55320 --- a/fs/ext4/mballoc.c
55321 +++ b/fs/ext4/mballoc.c
55322 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55323 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55324
55325 if (EXT4_SB(sb)->s_mb_stats)
55326 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55327 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55328
55329 break;
55330 }
55331 @@ -2171,7 +2171,7 @@ repeat:
55332 ac->ac_status = AC_STATUS_CONTINUE;
55333 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55334 cr = 3;
55335 - atomic_inc(&sbi->s_mb_lost_chunks);
55336 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55337 goto repeat;
55338 }
55339 }
55340 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55341 if (sbi->s_mb_stats) {
55342 ext4_msg(sb, KERN_INFO,
55343 "mballoc: %u blocks %u reqs (%u success)",
55344 - atomic_read(&sbi->s_bal_allocated),
55345 - atomic_read(&sbi->s_bal_reqs),
55346 - atomic_read(&sbi->s_bal_success));
55347 + atomic_read_unchecked(&sbi->s_bal_allocated),
55348 + atomic_read_unchecked(&sbi->s_bal_reqs),
55349 + atomic_read_unchecked(&sbi->s_bal_success));
55350 ext4_msg(sb, KERN_INFO,
55351 "mballoc: %u extents scanned, %u goal hits, "
55352 "%u 2^N hits, %u breaks, %u lost",
55353 - atomic_read(&sbi->s_bal_ex_scanned),
55354 - atomic_read(&sbi->s_bal_goals),
55355 - atomic_read(&sbi->s_bal_2orders),
55356 - atomic_read(&sbi->s_bal_breaks),
55357 - atomic_read(&sbi->s_mb_lost_chunks));
55358 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55359 + atomic_read_unchecked(&sbi->s_bal_goals),
55360 + atomic_read_unchecked(&sbi->s_bal_2orders),
55361 + atomic_read_unchecked(&sbi->s_bal_breaks),
55362 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55363 ext4_msg(sb, KERN_INFO,
55364 "mballoc: %lu generated and it took %Lu",
55365 sbi->s_mb_buddies_generated,
55366 sbi->s_mb_generation_time);
55367 ext4_msg(sb, KERN_INFO,
55368 "mballoc: %u preallocated, %u discarded",
55369 - atomic_read(&sbi->s_mb_preallocated),
55370 - atomic_read(&sbi->s_mb_discarded));
55371 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55372 + atomic_read_unchecked(&sbi->s_mb_discarded));
55373 }
55374
55375 free_percpu(sbi->s_locality_groups);
55376 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55377 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55378
55379 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55380 - atomic_inc(&sbi->s_bal_reqs);
55381 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55382 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55383 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55384 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55385 - atomic_inc(&sbi->s_bal_success);
55386 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55387 + atomic_inc_unchecked(&sbi->s_bal_success);
55388 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55389 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55390 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55391 - atomic_inc(&sbi->s_bal_goals);
55392 + atomic_inc_unchecked(&sbi->s_bal_goals);
55393 if (ac->ac_found > sbi->s_mb_max_to_scan)
55394 - atomic_inc(&sbi->s_bal_breaks);
55395 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55396 }
55397
55398 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55399 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55400 trace_ext4_mb_new_inode_pa(ac, pa);
55401
55402 ext4_mb_use_inode_pa(ac, pa);
55403 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55404 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55405
55406 ei = EXT4_I(ac->ac_inode);
55407 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55408 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55409 trace_ext4_mb_new_group_pa(ac, pa);
55410
55411 ext4_mb_use_group_pa(ac, pa);
55412 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55413 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55414
55415 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55416 lg = ac->ac_lg;
55417 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55418 * from the bitmap and continue.
55419 */
55420 }
55421 - atomic_add(free, &sbi->s_mb_discarded);
55422 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55423
55424 return err;
55425 }
55426 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55427 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55428 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55429 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55430 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55431 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55432 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55433
55434 return 0;
55435 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55436 index 214461e..3614c89 100644
55437 --- a/fs/ext4/mmp.c
55438 +++ b/fs/ext4/mmp.c
55439 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55440 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55441 const char *function, unsigned int line, const char *msg)
55442 {
55443 - __ext4_warning(sb, function, line, msg);
55444 + __ext4_warning(sb, function, line, "%s", msg);
55445 __ext4_warning(sb, function, line,
55446 "MMP failure info: last update time: %llu, last update "
55447 "node: %s, last update device: %s\n",
55448 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55449 index b59373b..f41c2b5 100644
55450 --- a/fs/ext4/super.c
55451 +++ b/fs/ext4/super.c
55452 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55453 }
55454
55455 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55456 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55457 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55458 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55459
55460 #ifdef CONFIG_QUOTA
55461 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55462 int offset;
55463 int deprecated_val;
55464 } u;
55465 -};
55466 +} __do_const;
55467
55468 static int parse_strtoull(const char *buf,
55469 unsigned long long max, unsigned long long *value)
55470 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
55471 index c081e34..03e9beb 100644
55472 --- a/fs/ext4/xattr.c
55473 +++ b/fs/ext4/xattr.c
55474 @@ -1350,6 +1350,8 @@ retry:
55475 s_min_extra_isize) {
55476 tried_min_extra_isize++;
55477 new_extra_isize = s_min_extra_isize;
55478 + kfree(is); is = NULL;
55479 + kfree(bs); bs = NULL;
55480 goto retry;
55481 }
55482 error = -1;
55483 diff --git a/fs/fcntl.c b/fs/fcntl.c
55484 index 65343c3..9969dcf 100644
55485 --- a/fs/fcntl.c
55486 +++ b/fs/fcntl.c
55487 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55488 if (err)
55489 return err;
55490
55491 + if (gr_handle_chroot_fowner(pid, type))
55492 + return -ENOENT;
55493 + if (gr_check_protected_task_fowner(pid, type))
55494 + return -EACCES;
55495 +
55496 f_modown(filp, pid, type, force);
55497 return 0;
55498 }
55499 diff --git a/fs/fhandle.c b/fs/fhandle.c
55500 index 999ff5c..41f4109 100644
55501 --- a/fs/fhandle.c
55502 +++ b/fs/fhandle.c
55503 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55504 } else
55505 retval = 0;
55506 /* copy the mount id */
55507 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55508 - sizeof(*mnt_id)) ||
55509 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55510 copy_to_user(ufh, handle,
55511 sizeof(struct file_handle) + handle_bytes))
55512 retval = -EFAULT;
55513 diff --git a/fs/file.c b/fs/file.c
55514 index 4a78f98..9447397 100644
55515 --- a/fs/file.c
55516 +++ b/fs/file.c
55517 @@ -16,6 +16,7 @@
55518 #include <linux/slab.h>
55519 #include <linux/vmalloc.h>
55520 #include <linux/file.h>
55521 +#include <linux/security.h>
55522 #include <linux/fdtable.h>
55523 #include <linux/bitops.h>
55524 #include <linux/interrupt.h>
55525 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55526 if (!file)
55527 return __close_fd(files, fd);
55528
55529 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55530 if (fd >= rlimit(RLIMIT_NOFILE))
55531 return -EBADF;
55532
55533 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55534 if (unlikely(oldfd == newfd))
55535 return -EINVAL;
55536
55537 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55538 if (newfd >= rlimit(RLIMIT_NOFILE))
55539 return -EBADF;
55540
55541 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55542 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55543 {
55544 int err;
55545 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55546 if (from >= rlimit(RLIMIT_NOFILE))
55547 return -EINVAL;
55548 err = alloc_fd(from, flags);
55549 diff --git a/fs/filesystems.c b/fs/filesystems.c
55550 index 92567d9..fcd8cbf 100644
55551 --- a/fs/filesystems.c
55552 +++ b/fs/filesystems.c
55553 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55554 int len = dot ? dot - name : strlen(name);
55555
55556 fs = __get_fs_type(name, len);
55557 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55558 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55559 +#else
55560 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55561 +#endif
55562 fs = __get_fs_type(name, len);
55563
55564 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55565 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55566 index d8ac61d..79a36f0 100644
55567 --- a/fs/fs_struct.c
55568 +++ b/fs/fs_struct.c
55569 @@ -4,6 +4,7 @@
55570 #include <linux/path.h>
55571 #include <linux/slab.h>
55572 #include <linux/fs_struct.h>
55573 +#include <linux/grsecurity.h>
55574 #include "internal.h"
55575
55576 /*
55577 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55578 write_seqcount_begin(&fs->seq);
55579 old_root = fs->root;
55580 fs->root = *path;
55581 + gr_set_chroot_entries(current, path);
55582 write_seqcount_end(&fs->seq);
55583 spin_unlock(&fs->lock);
55584 if (old_root.dentry)
55585 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55586 int hits = 0;
55587 spin_lock(&fs->lock);
55588 write_seqcount_begin(&fs->seq);
55589 + /* this root replacement is only done by pivot_root,
55590 + leave grsec's chroot tagging alone for this task
55591 + so that a pivoted root isn't treated as a chroot
55592 + */
55593 hits += replace_path(&fs->root, old_root, new_root);
55594 hits += replace_path(&fs->pwd, old_root, new_root);
55595 write_seqcount_end(&fs->seq);
55596 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55597 task_lock(tsk);
55598 spin_lock(&fs->lock);
55599 tsk->fs = NULL;
55600 - kill = !--fs->users;
55601 + gr_clear_chroot_entries(tsk);
55602 + kill = !atomic_dec_return(&fs->users);
55603 spin_unlock(&fs->lock);
55604 task_unlock(tsk);
55605 if (kill)
55606 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55607 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55608 /* We don't need to lock fs - think why ;-) */
55609 if (fs) {
55610 - fs->users = 1;
55611 + atomic_set(&fs->users, 1);
55612 fs->in_exec = 0;
55613 spin_lock_init(&fs->lock);
55614 seqcount_init(&fs->seq);
55615 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55616 spin_lock(&old->lock);
55617 fs->root = old->root;
55618 path_get(&fs->root);
55619 + /* instead of calling gr_set_chroot_entries here,
55620 + we call it from every caller of this function
55621 + */
55622 fs->pwd = old->pwd;
55623 path_get(&fs->pwd);
55624 spin_unlock(&old->lock);
55625 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55626
55627 task_lock(current);
55628 spin_lock(&fs->lock);
55629 - kill = !--fs->users;
55630 + kill = !atomic_dec_return(&fs->users);
55631 current->fs = new_fs;
55632 + gr_set_chroot_entries(current, &new_fs->root);
55633 spin_unlock(&fs->lock);
55634 task_unlock(current);
55635
55636 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55637
55638 int current_umask(void)
55639 {
55640 - return current->fs->umask;
55641 + return current->fs->umask | gr_acl_umask();
55642 }
55643 EXPORT_SYMBOL(current_umask);
55644
55645 /* to be mentioned only in INIT_TASK */
55646 struct fs_struct init_fs = {
55647 - .users = 1,
55648 + .users = ATOMIC_INIT(1),
55649 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55650 .seq = SEQCNT_ZERO,
55651 .umask = 0022,
55652 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55653 index 0e91a3c..6c6d2e0 100644
55654 --- a/fs/fscache/cookie.c
55655 +++ b/fs/fscache/cookie.c
55656 @@ -19,7 +19,7 @@
55657
55658 struct kmem_cache *fscache_cookie_jar;
55659
55660 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55661 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55662
55663 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55664 static int fscache_alloc_object(struct fscache_cache *cache,
55665 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55666 parent ? (char *) parent->def->name : "<no-parent>",
55667 def->name, netfs_data);
55668
55669 - fscache_stat(&fscache_n_acquires);
55670 + fscache_stat_unchecked(&fscache_n_acquires);
55671
55672 /* if there's no parent cookie, then we don't create one here either */
55673 if (!parent) {
55674 - fscache_stat(&fscache_n_acquires_null);
55675 + fscache_stat_unchecked(&fscache_n_acquires_null);
55676 _leave(" [no parent]");
55677 return NULL;
55678 }
55679 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55680 /* allocate and initialise a cookie */
55681 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55682 if (!cookie) {
55683 - fscache_stat(&fscache_n_acquires_oom);
55684 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55685 _leave(" [ENOMEM]");
55686 return NULL;
55687 }
55688 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55689
55690 switch (cookie->def->type) {
55691 case FSCACHE_COOKIE_TYPE_INDEX:
55692 - fscache_stat(&fscache_n_cookie_index);
55693 + fscache_stat_unchecked(&fscache_n_cookie_index);
55694 break;
55695 case FSCACHE_COOKIE_TYPE_DATAFILE:
55696 - fscache_stat(&fscache_n_cookie_data);
55697 + fscache_stat_unchecked(&fscache_n_cookie_data);
55698 break;
55699 default:
55700 - fscache_stat(&fscache_n_cookie_special);
55701 + fscache_stat_unchecked(&fscache_n_cookie_special);
55702 break;
55703 }
55704
55705 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55706 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55707 atomic_dec(&parent->n_children);
55708 __fscache_cookie_put(cookie);
55709 - fscache_stat(&fscache_n_acquires_nobufs);
55710 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55711 _leave(" = NULL");
55712 return NULL;
55713 }
55714 }
55715
55716 - fscache_stat(&fscache_n_acquires_ok);
55717 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55718 _leave(" = %p", cookie);
55719 return cookie;
55720 }
55721 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55722 cache = fscache_select_cache_for_object(cookie->parent);
55723 if (!cache) {
55724 up_read(&fscache_addremove_sem);
55725 - fscache_stat(&fscache_n_acquires_no_cache);
55726 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55727 _leave(" = -ENOMEDIUM [no cache]");
55728 return -ENOMEDIUM;
55729 }
55730 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55731 object = cache->ops->alloc_object(cache, cookie);
55732 fscache_stat_d(&fscache_n_cop_alloc_object);
55733 if (IS_ERR(object)) {
55734 - fscache_stat(&fscache_n_object_no_alloc);
55735 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55736 ret = PTR_ERR(object);
55737 goto error;
55738 }
55739
55740 - fscache_stat(&fscache_n_object_alloc);
55741 + fscache_stat_unchecked(&fscache_n_object_alloc);
55742
55743 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55744 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55745
55746 _debug("ALLOC OBJ%x: %s {%lx}",
55747 object->debug_id, cookie->def->name, object->events);
55748 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55749
55750 _enter("{%s}", cookie->def->name);
55751
55752 - fscache_stat(&fscache_n_invalidates);
55753 + fscache_stat_unchecked(&fscache_n_invalidates);
55754
55755 /* Only permit invalidation of data files. Invalidating an index will
55756 * require the caller to release all its attachments to the tree rooted
55757 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
55758 {
55759 struct fscache_object *object;
55760
55761 - fscache_stat(&fscache_n_updates);
55762 + fscache_stat_unchecked(&fscache_n_updates);
55763
55764 if (!cookie) {
55765 - fscache_stat(&fscache_n_updates_null);
55766 + fscache_stat_unchecked(&fscache_n_updates_null);
55767 _leave(" [no cookie]");
55768 return;
55769 }
55770 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
55771 {
55772 struct fscache_object *object;
55773
55774 - fscache_stat(&fscache_n_relinquishes);
55775 + fscache_stat_unchecked(&fscache_n_relinquishes);
55776 if (retire)
55777 - fscache_stat(&fscache_n_relinquishes_retire);
55778 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
55779
55780 if (!cookie) {
55781 - fscache_stat(&fscache_n_relinquishes_null);
55782 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
55783 _leave(" [no cookie]");
55784 return;
55785 }
55786 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
55787 index 12d505b..86473a3 100644
55788 --- a/fs/fscache/internal.h
55789 +++ b/fs/fscache/internal.h
55790 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
55791 * stats.c
55792 */
55793 #ifdef CONFIG_FSCACHE_STATS
55794 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55795 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55796 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55797 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55798
55799 -extern atomic_t fscache_n_op_pend;
55800 -extern atomic_t fscache_n_op_run;
55801 -extern atomic_t fscache_n_op_enqueue;
55802 -extern atomic_t fscache_n_op_deferred_release;
55803 -extern atomic_t fscache_n_op_release;
55804 -extern atomic_t fscache_n_op_gc;
55805 -extern atomic_t fscache_n_op_cancelled;
55806 -extern atomic_t fscache_n_op_rejected;
55807 +extern atomic_unchecked_t fscache_n_op_pend;
55808 +extern atomic_unchecked_t fscache_n_op_run;
55809 +extern atomic_unchecked_t fscache_n_op_enqueue;
55810 +extern atomic_unchecked_t fscache_n_op_deferred_release;
55811 +extern atomic_unchecked_t fscache_n_op_release;
55812 +extern atomic_unchecked_t fscache_n_op_gc;
55813 +extern atomic_unchecked_t fscache_n_op_cancelled;
55814 +extern atomic_unchecked_t fscache_n_op_rejected;
55815
55816 -extern atomic_t fscache_n_attr_changed;
55817 -extern atomic_t fscache_n_attr_changed_ok;
55818 -extern atomic_t fscache_n_attr_changed_nobufs;
55819 -extern atomic_t fscache_n_attr_changed_nomem;
55820 -extern atomic_t fscache_n_attr_changed_calls;
55821 +extern atomic_unchecked_t fscache_n_attr_changed;
55822 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
55823 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
55824 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
55825 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
55826
55827 -extern atomic_t fscache_n_allocs;
55828 -extern atomic_t fscache_n_allocs_ok;
55829 -extern atomic_t fscache_n_allocs_wait;
55830 -extern atomic_t fscache_n_allocs_nobufs;
55831 -extern atomic_t fscache_n_allocs_intr;
55832 -extern atomic_t fscache_n_allocs_object_dead;
55833 -extern atomic_t fscache_n_alloc_ops;
55834 -extern atomic_t fscache_n_alloc_op_waits;
55835 +extern atomic_unchecked_t fscache_n_allocs;
55836 +extern atomic_unchecked_t fscache_n_allocs_ok;
55837 +extern atomic_unchecked_t fscache_n_allocs_wait;
55838 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
55839 +extern atomic_unchecked_t fscache_n_allocs_intr;
55840 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
55841 +extern atomic_unchecked_t fscache_n_alloc_ops;
55842 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
55843
55844 -extern atomic_t fscache_n_retrievals;
55845 -extern atomic_t fscache_n_retrievals_ok;
55846 -extern atomic_t fscache_n_retrievals_wait;
55847 -extern atomic_t fscache_n_retrievals_nodata;
55848 -extern atomic_t fscache_n_retrievals_nobufs;
55849 -extern atomic_t fscache_n_retrievals_intr;
55850 -extern atomic_t fscache_n_retrievals_nomem;
55851 -extern atomic_t fscache_n_retrievals_object_dead;
55852 -extern atomic_t fscache_n_retrieval_ops;
55853 -extern atomic_t fscache_n_retrieval_op_waits;
55854 +extern atomic_unchecked_t fscache_n_retrievals;
55855 +extern atomic_unchecked_t fscache_n_retrievals_ok;
55856 +extern atomic_unchecked_t fscache_n_retrievals_wait;
55857 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
55858 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
55859 +extern atomic_unchecked_t fscache_n_retrievals_intr;
55860 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
55861 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
55862 +extern atomic_unchecked_t fscache_n_retrieval_ops;
55863 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
55864
55865 -extern atomic_t fscache_n_stores;
55866 -extern atomic_t fscache_n_stores_ok;
55867 -extern atomic_t fscache_n_stores_again;
55868 -extern atomic_t fscache_n_stores_nobufs;
55869 -extern atomic_t fscache_n_stores_oom;
55870 -extern atomic_t fscache_n_store_ops;
55871 -extern atomic_t fscache_n_store_calls;
55872 -extern atomic_t fscache_n_store_pages;
55873 -extern atomic_t fscache_n_store_radix_deletes;
55874 -extern atomic_t fscache_n_store_pages_over_limit;
55875 +extern atomic_unchecked_t fscache_n_stores;
55876 +extern atomic_unchecked_t fscache_n_stores_ok;
55877 +extern atomic_unchecked_t fscache_n_stores_again;
55878 +extern atomic_unchecked_t fscache_n_stores_nobufs;
55879 +extern atomic_unchecked_t fscache_n_stores_oom;
55880 +extern atomic_unchecked_t fscache_n_store_ops;
55881 +extern atomic_unchecked_t fscache_n_store_calls;
55882 +extern atomic_unchecked_t fscache_n_store_pages;
55883 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
55884 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
55885
55886 -extern atomic_t fscache_n_store_vmscan_not_storing;
55887 -extern atomic_t fscache_n_store_vmscan_gone;
55888 -extern atomic_t fscache_n_store_vmscan_busy;
55889 -extern atomic_t fscache_n_store_vmscan_cancelled;
55890 -extern atomic_t fscache_n_store_vmscan_wait;
55891 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
55892 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
55893 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
55894 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
55895 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
55896
55897 -extern atomic_t fscache_n_marks;
55898 -extern atomic_t fscache_n_uncaches;
55899 +extern atomic_unchecked_t fscache_n_marks;
55900 +extern atomic_unchecked_t fscache_n_uncaches;
55901
55902 -extern atomic_t fscache_n_acquires;
55903 -extern atomic_t fscache_n_acquires_null;
55904 -extern atomic_t fscache_n_acquires_no_cache;
55905 -extern atomic_t fscache_n_acquires_ok;
55906 -extern atomic_t fscache_n_acquires_nobufs;
55907 -extern atomic_t fscache_n_acquires_oom;
55908 +extern atomic_unchecked_t fscache_n_acquires;
55909 +extern atomic_unchecked_t fscache_n_acquires_null;
55910 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
55911 +extern atomic_unchecked_t fscache_n_acquires_ok;
55912 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
55913 +extern atomic_unchecked_t fscache_n_acquires_oom;
55914
55915 -extern atomic_t fscache_n_invalidates;
55916 -extern atomic_t fscache_n_invalidates_run;
55917 +extern atomic_unchecked_t fscache_n_invalidates;
55918 +extern atomic_unchecked_t fscache_n_invalidates_run;
55919
55920 -extern atomic_t fscache_n_updates;
55921 -extern atomic_t fscache_n_updates_null;
55922 -extern atomic_t fscache_n_updates_run;
55923 +extern atomic_unchecked_t fscache_n_updates;
55924 +extern atomic_unchecked_t fscache_n_updates_null;
55925 +extern atomic_unchecked_t fscache_n_updates_run;
55926
55927 -extern atomic_t fscache_n_relinquishes;
55928 -extern atomic_t fscache_n_relinquishes_null;
55929 -extern atomic_t fscache_n_relinquishes_waitcrt;
55930 -extern atomic_t fscache_n_relinquishes_retire;
55931 +extern atomic_unchecked_t fscache_n_relinquishes;
55932 +extern atomic_unchecked_t fscache_n_relinquishes_null;
55933 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
55934 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
55935
55936 -extern atomic_t fscache_n_cookie_index;
55937 -extern atomic_t fscache_n_cookie_data;
55938 -extern atomic_t fscache_n_cookie_special;
55939 +extern atomic_unchecked_t fscache_n_cookie_index;
55940 +extern atomic_unchecked_t fscache_n_cookie_data;
55941 +extern atomic_unchecked_t fscache_n_cookie_special;
55942
55943 -extern atomic_t fscache_n_object_alloc;
55944 -extern atomic_t fscache_n_object_no_alloc;
55945 -extern atomic_t fscache_n_object_lookups;
55946 -extern atomic_t fscache_n_object_lookups_negative;
55947 -extern atomic_t fscache_n_object_lookups_positive;
55948 -extern atomic_t fscache_n_object_lookups_timed_out;
55949 -extern atomic_t fscache_n_object_created;
55950 -extern atomic_t fscache_n_object_avail;
55951 -extern atomic_t fscache_n_object_dead;
55952 +extern atomic_unchecked_t fscache_n_object_alloc;
55953 +extern atomic_unchecked_t fscache_n_object_no_alloc;
55954 +extern atomic_unchecked_t fscache_n_object_lookups;
55955 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
55956 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
55957 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
55958 +extern atomic_unchecked_t fscache_n_object_created;
55959 +extern atomic_unchecked_t fscache_n_object_avail;
55960 +extern atomic_unchecked_t fscache_n_object_dead;
55961
55962 -extern atomic_t fscache_n_checkaux_none;
55963 -extern atomic_t fscache_n_checkaux_okay;
55964 -extern atomic_t fscache_n_checkaux_update;
55965 -extern atomic_t fscache_n_checkaux_obsolete;
55966 +extern atomic_unchecked_t fscache_n_checkaux_none;
55967 +extern atomic_unchecked_t fscache_n_checkaux_okay;
55968 +extern atomic_unchecked_t fscache_n_checkaux_update;
55969 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
55970
55971 extern atomic_t fscache_n_cop_alloc_object;
55972 extern atomic_t fscache_n_cop_lookup_object;
55973 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
55974 atomic_inc(stat);
55975 }
55976
55977 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
55978 +{
55979 + atomic_inc_unchecked(stat);
55980 +}
55981 +
55982 static inline void fscache_stat_d(atomic_t *stat)
55983 {
55984 atomic_dec(stat);
55985 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
55986
55987 #define __fscache_stat(stat) (NULL)
55988 #define fscache_stat(stat) do {} while (0)
55989 +#define fscache_stat_unchecked(stat) do {} while (0)
55990 #define fscache_stat_d(stat) do {} while (0)
55991 #endif
55992
55993 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
55994 index 86d75a6..5f3d7a0 100644
55995 --- a/fs/fscache/object.c
55996 +++ b/fs/fscache/object.c
55997 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
55998 _debug("LOOKUP \"%s\" in \"%s\"",
55999 cookie->def->name, object->cache->tag->name);
56000
56001 - fscache_stat(&fscache_n_object_lookups);
56002 + fscache_stat_unchecked(&fscache_n_object_lookups);
56003 fscache_stat(&fscache_n_cop_lookup_object);
56004 ret = object->cache->ops->lookup_object(object);
56005 fscache_stat_d(&fscache_n_cop_lookup_object);
56006 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56007 if (ret == -ETIMEDOUT) {
56008 /* probably stuck behind another object, so move this one to
56009 * the back of the queue */
56010 - fscache_stat(&fscache_n_object_lookups_timed_out);
56011 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56012 _leave(" [timeout]");
56013 return NO_TRANSIT;
56014 }
56015 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56016 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56017
56018 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56019 - fscache_stat(&fscache_n_object_lookups_negative);
56020 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56021
56022 /* Allow write requests to begin stacking up and read requests to begin
56023 * returning ENODATA.
56024 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56025 /* if we were still looking up, then we must have a positive lookup
56026 * result, in which case there may be data available */
56027 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56028 - fscache_stat(&fscache_n_object_lookups_positive);
56029 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56030
56031 /* We do (presumably) have data */
56032 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56033 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56034 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56035 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56036 } else {
56037 - fscache_stat(&fscache_n_object_created);
56038 + fscache_stat_unchecked(&fscache_n_object_created);
56039 }
56040
56041 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56042 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56043 fscache_stat_d(&fscache_n_cop_lookup_complete);
56044
56045 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56046 - fscache_stat(&fscache_n_object_avail);
56047 + fscache_stat_unchecked(&fscache_n_object_avail);
56048
56049 _leave("");
56050 return transit_to(JUMPSTART_DEPS);
56051 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56052
56053 /* this just shifts the object release to the work processor */
56054 fscache_put_object(object);
56055 - fscache_stat(&fscache_n_object_dead);
56056 + fscache_stat_unchecked(&fscache_n_object_dead);
56057
56058 _leave("");
56059 return transit_to(OBJECT_DEAD);
56060 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56061 enum fscache_checkaux result;
56062
56063 if (!object->cookie->def->check_aux) {
56064 - fscache_stat(&fscache_n_checkaux_none);
56065 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56066 return FSCACHE_CHECKAUX_OKAY;
56067 }
56068
56069 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56070 switch (result) {
56071 /* entry okay as is */
56072 case FSCACHE_CHECKAUX_OKAY:
56073 - fscache_stat(&fscache_n_checkaux_okay);
56074 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56075 break;
56076
56077 /* entry requires update */
56078 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56079 - fscache_stat(&fscache_n_checkaux_update);
56080 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56081 break;
56082
56083 /* entry requires deletion */
56084 case FSCACHE_CHECKAUX_OBSOLETE:
56085 - fscache_stat(&fscache_n_checkaux_obsolete);
56086 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56087 break;
56088
56089 default:
56090 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56091 {
56092 const struct fscache_state *s;
56093
56094 - fscache_stat(&fscache_n_invalidates_run);
56095 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56096 fscache_stat(&fscache_n_cop_invalidate_object);
56097 s = _fscache_invalidate_object(object, event);
56098 fscache_stat_d(&fscache_n_cop_invalidate_object);
56099 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56100 {
56101 _enter("{OBJ%x},%d", object->debug_id, event);
56102
56103 - fscache_stat(&fscache_n_updates_run);
56104 + fscache_stat_unchecked(&fscache_n_updates_run);
56105 fscache_stat(&fscache_n_cop_update_object);
56106 object->cache->ops->update_object(object);
56107 fscache_stat_d(&fscache_n_cop_update_object);
56108 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56109 index 318071a..379938b 100644
56110 --- a/fs/fscache/operation.c
56111 +++ b/fs/fscache/operation.c
56112 @@ -17,7 +17,7 @@
56113 #include <linux/slab.h>
56114 #include "internal.h"
56115
56116 -atomic_t fscache_op_debug_id;
56117 +atomic_unchecked_t fscache_op_debug_id;
56118 EXPORT_SYMBOL(fscache_op_debug_id);
56119
56120 /**
56121 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56122 ASSERTCMP(atomic_read(&op->usage), >, 0);
56123 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56124
56125 - fscache_stat(&fscache_n_op_enqueue);
56126 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56127 switch (op->flags & FSCACHE_OP_TYPE) {
56128 case FSCACHE_OP_ASYNC:
56129 _debug("queue async");
56130 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56131 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56132 if (op->processor)
56133 fscache_enqueue_operation(op);
56134 - fscache_stat(&fscache_n_op_run);
56135 + fscache_stat_unchecked(&fscache_n_op_run);
56136 }
56137
56138 /*
56139 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56140 if (object->n_in_progress > 0) {
56141 atomic_inc(&op->usage);
56142 list_add_tail(&op->pend_link, &object->pending_ops);
56143 - fscache_stat(&fscache_n_op_pend);
56144 + fscache_stat_unchecked(&fscache_n_op_pend);
56145 } else if (!list_empty(&object->pending_ops)) {
56146 atomic_inc(&op->usage);
56147 list_add_tail(&op->pend_link, &object->pending_ops);
56148 - fscache_stat(&fscache_n_op_pend);
56149 + fscache_stat_unchecked(&fscache_n_op_pend);
56150 fscache_start_operations(object);
56151 } else {
56152 ASSERTCMP(object->n_in_progress, ==, 0);
56153 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56154 object->n_exclusive++; /* reads and writes must wait */
56155 atomic_inc(&op->usage);
56156 list_add_tail(&op->pend_link, &object->pending_ops);
56157 - fscache_stat(&fscache_n_op_pend);
56158 + fscache_stat_unchecked(&fscache_n_op_pend);
56159 ret = 0;
56160 } else {
56161 /* If we're in any other state, there must have been an I/O
56162 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56163 if (object->n_exclusive > 0) {
56164 atomic_inc(&op->usage);
56165 list_add_tail(&op->pend_link, &object->pending_ops);
56166 - fscache_stat(&fscache_n_op_pend);
56167 + fscache_stat_unchecked(&fscache_n_op_pend);
56168 } else if (!list_empty(&object->pending_ops)) {
56169 atomic_inc(&op->usage);
56170 list_add_tail(&op->pend_link, &object->pending_ops);
56171 - fscache_stat(&fscache_n_op_pend);
56172 + fscache_stat_unchecked(&fscache_n_op_pend);
56173 fscache_start_operations(object);
56174 } else {
56175 ASSERTCMP(object->n_exclusive, ==, 0);
56176 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56177 object->n_ops++;
56178 atomic_inc(&op->usage);
56179 list_add_tail(&op->pend_link, &object->pending_ops);
56180 - fscache_stat(&fscache_n_op_pend);
56181 + fscache_stat_unchecked(&fscache_n_op_pend);
56182 ret = 0;
56183 } else if (fscache_object_is_dying(object)) {
56184 - fscache_stat(&fscache_n_op_rejected);
56185 + fscache_stat_unchecked(&fscache_n_op_rejected);
56186 op->state = FSCACHE_OP_ST_CANCELLED;
56187 ret = -ENOBUFS;
56188 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56189 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56190 ret = -EBUSY;
56191 if (op->state == FSCACHE_OP_ST_PENDING) {
56192 ASSERT(!list_empty(&op->pend_link));
56193 - fscache_stat(&fscache_n_op_cancelled);
56194 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56195 list_del_init(&op->pend_link);
56196 if (do_cancel)
56197 do_cancel(op);
56198 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56199 while (!list_empty(&object->pending_ops)) {
56200 op = list_entry(object->pending_ops.next,
56201 struct fscache_operation, pend_link);
56202 - fscache_stat(&fscache_n_op_cancelled);
56203 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56204 list_del_init(&op->pend_link);
56205
56206 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56207 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56208 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56209 op->state = FSCACHE_OP_ST_DEAD;
56210
56211 - fscache_stat(&fscache_n_op_release);
56212 + fscache_stat_unchecked(&fscache_n_op_release);
56213
56214 if (op->release) {
56215 op->release(op);
56216 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56217 * lock, and defer it otherwise */
56218 if (!spin_trylock(&object->lock)) {
56219 _debug("defer put");
56220 - fscache_stat(&fscache_n_op_deferred_release);
56221 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56222
56223 cache = object->cache;
56224 spin_lock(&cache->op_gc_list_lock);
56225 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56226
56227 _debug("GC DEFERRED REL OBJ%x OP%x",
56228 object->debug_id, op->debug_id);
56229 - fscache_stat(&fscache_n_op_gc);
56230 + fscache_stat_unchecked(&fscache_n_op_gc);
56231
56232 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56233 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56234 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56235 index d479ab3..727a7f2 100644
56236 --- a/fs/fscache/page.c
56237 +++ b/fs/fscache/page.c
56238 @@ -61,7 +61,7 @@ try_again:
56239 val = radix_tree_lookup(&cookie->stores, page->index);
56240 if (!val) {
56241 rcu_read_unlock();
56242 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56243 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56244 __fscache_uncache_page(cookie, page);
56245 return true;
56246 }
56247 @@ -91,11 +91,11 @@ try_again:
56248 spin_unlock(&cookie->stores_lock);
56249
56250 if (xpage) {
56251 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56252 - fscache_stat(&fscache_n_store_radix_deletes);
56253 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56254 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56255 ASSERTCMP(xpage, ==, page);
56256 } else {
56257 - fscache_stat(&fscache_n_store_vmscan_gone);
56258 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56259 }
56260
56261 wake_up_bit(&cookie->flags, 0);
56262 @@ -110,11 +110,11 @@ page_busy:
56263 * sleeping on memory allocation, so we may need to impose a timeout
56264 * too. */
56265 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56266 - fscache_stat(&fscache_n_store_vmscan_busy);
56267 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56268 return false;
56269 }
56270
56271 - fscache_stat(&fscache_n_store_vmscan_wait);
56272 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56273 __fscache_wait_on_page_write(cookie, page);
56274 gfp &= ~__GFP_WAIT;
56275 goto try_again;
56276 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56277 FSCACHE_COOKIE_STORING_TAG);
56278 if (!radix_tree_tag_get(&cookie->stores, page->index,
56279 FSCACHE_COOKIE_PENDING_TAG)) {
56280 - fscache_stat(&fscache_n_store_radix_deletes);
56281 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56282 xpage = radix_tree_delete(&cookie->stores, page->index);
56283 }
56284 spin_unlock(&cookie->stores_lock);
56285 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56286
56287 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56288
56289 - fscache_stat(&fscache_n_attr_changed_calls);
56290 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56291
56292 if (fscache_object_is_active(object) &&
56293 fscache_use_cookie(object)) {
56294 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56295
56296 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56297
56298 - fscache_stat(&fscache_n_attr_changed);
56299 + fscache_stat_unchecked(&fscache_n_attr_changed);
56300
56301 op = kzalloc(sizeof(*op), GFP_KERNEL);
56302 if (!op) {
56303 - fscache_stat(&fscache_n_attr_changed_nomem);
56304 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56305 _leave(" = -ENOMEM");
56306 return -ENOMEM;
56307 }
56308 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56309 if (fscache_submit_exclusive_op(object, op) < 0)
56310 goto nobufs;
56311 spin_unlock(&cookie->lock);
56312 - fscache_stat(&fscache_n_attr_changed_ok);
56313 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56314 fscache_put_operation(op);
56315 _leave(" = 0");
56316 return 0;
56317 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56318 nobufs:
56319 spin_unlock(&cookie->lock);
56320 kfree(op);
56321 - fscache_stat(&fscache_n_attr_changed_nobufs);
56322 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56323 _leave(" = %d", -ENOBUFS);
56324 return -ENOBUFS;
56325 }
56326 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56327 /* allocate a retrieval operation and attempt to submit it */
56328 op = kzalloc(sizeof(*op), GFP_NOIO);
56329 if (!op) {
56330 - fscache_stat(&fscache_n_retrievals_nomem);
56331 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56332 return NULL;
56333 }
56334
56335 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56336 return 0;
56337 }
56338
56339 - fscache_stat(&fscache_n_retrievals_wait);
56340 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56341
56342 jif = jiffies;
56343 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56344 fscache_wait_bit_interruptible,
56345 TASK_INTERRUPTIBLE) != 0) {
56346 - fscache_stat(&fscache_n_retrievals_intr);
56347 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56348 _leave(" = -ERESTARTSYS");
56349 return -ERESTARTSYS;
56350 }
56351 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56352 */
56353 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56354 struct fscache_retrieval *op,
56355 - atomic_t *stat_op_waits,
56356 - atomic_t *stat_object_dead)
56357 + atomic_unchecked_t *stat_op_waits,
56358 + atomic_unchecked_t *stat_object_dead)
56359 {
56360 int ret;
56361
56362 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56363 goto check_if_dead;
56364
56365 _debug(">>> WT");
56366 - fscache_stat(stat_op_waits);
56367 + fscache_stat_unchecked(stat_op_waits);
56368 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56369 fscache_wait_bit_interruptible,
56370 TASK_INTERRUPTIBLE) != 0) {
56371 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56372
56373 check_if_dead:
56374 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56375 - fscache_stat(stat_object_dead);
56376 + fscache_stat_unchecked(stat_object_dead);
56377 _leave(" = -ENOBUFS [cancelled]");
56378 return -ENOBUFS;
56379 }
56380 if (unlikely(fscache_object_is_dead(object))) {
56381 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56382 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56383 - fscache_stat(stat_object_dead);
56384 + fscache_stat_unchecked(stat_object_dead);
56385 return -ENOBUFS;
56386 }
56387 return 0;
56388 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56389
56390 _enter("%p,%p,,,", cookie, page);
56391
56392 - fscache_stat(&fscache_n_retrievals);
56393 + fscache_stat_unchecked(&fscache_n_retrievals);
56394
56395 if (hlist_empty(&cookie->backing_objects))
56396 goto nobufs;
56397 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56398 goto nobufs_unlock_dec;
56399 spin_unlock(&cookie->lock);
56400
56401 - fscache_stat(&fscache_n_retrieval_ops);
56402 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56403
56404 /* pin the netfs read context in case we need to do the actual netfs
56405 * read because we've encountered a cache read failure */
56406 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56407
56408 error:
56409 if (ret == -ENOMEM)
56410 - fscache_stat(&fscache_n_retrievals_nomem);
56411 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56412 else if (ret == -ERESTARTSYS)
56413 - fscache_stat(&fscache_n_retrievals_intr);
56414 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56415 else if (ret == -ENODATA)
56416 - fscache_stat(&fscache_n_retrievals_nodata);
56417 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56418 else if (ret < 0)
56419 - fscache_stat(&fscache_n_retrievals_nobufs);
56420 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56421 else
56422 - fscache_stat(&fscache_n_retrievals_ok);
56423 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56424
56425 fscache_put_retrieval(op);
56426 _leave(" = %d", ret);
56427 @@ -475,7 +475,7 @@ nobufs_unlock:
56428 atomic_dec(&cookie->n_active);
56429 kfree(op);
56430 nobufs:
56431 - fscache_stat(&fscache_n_retrievals_nobufs);
56432 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56433 _leave(" = -ENOBUFS");
56434 return -ENOBUFS;
56435 }
56436 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56437
56438 _enter("%p,,%d,,,", cookie, *nr_pages);
56439
56440 - fscache_stat(&fscache_n_retrievals);
56441 + fscache_stat_unchecked(&fscache_n_retrievals);
56442
56443 if (hlist_empty(&cookie->backing_objects))
56444 goto nobufs;
56445 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56446 goto nobufs_unlock_dec;
56447 spin_unlock(&cookie->lock);
56448
56449 - fscache_stat(&fscache_n_retrieval_ops);
56450 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56451
56452 /* pin the netfs read context in case we need to do the actual netfs
56453 * read because we've encountered a cache read failure */
56454 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56455
56456 error:
56457 if (ret == -ENOMEM)
56458 - fscache_stat(&fscache_n_retrievals_nomem);
56459 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56460 else if (ret == -ERESTARTSYS)
56461 - fscache_stat(&fscache_n_retrievals_intr);
56462 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56463 else if (ret == -ENODATA)
56464 - fscache_stat(&fscache_n_retrievals_nodata);
56465 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56466 else if (ret < 0)
56467 - fscache_stat(&fscache_n_retrievals_nobufs);
56468 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56469 else
56470 - fscache_stat(&fscache_n_retrievals_ok);
56471 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56472
56473 fscache_put_retrieval(op);
56474 _leave(" = %d", ret);
56475 @@ -600,7 +600,7 @@ nobufs_unlock:
56476 atomic_dec(&cookie->n_active);
56477 kfree(op);
56478 nobufs:
56479 - fscache_stat(&fscache_n_retrievals_nobufs);
56480 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56481 _leave(" = -ENOBUFS");
56482 return -ENOBUFS;
56483 }
56484 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56485
56486 _enter("%p,%p,,,", cookie, page);
56487
56488 - fscache_stat(&fscache_n_allocs);
56489 + fscache_stat_unchecked(&fscache_n_allocs);
56490
56491 if (hlist_empty(&cookie->backing_objects))
56492 goto nobufs;
56493 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56494 goto nobufs_unlock;
56495 spin_unlock(&cookie->lock);
56496
56497 - fscache_stat(&fscache_n_alloc_ops);
56498 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56499
56500 ret = fscache_wait_for_retrieval_activation(
56501 object, op,
56502 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56503
56504 error:
56505 if (ret == -ERESTARTSYS)
56506 - fscache_stat(&fscache_n_allocs_intr);
56507 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56508 else if (ret < 0)
56509 - fscache_stat(&fscache_n_allocs_nobufs);
56510 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56511 else
56512 - fscache_stat(&fscache_n_allocs_ok);
56513 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56514
56515 fscache_put_retrieval(op);
56516 _leave(" = %d", ret);
56517 @@ -687,7 +687,7 @@ nobufs_unlock:
56518 atomic_dec(&cookie->n_active);
56519 kfree(op);
56520 nobufs:
56521 - fscache_stat(&fscache_n_allocs_nobufs);
56522 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56523 _leave(" = -ENOBUFS");
56524 return -ENOBUFS;
56525 }
56526 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56527
56528 spin_lock(&cookie->stores_lock);
56529
56530 - fscache_stat(&fscache_n_store_calls);
56531 + fscache_stat_unchecked(&fscache_n_store_calls);
56532
56533 /* find a page to store */
56534 page = NULL;
56535 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56536 page = results[0];
56537 _debug("gang %d [%lx]", n, page->index);
56538 if (page->index > op->store_limit) {
56539 - fscache_stat(&fscache_n_store_pages_over_limit);
56540 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56541 goto superseded;
56542 }
56543
56544 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56545 spin_unlock(&cookie->stores_lock);
56546 spin_unlock(&object->lock);
56547
56548 - fscache_stat(&fscache_n_store_pages);
56549 + fscache_stat_unchecked(&fscache_n_store_pages);
56550 fscache_stat(&fscache_n_cop_write_page);
56551 ret = object->cache->ops->write_page(op, page);
56552 fscache_stat_d(&fscache_n_cop_write_page);
56553 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56554 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56555 ASSERT(PageFsCache(page));
56556
56557 - fscache_stat(&fscache_n_stores);
56558 + fscache_stat_unchecked(&fscache_n_stores);
56559
56560 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56561 _leave(" = -ENOBUFS [invalidating]");
56562 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56563 spin_unlock(&cookie->stores_lock);
56564 spin_unlock(&object->lock);
56565
56566 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56567 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56568 op->store_limit = object->store_limit;
56569
56570 atomic_inc(&cookie->n_active);
56571 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56572
56573 spin_unlock(&cookie->lock);
56574 radix_tree_preload_end();
56575 - fscache_stat(&fscache_n_store_ops);
56576 - fscache_stat(&fscache_n_stores_ok);
56577 + fscache_stat_unchecked(&fscache_n_store_ops);
56578 + fscache_stat_unchecked(&fscache_n_stores_ok);
56579
56580 /* the work queue now carries its own ref on the object */
56581 fscache_put_operation(&op->op);
56582 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56583 return 0;
56584
56585 already_queued:
56586 - fscache_stat(&fscache_n_stores_again);
56587 + fscache_stat_unchecked(&fscache_n_stores_again);
56588 already_pending:
56589 spin_unlock(&cookie->stores_lock);
56590 spin_unlock(&object->lock);
56591 spin_unlock(&cookie->lock);
56592 radix_tree_preload_end();
56593 kfree(op);
56594 - fscache_stat(&fscache_n_stores_ok);
56595 + fscache_stat_unchecked(&fscache_n_stores_ok);
56596 _leave(" = 0");
56597 return 0;
56598
56599 @@ -976,14 +976,14 @@ nobufs:
56600 spin_unlock(&cookie->lock);
56601 radix_tree_preload_end();
56602 kfree(op);
56603 - fscache_stat(&fscache_n_stores_nobufs);
56604 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56605 _leave(" = -ENOBUFS");
56606 return -ENOBUFS;
56607
56608 nomem_free:
56609 kfree(op);
56610 nomem:
56611 - fscache_stat(&fscache_n_stores_oom);
56612 + fscache_stat_unchecked(&fscache_n_stores_oom);
56613 _leave(" = -ENOMEM");
56614 return -ENOMEM;
56615 }
56616 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56617 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56618 ASSERTCMP(page, !=, NULL);
56619
56620 - fscache_stat(&fscache_n_uncaches);
56621 + fscache_stat_unchecked(&fscache_n_uncaches);
56622
56623 /* cache withdrawal may beat us to it */
56624 if (!PageFsCache(page))
56625 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56626 struct fscache_cookie *cookie = op->op.object->cookie;
56627
56628 #ifdef CONFIG_FSCACHE_STATS
56629 - atomic_inc(&fscache_n_marks);
56630 + atomic_inc_unchecked(&fscache_n_marks);
56631 #endif
56632
56633 _debug("- mark %p{%lx}", page, page->index);
56634 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56635 index 40d13c7..ddf52b9 100644
56636 --- a/fs/fscache/stats.c
56637 +++ b/fs/fscache/stats.c
56638 @@ -18,99 +18,99 @@
56639 /*
56640 * operation counters
56641 */
56642 -atomic_t fscache_n_op_pend;
56643 -atomic_t fscache_n_op_run;
56644 -atomic_t fscache_n_op_enqueue;
56645 -atomic_t fscache_n_op_requeue;
56646 -atomic_t fscache_n_op_deferred_release;
56647 -atomic_t fscache_n_op_release;
56648 -atomic_t fscache_n_op_gc;
56649 -atomic_t fscache_n_op_cancelled;
56650 -atomic_t fscache_n_op_rejected;
56651 +atomic_unchecked_t fscache_n_op_pend;
56652 +atomic_unchecked_t fscache_n_op_run;
56653 +atomic_unchecked_t fscache_n_op_enqueue;
56654 +atomic_unchecked_t fscache_n_op_requeue;
56655 +atomic_unchecked_t fscache_n_op_deferred_release;
56656 +atomic_unchecked_t fscache_n_op_release;
56657 +atomic_unchecked_t fscache_n_op_gc;
56658 +atomic_unchecked_t fscache_n_op_cancelled;
56659 +atomic_unchecked_t fscache_n_op_rejected;
56660
56661 -atomic_t fscache_n_attr_changed;
56662 -atomic_t fscache_n_attr_changed_ok;
56663 -atomic_t fscache_n_attr_changed_nobufs;
56664 -atomic_t fscache_n_attr_changed_nomem;
56665 -atomic_t fscache_n_attr_changed_calls;
56666 +atomic_unchecked_t fscache_n_attr_changed;
56667 +atomic_unchecked_t fscache_n_attr_changed_ok;
56668 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56669 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56670 +atomic_unchecked_t fscache_n_attr_changed_calls;
56671
56672 -atomic_t fscache_n_allocs;
56673 -atomic_t fscache_n_allocs_ok;
56674 -atomic_t fscache_n_allocs_wait;
56675 -atomic_t fscache_n_allocs_nobufs;
56676 -atomic_t fscache_n_allocs_intr;
56677 -atomic_t fscache_n_allocs_object_dead;
56678 -atomic_t fscache_n_alloc_ops;
56679 -atomic_t fscache_n_alloc_op_waits;
56680 +atomic_unchecked_t fscache_n_allocs;
56681 +atomic_unchecked_t fscache_n_allocs_ok;
56682 +atomic_unchecked_t fscache_n_allocs_wait;
56683 +atomic_unchecked_t fscache_n_allocs_nobufs;
56684 +atomic_unchecked_t fscache_n_allocs_intr;
56685 +atomic_unchecked_t fscache_n_allocs_object_dead;
56686 +atomic_unchecked_t fscache_n_alloc_ops;
56687 +atomic_unchecked_t fscache_n_alloc_op_waits;
56688
56689 -atomic_t fscache_n_retrievals;
56690 -atomic_t fscache_n_retrievals_ok;
56691 -atomic_t fscache_n_retrievals_wait;
56692 -atomic_t fscache_n_retrievals_nodata;
56693 -atomic_t fscache_n_retrievals_nobufs;
56694 -atomic_t fscache_n_retrievals_intr;
56695 -atomic_t fscache_n_retrievals_nomem;
56696 -atomic_t fscache_n_retrievals_object_dead;
56697 -atomic_t fscache_n_retrieval_ops;
56698 -atomic_t fscache_n_retrieval_op_waits;
56699 +atomic_unchecked_t fscache_n_retrievals;
56700 +atomic_unchecked_t fscache_n_retrievals_ok;
56701 +atomic_unchecked_t fscache_n_retrievals_wait;
56702 +atomic_unchecked_t fscache_n_retrievals_nodata;
56703 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56704 +atomic_unchecked_t fscache_n_retrievals_intr;
56705 +atomic_unchecked_t fscache_n_retrievals_nomem;
56706 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56707 +atomic_unchecked_t fscache_n_retrieval_ops;
56708 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56709
56710 -atomic_t fscache_n_stores;
56711 -atomic_t fscache_n_stores_ok;
56712 -atomic_t fscache_n_stores_again;
56713 -atomic_t fscache_n_stores_nobufs;
56714 -atomic_t fscache_n_stores_oom;
56715 -atomic_t fscache_n_store_ops;
56716 -atomic_t fscache_n_store_calls;
56717 -atomic_t fscache_n_store_pages;
56718 -atomic_t fscache_n_store_radix_deletes;
56719 -atomic_t fscache_n_store_pages_over_limit;
56720 +atomic_unchecked_t fscache_n_stores;
56721 +atomic_unchecked_t fscache_n_stores_ok;
56722 +atomic_unchecked_t fscache_n_stores_again;
56723 +atomic_unchecked_t fscache_n_stores_nobufs;
56724 +atomic_unchecked_t fscache_n_stores_oom;
56725 +atomic_unchecked_t fscache_n_store_ops;
56726 +atomic_unchecked_t fscache_n_store_calls;
56727 +atomic_unchecked_t fscache_n_store_pages;
56728 +atomic_unchecked_t fscache_n_store_radix_deletes;
56729 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56730
56731 -atomic_t fscache_n_store_vmscan_not_storing;
56732 -atomic_t fscache_n_store_vmscan_gone;
56733 -atomic_t fscache_n_store_vmscan_busy;
56734 -atomic_t fscache_n_store_vmscan_cancelled;
56735 -atomic_t fscache_n_store_vmscan_wait;
56736 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56737 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56738 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56739 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56740 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56741
56742 -atomic_t fscache_n_marks;
56743 -atomic_t fscache_n_uncaches;
56744 +atomic_unchecked_t fscache_n_marks;
56745 +atomic_unchecked_t fscache_n_uncaches;
56746
56747 -atomic_t fscache_n_acquires;
56748 -atomic_t fscache_n_acquires_null;
56749 -atomic_t fscache_n_acquires_no_cache;
56750 -atomic_t fscache_n_acquires_ok;
56751 -atomic_t fscache_n_acquires_nobufs;
56752 -atomic_t fscache_n_acquires_oom;
56753 +atomic_unchecked_t fscache_n_acquires;
56754 +atomic_unchecked_t fscache_n_acquires_null;
56755 +atomic_unchecked_t fscache_n_acquires_no_cache;
56756 +atomic_unchecked_t fscache_n_acquires_ok;
56757 +atomic_unchecked_t fscache_n_acquires_nobufs;
56758 +atomic_unchecked_t fscache_n_acquires_oom;
56759
56760 -atomic_t fscache_n_invalidates;
56761 -atomic_t fscache_n_invalidates_run;
56762 +atomic_unchecked_t fscache_n_invalidates;
56763 +atomic_unchecked_t fscache_n_invalidates_run;
56764
56765 -atomic_t fscache_n_updates;
56766 -atomic_t fscache_n_updates_null;
56767 -atomic_t fscache_n_updates_run;
56768 +atomic_unchecked_t fscache_n_updates;
56769 +atomic_unchecked_t fscache_n_updates_null;
56770 +atomic_unchecked_t fscache_n_updates_run;
56771
56772 -atomic_t fscache_n_relinquishes;
56773 -atomic_t fscache_n_relinquishes_null;
56774 -atomic_t fscache_n_relinquishes_waitcrt;
56775 -atomic_t fscache_n_relinquishes_retire;
56776 +atomic_unchecked_t fscache_n_relinquishes;
56777 +atomic_unchecked_t fscache_n_relinquishes_null;
56778 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56779 +atomic_unchecked_t fscache_n_relinquishes_retire;
56780
56781 -atomic_t fscache_n_cookie_index;
56782 -atomic_t fscache_n_cookie_data;
56783 -atomic_t fscache_n_cookie_special;
56784 +atomic_unchecked_t fscache_n_cookie_index;
56785 +atomic_unchecked_t fscache_n_cookie_data;
56786 +atomic_unchecked_t fscache_n_cookie_special;
56787
56788 -atomic_t fscache_n_object_alloc;
56789 -atomic_t fscache_n_object_no_alloc;
56790 -atomic_t fscache_n_object_lookups;
56791 -atomic_t fscache_n_object_lookups_negative;
56792 -atomic_t fscache_n_object_lookups_positive;
56793 -atomic_t fscache_n_object_lookups_timed_out;
56794 -atomic_t fscache_n_object_created;
56795 -atomic_t fscache_n_object_avail;
56796 -atomic_t fscache_n_object_dead;
56797 +atomic_unchecked_t fscache_n_object_alloc;
56798 +atomic_unchecked_t fscache_n_object_no_alloc;
56799 +atomic_unchecked_t fscache_n_object_lookups;
56800 +atomic_unchecked_t fscache_n_object_lookups_negative;
56801 +atomic_unchecked_t fscache_n_object_lookups_positive;
56802 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
56803 +atomic_unchecked_t fscache_n_object_created;
56804 +atomic_unchecked_t fscache_n_object_avail;
56805 +atomic_unchecked_t fscache_n_object_dead;
56806
56807 -atomic_t fscache_n_checkaux_none;
56808 -atomic_t fscache_n_checkaux_okay;
56809 -atomic_t fscache_n_checkaux_update;
56810 -atomic_t fscache_n_checkaux_obsolete;
56811 +atomic_unchecked_t fscache_n_checkaux_none;
56812 +atomic_unchecked_t fscache_n_checkaux_okay;
56813 +atomic_unchecked_t fscache_n_checkaux_update;
56814 +atomic_unchecked_t fscache_n_checkaux_obsolete;
56815
56816 atomic_t fscache_n_cop_alloc_object;
56817 atomic_t fscache_n_cop_lookup_object;
56818 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
56819 seq_puts(m, "FS-Cache statistics\n");
56820
56821 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
56822 - atomic_read(&fscache_n_cookie_index),
56823 - atomic_read(&fscache_n_cookie_data),
56824 - atomic_read(&fscache_n_cookie_special));
56825 + atomic_read_unchecked(&fscache_n_cookie_index),
56826 + atomic_read_unchecked(&fscache_n_cookie_data),
56827 + atomic_read_unchecked(&fscache_n_cookie_special));
56828
56829 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
56830 - atomic_read(&fscache_n_object_alloc),
56831 - atomic_read(&fscache_n_object_no_alloc),
56832 - atomic_read(&fscache_n_object_avail),
56833 - atomic_read(&fscache_n_object_dead));
56834 + atomic_read_unchecked(&fscache_n_object_alloc),
56835 + atomic_read_unchecked(&fscache_n_object_no_alloc),
56836 + atomic_read_unchecked(&fscache_n_object_avail),
56837 + atomic_read_unchecked(&fscache_n_object_dead));
56838 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
56839 - atomic_read(&fscache_n_checkaux_none),
56840 - atomic_read(&fscache_n_checkaux_okay),
56841 - atomic_read(&fscache_n_checkaux_update),
56842 - atomic_read(&fscache_n_checkaux_obsolete));
56843 + atomic_read_unchecked(&fscache_n_checkaux_none),
56844 + atomic_read_unchecked(&fscache_n_checkaux_okay),
56845 + atomic_read_unchecked(&fscache_n_checkaux_update),
56846 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
56847
56848 seq_printf(m, "Pages : mrk=%u unc=%u\n",
56849 - atomic_read(&fscache_n_marks),
56850 - atomic_read(&fscache_n_uncaches));
56851 + atomic_read_unchecked(&fscache_n_marks),
56852 + atomic_read_unchecked(&fscache_n_uncaches));
56853
56854 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
56855 " oom=%u\n",
56856 - atomic_read(&fscache_n_acquires),
56857 - atomic_read(&fscache_n_acquires_null),
56858 - atomic_read(&fscache_n_acquires_no_cache),
56859 - atomic_read(&fscache_n_acquires_ok),
56860 - atomic_read(&fscache_n_acquires_nobufs),
56861 - atomic_read(&fscache_n_acquires_oom));
56862 + atomic_read_unchecked(&fscache_n_acquires),
56863 + atomic_read_unchecked(&fscache_n_acquires_null),
56864 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
56865 + atomic_read_unchecked(&fscache_n_acquires_ok),
56866 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
56867 + atomic_read_unchecked(&fscache_n_acquires_oom));
56868
56869 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
56870 - atomic_read(&fscache_n_object_lookups),
56871 - atomic_read(&fscache_n_object_lookups_negative),
56872 - atomic_read(&fscache_n_object_lookups_positive),
56873 - atomic_read(&fscache_n_object_created),
56874 - atomic_read(&fscache_n_object_lookups_timed_out));
56875 + atomic_read_unchecked(&fscache_n_object_lookups),
56876 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
56877 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
56878 + atomic_read_unchecked(&fscache_n_object_created),
56879 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
56880
56881 seq_printf(m, "Invals : n=%u run=%u\n",
56882 - atomic_read(&fscache_n_invalidates),
56883 - atomic_read(&fscache_n_invalidates_run));
56884 + atomic_read_unchecked(&fscache_n_invalidates),
56885 + atomic_read_unchecked(&fscache_n_invalidates_run));
56886
56887 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
56888 - atomic_read(&fscache_n_updates),
56889 - atomic_read(&fscache_n_updates_null),
56890 - atomic_read(&fscache_n_updates_run));
56891 + atomic_read_unchecked(&fscache_n_updates),
56892 + atomic_read_unchecked(&fscache_n_updates_null),
56893 + atomic_read_unchecked(&fscache_n_updates_run));
56894
56895 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
56896 - atomic_read(&fscache_n_relinquishes),
56897 - atomic_read(&fscache_n_relinquishes_null),
56898 - atomic_read(&fscache_n_relinquishes_waitcrt),
56899 - atomic_read(&fscache_n_relinquishes_retire));
56900 + atomic_read_unchecked(&fscache_n_relinquishes),
56901 + atomic_read_unchecked(&fscache_n_relinquishes_null),
56902 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
56903 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
56904
56905 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
56906 - atomic_read(&fscache_n_attr_changed),
56907 - atomic_read(&fscache_n_attr_changed_ok),
56908 - atomic_read(&fscache_n_attr_changed_nobufs),
56909 - atomic_read(&fscache_n_attr_changed_nomem),
56910 - atomic_read(&fscache_n_attr_changed_calls));
56911 + atomic_read_unchecked(&fscache_n_attr_changed),
56912 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
56913 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
56914 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
56915 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
56916
56917 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
56918 - atomic_read(&fscache_n_allocs),
56919 - atomic_read(&fscache_n_allocs_ok),
56920 - atomic_read(&fscache_n_allocs_wait),
56921 - atomic_read(&fscache_n_allocs_nobufs),
56922 - atomic_read(&fscache_n_allocs_intr));
56923 + atomic_read_unchecked(&fscache_n_allocs),
56924 + atomic_read_unchecked(&fscache_n_allocs_ok),
56925 + atomic_read_unchecked(&fscache_n_allocs_wait),
56926 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
56927 + atomic_read_unchecked(&fscache_n_allocs_intr));
56928 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
56929 - atomic_read(&fscache_n_alloc_ops),
56930 - atomic_read(&fscache_n_alloc_op_waits),
56931 - atomic_read(&fscache_n_allocs_object_dead));
56932 + atomic_read_unchecked(&fscache_n_alloc_ops),
56933 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
56934 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
56935
56936 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
56937 " int=%u oom=%u\n",
56938 - atomic_read(&fscache_n_retrievals),
56939 - atomic_read(&fscache_n_retrievals_ok),
56940 - atomic_read(&fscache_n_retrievals_wait),
56941 - atomic_read(&fscache_n_retrievals_nodata),
56942 - atomic_read(&fscache_n_retrievals_nobufs),
56943 - atomic_read(&fscache_n_retrievals_intr),
56944 - atomic_read(&fscache_n_retrievals_nomem));
56945 + atomic_read_unchecked(&fscache_n_retrievals),
56946 + atomic_read_unchecked(&fscache_n_retrievals_ok),
56947 + atomic_read_unchecked(&fscache_n_retrievals_wait),
56948 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
56949 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
56950 + atomic_read_unchecked(&fscache_n_retrievals_intr),
56951 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
56952 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
56953 - atomic_read(&fscache_n_retrieval_ops),
56954 - atomic_read(&fscache_n_retrieval_op_waits),
56955 - atomic_read(&fscache_n_retrievals_object_dead));
56956 + atomic_read_unchecked(&fscache_n_retrieval_ops),
56957 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
56958 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
56959
56960 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
56961 - atomic_read(&fscache_n_stores),
56962 - atomic_read(&fscache_n_stores_ok),
56963 - atomic_read(&fscache_n_stores_again),
56964 - atomic_read(&fscache_n_stores_nobufs),
56965 - atomic_read(&fscache_n_stores_oom));
56966 + atomic_read_unchecked(&fscache_n_stores),
56967 + atomic_read_unchecked(&fscache_n_stores_ok),
56968 + atomic_read_unchecked(&fscache_n_stores_again),
56969 + atomic_read_unchecked(&fscache_n_stores_nobufs),
56970 + atomic_read_unchecked(&fscache_n_stores_oom));
56971 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
56972 - atomic_read(&fscache_n_store_ops),
56973 - atomic_read(&fscache_n_store_calls),
56974 - atomic_read(&fscache_n_store_pages),
56975 - atomic_read(&fscache_n_store_radix_deletes),
56976 - atomic_read(&fscache_n_store_pages_over_limit));
56977 + atomic_read_unchecked(&fscache_n_store_ops),
56978 + atomic_read_unchecked(&fscache_n_store_calls),
56979 + atomic_read_unchecked(&fscache_n_store_pages),
56980 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
56981 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
56982
56983 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
56984 - atomic_read(&fscache_n_store_vmscan_not_storing),
56985 - atomic_read(&fscache_n_store_vmscan_gone),
56986 - atomic_read(&fscache_n_store_vmscan_busy),
56987 - atomic_read(&fscache_n_store_vmscan_cancelled),
56988 - atomic_read(&fscache_n_store_vmscan_wait));
56989 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
56990 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
56991 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
56992 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
56993 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
56994
56995 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
56996 - atomic_read(&fscache_n_op_pend),
56997 - atomic_read(&fscache_n_op_run),
56998 - atomic_read(&fscache_n_op_enqueue),
56999 - atomic_read(&fscache_n_op_cancelled),
57000 - atomic_read(&fscache_n_op_rejected));
57001 + atomic_read_unchecked(&fscache_n_op_pend),
57002 + atomic_read_unchecked(&fscache_n_op_run),
57003 + atomic_read_unchecked(&fscache_n_op_enqueue),
57004 + atomic_read_unchecked(&fscache_n_op_cancelled),
57005 + atomic_read_unchecked(&fscache_n_op_rejected));
57006 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57007 - atomic_read(&fscache_n_op_deferred_release),
57008 - atomic_read(&fscache_n_op_release),
57009 - atomic_read(&fscache_n_op_gc));
57010 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57011 + atomic_read_unchecked(&fscache_n_op_release),
57012 + atomic_read_unchecked(&fscache_n_op_gc));
57013
57014 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57015 atomic_read(&fscache_n_cop_alloc_object),
57016 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57017 index aef34b1..59bfd7b 100644
57018 --- a/fs/fuse/cuse.c
57019 +++ b/fs/fuse/cuse.c
57020 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57021 INIT_LIST_HEAD(&cuse_conntbl[i]);
57022
57023 /* inherit and extend fuse_dev_operations */
57024 - cuse_channel_fops = fuse_dev_operations;
57025 - cuse_channel_fops.owner = THIS_MODULE;
57026 - cuse_channel_fops.open = cuse_channel_open;
57027 - cuse_channel_fops.release = cuse_channel_release;
57028 + pax_open_kernel();
57029 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57030 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57031 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57032 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57033 + pax_close_kernel();
57034
57035 cuse_class = class_create(THIS_MODULE, "cuse");
57036 if (IS_ERR(cuse_class))
57037 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57038 index 1d55f94..088da65 100644
57039 --- a/fs/fuse/dev.c
57040 +++ b/fs/fuse/dev.c
57041 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57042 ret = 0;
57043 pipe_lock(pipe);
57044
57045 - if (!pipe->readers) {
57046 + if (!atomic_read(&pipe->readers)) {
57047 send_sig(SIGPIPE, current, 0);
57048 if (!ret)
57049 ret = -EPIPE;
57050 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57051 page_nr++;
57052 ret += buf->len;
57053
57054 - if (pipe->files)
57055 + if (atomic_read(&pipe->files))
57056 do_wakeup = 1;
57057 }
57058
57059 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57060 index 8fec28f..cd40dba 100644
57061 --- a/fs/fuse/dir.c
57062 +++ b/fs/fuse/dir.c
57063 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
57064 return link;
57065 }
57066
57067 -static void free_link(char *link)
57068 +static void free_link(const char *link)
57069 {
57070 if (!IS_ERR(link))
57071 free_page((unsigned long) link);
57072 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57073 index 64915ee..6bed500 100644
57074 --- a/fs/gfs2/inode.c
57075 +++ b/fs/gfs2/inode.c
57076 @@ -1506,7 +1506,7 @@ out:
57077
57078 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57079 {
57080 - char *s = nd_get_link(nd);
57081 + const char *s = nd_get_link(nd);
57082 if (!IS_ERR(s))
57083 kfree(s);
57084 }
57085 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57086 index d19b30a..ef89c36 100644
57087 --- a/fs/hugetlbfs/inode.c
57088 +++ b/fs/hugetlbfs/inode.c
57089 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57090 struct mm_struct *mm = current->mm;
57091 struct vm_area_struct *vma;
57092 struct hstate *h = hstate_file(file);
57093 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57094 struct vm_unmapped_area_info info;
57095
57096 if (len & ~huge_page_mask(h))
57097 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57098 return addr;
57099 }
57100
57101 +#ifdef CONFIG_PAX_RANDMMAP
57102 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57103 +#endif
57104 +
57105 if (addr) {
57106 addr = ALIGN(addr, huge_page_size(h));
57107 vma = find_vma(mm, addr);
57108 - if (TASK_SIZE - len >= addr &&
57109 - (!vma || addr + len <= vma->vm_start))
57110 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57111 return addr;
57112 }
57113
57114 info.flags = 0;
57115 info.length = len;
57116 info.low_limit = TASK_UNMAPPED_BASE;
57117 +
57118 +#ifdef CONFIG_PAX_RANDMMAP
57119 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57120 + info.low_limit += mm->delta_mmap;
57121 +#endif
57122 +
57123 info.high_limit = TASK_SIZE;
57124 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57125 info.align_offset = 0;
57126 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57127 };
57128 MODULE_ALIAS_FS("hugetlbfs");
57129
57130 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57131 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57132
57133 static int can_do_hugetlb_shm(void)
57134 {
57135 diff --git a/fs/inode.c b/fs/inode.c
57136 index d6dfb09..602e77e 100644
57137 --- a/fs/inode.c
57138 +++ b/fs/inode.c
57139 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57140
57141 #ifdef CONFIG_SMP
57142 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57143 - static atomic_t shared_last_ino;
57144 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57145 + static atomic_unchecked_t shared_last_ino;
57146 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57147
57148 res = next - LAST_INO_BATCH;
57149 }
57150 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57151 index 4a6cf28..d3a29d3 100644
57152 --- a/fs/jffs2/erase.c
57153 +++ b/fs/jffs2/erase.c
57154 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57155 struct jffs2_unknown_node marker = {
57156 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57157 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57158 - .totlen = cpu_to_je32(c->cleanmarker_size)
57159 + .totlen = cpu_to_je32(c->cleanmarker_size),
57160 + .hdr_crc = cpu_to_je32(0)
57161 };
57162
57163 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57164 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57165 index a6597d6..41b30ec 100644
57166 --- a/fs/jffs2/wbuf.c
57167 +++ b/fs/jffs2/wbuf.c
57168 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57169 {
57170 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57171 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57172 - .totlen = constant_cpu_to_je32(8)
57173 + .totlen = constant_cpu_to_je32(8),
57174 + .hdr_crc = constant_cpu_to_je32(0)
57175 };
57176
57177 /*
57178 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57179 index 6669aa2..36b033d 100644
57180 --- a/fs/jfs/super.c
57181 +++ b/fs/jfs/super.c
57182 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57183
57184 jfs_inode_cachep =
57185 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57186 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57187 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57188 init_once);
57189 if (jfs_inode_cachep == NULL)
57190 return -ENOMEM;
57191 diff --git a/fs/libfs.c b/fs/libfs.c
57192 index 3a3a9b5..3a9b074 100644
57193 --- a/fs/libfs.c
57194 +++ b/fs/libfs.c
57195 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57196
57197 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57198 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57199 + char d_name[sizeof(next->d_iname)];
57200 + const unsigned char *name;
57201 +
57202 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57203 if (!simple_positive(next)) {
57204 spin_unlock(&next->d_lock);
57205 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57206
57207 spin_unlock(&next->d_lock);
57208 spin_unlock(&dentry->d_lock);
57209 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57210 + name = next->d_name.name;
57211 + if (name == next->d_iname) {
57212 + memcpy(d_name, name, next->d_name.len);
57213 + name = d_name;
57214 + }
57215 + if (!dir_emit(ctx, name, next->d_name.len,
57216 next->d_inode->i_ino, dt_type(next->d_inode)))
57217 return 0;
57218 spin_lock(&dentry->d_lock);
57219 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57220 index acd3947..1f896e2 100644
57221 --- a/fs/lockd/clntproc.c
57222 +++ b/fs/lockd/clntproc.c
57223 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57224 /*
57225 * Cookie counter for NLM requests
57226 */
57227 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57228 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57229
57230 void nlmclnt_next_cookie(struct nlm_cookie *c)
57231 {
57232 - u32 cookie = atomic_inc_return(&nlm_cookie);
57233 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57234
57235 memcpy(c->data, &cookie, 4);
57236 c->len=4;
57237 diff --git a/fs/locks.c b/fs/locks.c
57238 index b27a300..4156d0b 100644
57239 --- a/fs/locks.c
57240 +++ b/fs/locks.c
57241 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57242 return;
57243
57244 if (filp->f_op && filp->f_op->flock) {
57245 - struct file_lock fl = {
57246 + struct file_lock flock = {
57247 .fl_pid = current->tgid,
57248 .fl_file = filp,
57249 .fl_flags = FL_FLOCK,
57250 .fl_type = F_UNLCK,
57251 .fl_end = OFFSET_MAX,
57252 };
57253 - filp->f_op->flock(filp, F_SETLKW, &fl);
57254 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57255 - fl.fl_ops->fl_release_private(&fl);
57256 + filp->f_op->flock(filp, F_SETLKW, &flock);
57257 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57258 + flock.fl_ops->fl_release_private(&flock);
57259 }
57260
57261 spin_lock(&inode->i_lock);
57262 diff --git a/fs/namei.c b/fs/namei.c
57263 index 7720fbd..7934bb2 100644
57264 --- a/fs/namei.c
57265 +++ b/fs/namei.c
57266 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57267 if (ret != -EACCES)
57268 return ret;
57269
57270 +#ifdef CONFIG_GRKERNSEC
57271 + /* we'll block if we have to log due to a denied capability use */
57272 + if (mask & MAY_NOT_BLOCK)
57273 + return -ECHILD;
57274 +#endif
57275 +
57276 if (S_ISDIR(inode->i_mode)) {
57277 /* DACs are overridable for directories */
57278 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57279 - return 0;
57280 if (!(mask & MAY_WRITE))
57281 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57282 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57283 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57284 return 0;
57285 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57286 + return 0;
57287 return -EACCES;
57288 }
57289 /*
57290 + * Searching includes executable on directories, else just read.
57291 + */
57292 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57293 + if (mask == MAY_READ)
57294 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57295 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57296 + return 0;
57297 +
57298 + /*
57299 * Read/write DACs are always overridable.
57300 * Executable DACs are overridable when there is
57301 * at least one exec bit set.
57302 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57303 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57304 return 0;
57305
57306 - /*
57307 - * Searching includes executable on directories, else just read.
57308 - */
57309 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57310 - if (mask == MAY_READ)
57311 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57312 - return 0;
57313 -
57314 return -EACCES;
57315 }
57316
57317 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57318 {
57319 struct dentry *dentry = link->dentry;
57320 int error;
57321 - char *s;
57322 + const char *s;
57323
57324 BUG_ON(nd->flags & LOOKUP_RCU);
57325
57326 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57327 if (error)
57328 goto out_put_nd_path;
57329
57330 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57331 + dentry->d_inode, dentry, nd->path.mnt)) {
57332 + error = -EACCES;
57333 + goto out_put_nd_path;
57334 + }
57335 +
57336 nd->last_type = LAST_BIND;
57337 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57338 error = PTR_ERR(*p);
57339 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57340 if (res)
57341 break;
57342 res = walk_component(nd, path, LOOKUP_FOLLOW);
57343 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57344 + res = -EACCES;
57345 put_link(nd, &link, cookie);
57346 } while (res > 0);
57347
57348 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57349 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57350 {
57351 unsigned long a, b, adata, bdata, mask, hash, len;
57352 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57353 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57354
57355 hash = a = 0;
57356 len = -sizeof(unsigned long);
57357 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57358 if (err)
57359 break;
57360 err = lookup_last(nd, &path);
57361 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57362 + err = -EACCES;
57363 put_link(nd, &link, cookie);
57364 }
57365 }
57366 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57367 if (!err)
57368 err = complete_walk(nd);
57369
57370 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57371 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57372 + path_put(&nd->path);
57373 + err = -ENOENT;
57374 + }
57375 + }
57376 +
57377 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57378 if (!can_lookup(nd->inode)) {
57379 path_put(&nd->path);
57380 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57381 retval = path_lookupat(dfd, name->name,
57382 flags | LOOKUP_REVAL, nd);
57383
57384 - if (likely(!retval))
57385 + if (likely(!retval)) {
57386 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57387 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57388 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57389 + path_put(&nd->path);
57390 + return -ENOENT;
57391 + }
57392 + }
57393 + }
57394 return retval;
57395 }
57396
57397 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57398 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57399 return -EPERM;
57400
57401 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57402 + return -EPERM;
57403 + if (gr_handle_rawio(inode))
57404 + return -EPERM;
57405 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57406 + return -EACCES;
57407 +
57408 return 0;
57409 }
57410
57411 @@ -2601,7 +2640,7 @@ looked_up:
57412 * cleared otherwise prior to returning.
57413 */
57414 static int lookup_open(struct nameidata *nd, struct path *path,
57415 - struct file *file,
57416 + struct path *link, struct file *file,
57417 const struct open_flags *op,
57418 bool got_write, int *opened)
57419 {
57420 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57421 /* Negative dentry, just create the file */
57422 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57423 umode_t mode = op->mode;
57424 +
57425 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57426 + error = -EACCES;
57427 + goto out_dput;
57428 + }
57429 +
57430 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57431 + error = -EACCES;
57432 + goto out_dput;
57433 + }
57434 +
57435 if (!IS_POSIXACL(dir->d_inode))
57436 mode &= ~current_umask();
57437 /*
57438 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57439 nd->flags & LOOKUP_EXCL);
57440 if (error)
57441 goto out_dput;
57442 + else
57443 + gr_handle_create(dentry, nd->path.mnt);
57444 }
57445 out_no_open:
57446 path->dentry = dentry;
57447 @@ -2671,7 +2723,7 @@ out_dput:
57448 /*
57449 * Handle the last step of open()
57450 */
57451 -static int do_last(struct nameidata *nd, struct path *path,
57452 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57453 struct file *file, const struct open_flags *op,
57454 int *opened, struct filename *name)
57455 {
57456 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57457 if (error)
57458 return error;
57459
57460 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57461 + error = -ENOENT;
57462 + goto out;
57463 + }
57464 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57465 + error = -EACCES;
57466 + goto out;
57467 + }
57468 +
57469 audit_inode(name, dir, LOOKUP_PARENT);
57470 error = -EISDIR;
57471 /* trailing slashes? */
57472 @@ -2740,7 +2801,7 @@ retry_lookup:
57473 */
57474 }
57475 mutex_lock(&dir->d_inode->i_mutex);
57476 - error = lookup_open(nd, path, file, op, got_write, opened);
57477 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57478 mutex_unlock(&dir->d_inode->i_mutex);
57479
57480 if (error <= 0) {
57481 @@ -2764,11 +2825,28 @@ retry_lookup:
57482 goto finish_open_created;
57483 }
57484
57485 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57486 + error = -ENOENT;
57487 + goto exit_dput;
57488 + }
57489 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57490 + error = -EACCES;
57491 + goto exit_dput;
57492 + }
57493 +
57494 /*
57495 * create/update audit record if it already exists.
57496 */
57497 - if (path->dentry->d_inode)
57498 + if (path->dentry->d_inode) {
57499 + /* only check if O_CREAT is specified, all other checks need to go
57500 + into may_open */
57501 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57502 + error = -EACCES;
57503 + goto exit_dput;
57504 + }
57505 +
57506 audit_inode(name, path->dentry, 0);
57507 + }
57508
57509 /*
57510 * If atomic_open() acquired write access it is dropped now due to
57511 @@ -2809,6 +2887,11 @@ finish_lookup:
57512 }
57513 }
57514 BUG_ON(inode != path->dentry->d_inode);
57515 + /* if we're resolving a symlink to another symlink */
57516 + if (link && gr_handle_symlink_owner(link, inode)) {
57517 + error = -EACCES;
57518 + goto out;
57519 + }
57520 return 1;
57521 }
57522
57523 @@ -2818,7 +2901,6 @@ finish_lookup:
57524 save_parent.dentry = nd->path.dentry;
57525 save_parent.mnt = mntget(path->mnt);
57526 nd->path.dentry = path->dentry;
57527 -
57528 }
57529 nd->inode = inode;
57530 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57531 @@ -2828,7 +2910,18 @@ finish_open:
57532 path_put(&save_parent);
57533 return error;
57534 }
57535 +
57536 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57537 + error = -ENOENT;
57538 + goto out;
57539 + }
57540 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57541 + error = -EACCES;
57542 + goto out;
57543 + }
57544 +
57545 audit_inode(name, nd->path.dentry, 0);
57546 +
57547 error = -EISDIR;
57548 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57549 goto out;
57550 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57551 if (unlikely(error))
57552 goto out;
57553
57554 - error = do_last(nd, &path, file, op, &opened, pathname);
57555 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57556 while (unlikely(error > 0)) { /* trailing symlink */
57557 struct path link = path;
57558 void *cookie;
57559 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57560 error = follow_link(&link, nd, &cookie);
57561 if (unlikely(error))
57562 break;
57563 - error = do_last(nd, &path, file, op, &opened, pathname);
57564 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57565 put_link(nd, &link, cookie);
57566 }
57567 out:
57568 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57569 goto unlock;
57570
57571 error = -EEXIST;
57572 - if (dentry->d_inode)
57573 + if (dentry->d_inode) {
57574 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57575 + error = -ENOENT;
57576 + }
57577 goto fail;
57578 + }
57579 /*
57580 * Special case - lookup gave negative, but... we had foo/bar/
57581 * From the vfs_mknod() POV we just have a negative dentry -
57582 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57583 }
57584 EXPORT_SYMBOL(user_path_create);
57585
57586 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57587 +{
57588 + struct filename *tmp = getname(pathname);
57589 + struct dentry *res;
57590 + if (IS_ERR(tmp))
57591 + return ERR_CAST(tmp);
57592 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57593 + if (IS_ERR(res))
57594 + putname(tmp);
57595 + else
57596 + *to = tmp;
57597 + return res;
57598 +}
57599 +
57600 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57601 {
57602 int error = may_create(dir, dentry);
57603 @@ -3224,6 +3335,17 @@ retry:
57604
57605 if (!IS_POSIXACL(path.dentry->d_inode))
57606 mode &= ~current_umask();
57607 +
57608 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57609 + error = -EPERM;
57610 + goto out;
57611 + }
57612 +
57613 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57614 + error = -EACCES;
57615 + goto out;
57616 + }
57617 +
57618 error = security_path_mknod(&path, dentry, mode, dev);
57619 if (error)
57620 goto out;
57621 @@ -3240,6 +3362,8 @@ retry:
57622 break;
57623 }
57624 out:
57625 + if (!error)
57626 + gr_handle_create(dentry, path.mnt);
57627 done_path_create(&path, dentry);
57628 if (retry_estale(error, lookup_flags)) {
57629 lookup_flags |= LOOKUP_REVAL;
57630 @@ -3292,9 +3416,16 @@ retry:
57631
57632 if (!IS_POSIXACL(path.dentry->d_inode))
57633 mode &= ~current_umask();
57634 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57635 + error = -EACCES;
57636 + goto out;
57637 + }
57638 error = security_path_mkdir(&path, dentry, mode);
57639 if (!error)
57640 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57641 + if (!error)
57642 + gr_handle_create(dentry, path.mnt);
57643 +out:
57644 done_path_create(&path, dentry);
57645 if (retry_estale(error, lookup_flags)) {
57646 lookup_flags |= LOOKUP_REVAL;
57647 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57648 struct filename *name;
57649 struct dentry *dentry;
57650 struct nameidata nd;
57651 + ino_t saved_ino = 0;
57652 + dev_t saved_dev = 0;
57653 unsigned int lookup_flags = 0;
57654 retry:
57655 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57656 @@ -3407,10 +3540,21 @@ retry:
57657 error = -ENOENT;
57658 goto exit3;
57659 }
57660 +
57661 + saved_ino = dentry->d_inode->i_ino;
57662 + saved_dev = gr_get_dev_from_dentry(dentry);
57663 +
57664 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57665 + error = -EACCES;
57666 + goto exit3;
57667 + }
57668 +
57669 error = security_path_rmdir(&nd.path, dentry);
57670 if (error)
57671 goto exit3;
57672 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57673 + if (!error && (saved_dev || saved_ino))
57674 + gr_handle_delete(saved_ino, saved_dev);
57675 exit3:
57676 dput(dentry);
57677 exit2:
57678 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57679 struct dentry *dentry;
57680 struct nameidata nd;
57681 struct inode *inode = NULL;
57682 + ino_t saved_ino = 0;
57683 + dev_t saved_dev = 0;
57684 unsigned int lookup_flags = 0;
57685 retry:
57686 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57687 @@ -3502,10 +3648,22 @@ retry:
57688 if (!inode)
57689 goto slashes;
57690 ihold(inode);
57691 +
57692 + if (inode->i_nlink <= 1) {
57693 + saved_ino = inode->i_ino;
57694 + saved_dev = gr_get_dev_from_dentry(dentry);
57695 + }
57696 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57697 + error = -EACCES;
57698 + goto exit2;
57699 + }
57700 +
57701 error = security_path_unlink(&nd.path, dentry);
57702 if (error)
57703 goto exit2;
57704 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57705 + if (!error && (saved_ino || saved_dev))
57706 + gr_handle_delete(saved_ino, saved_dev);
57707 exit2:
57708 dput(dentry);
57709 }
57710 @@ -3583,9 +3741,17 @@ retry:
57711 if (IS_ERR(dentry))
57712 goto out_putname;
57713
57714 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57715 + error = -EACCES;
57716 + goto out;
57717 + }
57718 +
57719 error = security_path_symlink(&path, dentry, from->name);
57720 if (!error)
57721 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57722 + if (!error)
57723 + gr_handle_create(dentry, path.mnt);
57724 +out:
57725 done_path_create(&path, dentry);
57726 if (retry_estale(error, lookup_flags)) {
57727 lookup_flags |= LOOKUP_REVAL;
57728 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57729 {
57730 struct dentry *new_dentry;
57731 struct path old_path, new_path;
57732 + struct filename *to = NULL;
57733 int how = 0;
57734 int error;
57735
57736 @@ -3688,7 +3855,7 @@ retry:
57737 if (error)
57738 return error;
57739
57740 - new_dentry = user_path_create(newdfd, newname, &new_path,
57741 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57742 (how & LOOKUP_REVAL));
57743 error = PTR_ERR(new_dentry);
57744 if (IS_ERR(new_dentry))
57745 @@ -3700,11 +3867,28 @@ retry:
57746 error = may_linkat(&old_path);
57747 if (unlikely(error))
57748 goto out_dput;
57749 +
57750 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57751 + old_path.dentry->d_inode,
57752 + old_path.dentry->d_inode->i_mode, to)) {
57753 + error = -EACCES;
57754 + goto out_dput;
57755 + }
57756 +
57757 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
57758 + old_path.dentry, old_path.mnt, to)) {
57759 + error = -EACCES;
57760 + goto out_dput;
57761 + }
57762 +
57763 error = security_path_link(old_path.dentry, &new_path, new_dentry);
57764 if (error)
57765 goto out_dput;
57766 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
57767 + if (!error)
57768 + gr_handle_create(new_dentry, new_path.mnt);
57769 out_dput:
57770 + putname(to);
57771 done_path_create(&new_path, new_dentry);
57772 if (retry_estale(error, how)) {
57773 how |= LOOKUP_REVAL;
57774 @@ -3950,12 +4134,21 @@ retry:
57775 if (new_dentry == trap)
57776 goto exit5;
57777
57778 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
57779 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
57780 + to);
57781 + if (error)
57782 + goto exit5;
57783 +
57784 error = security_path_rename(&oldnd.path, old_dentry,
57785 &newnd.path, new_dentry);
57786 if (error)
57787 goto exit5;
57788 error = vfs_rename(old_dir->d_inode, old_dentry,
57789 new_dir->d_inode, new_dentry);
57790 + if (!error)
57791 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
57792 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
57793 exit5:
57794 dput(new_dentry);
57795 exit4:
57796 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
57797
57798 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
57799 {
57800 + char tmpbuf[64];
57801 + const char *newlink;
57802 int len;
57803
57804 len = PTR_ERR(link);
57805 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
57806 len = strlen(link);
57807 if (len > (unsigned) buflen)
57808 len = buflen;
57809 - if (copy_to_user(buffer, link, len))
57810 +
57811 + if (len < sizeof(tmpbuf)) {
57812 + memcpy(tmpbuf, link, len);
57813 + newlink = tmpbuf;
57814 + } else
57815 + newlink = link;
57816 +
57817 + if (copy_to_user(buffer, newlink, len))
57818 len = -EFAULT;
57819 out:
57820 return len;
57821 diff --git a/fs/namespace.c b/fs/namespace.c
57822 index a45ba4f..b4c7d07 100644
57823 --- a/fs/namespace.c
57824 +++ b/fs/namespace.c
57825 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
57826 if (!(sb->s_flags & MS_RDONLY))
57827 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
57828 up_write(&sb->s_umount);
57829 +
57830 + gr_log_remount(mnt->mnt_devname, retval);
57831 +
57832 return retval;
57833 }
57834
57835 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
57836 }
57837 br_write_unlock(&vfsmount_lock);
57838 namespace_unlock();
57839 +
57840 + gr_log_unmount(mnt->mnt_devname, retval);
57841 +
57842 return retval;
57843 }
57844
57845 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
57846 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
57847 */
57848
57849 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
57850 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
57851 {
57852 struct path path;
57853 struct mount *mnt;
57854 @@ -1342,7 +1348,7 @@ out:
57855 /*
57856 * The 2.0 compatible umount. No flags.
57857 */
57858 -SYSCALL_DEFINE1(oldumount, char __user *, name)
57859 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
57860 {
57861 return sys_umount(name, 0);
57862 }
57863 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
57864 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
57865 MS_STRICTATIME);
57866
57867 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
57868 + retval = -EPERM;
57869 + goto dput_out;
57870 + }
57871 +
57872 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
57873 + retval = -EPERM;
57874 + goto dput_out;
57875 + }
57876 +
57877 if (flags & MS_REMOUNT)
57878 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
57879 data_page);
57880 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
57881 dev_name, data_page);
57882 dput_out:
57883 path_put(&path);
57884 +
57885 + gr_log_mount(dev_name, dir_name, retval);
57886 +
57887 return retval;
57888 }
57889
57890 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
57891 * number incrementing at 10Ghz will take 12,427 years to wrap which
57892 * is effectively never, so we can ignore the possibility.
57893 */
57894 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
57895 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
57896
57897 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
57898 {
57899 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
57900 kfree(new_ns);
57901 return ERR_PTR(ret);
57902 }
57903 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
57904 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
57905 atomic_set(&new_ns->count, 1);
57906 new_ns->root = NULL;
57907 INIT_LIST_HEAD(&new_ns->list);
57908 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
57909 * Allocate a new namespace structure and populate it with contents
57910 * copied from the namespace of the passed in task structure.
57911 */
57912 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
57913 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
57914 struct user_namespace *user_ns, struct fs_struct *fs)
57915 {
57916 struct mnt_namespace *new_ns;
57917 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
57918 }
57919 EXPORT_SYMBOL(mount_subtree);
57920
57921 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
57922 - char __user *, type, unsigned long, flags, void __user *, data)
57923 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
57924 + const char __user *, type, unsigned long, flags, void __user *, data)
57925 {
57926 int ret;
57927 char *kernel_type;
57928 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
57929 if (error)
57930 goto out2;
57931
57932 + if (gr_handle_chroot_pivot()) {
57933 + error = -EPERM;
57934 + goto out2;
57935 + }
57936 +
57937 get_fs_root(current->fs, &root);
57938 old_mp = lock_mount(&old);
57939 error = PTR_ERR(old_mp);
57940 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
57941 !nsown_capable(CAP_SYS_ADMIN))
57942 return -EPERM;
57943
57944 - if (fs->users != 1)
57945 + if (atomic_read(&fs->users) != 1)
57946 return -EINVAL;
57947
57948 get_mnt_ns(mnt_ns);
57949 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
57950 index f4ccfe6..a5cf064 100644
57951 --- a/fs/nfs/callback_xdr.c
57952 +++ b/fs/nfs/callback_xdr.c
57953 @@ -51,7 +51,7 @@ struct callback_op {
57954 callback_decode_arg_t decode_args;
57955 callback_encode_res_t encode_res;
57956 long res_maxsize;
57957 -};
57958 +} __do_const;
57959
57960 static struct callback_op callback_ops[];
57961
57962 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
57963 index 941246f..17d8724 100644
57964 --- a/fs/nfs/inode.c
57965 +++ b/fs/nfs/inode.c
57966 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
57967 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
57968 }
57969
57970 -static atomic_long_t nfs_attr_generation_counter;
57971 +static atomic_long_unchecked_t nfs_attr_generation_counter;
57972
57973 static unsigned long nfs_read_attr_generation_counter(void)
57974 {
57975 - return atomic_long_read(&nfs_attr_generation_counter);
57976 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
57977 }
57978
57979 unsigned long nfs_inc_attr_generation_counter(void)
57980 {
57981 - return atomic_long_inc_return(&nfs_attr_generation_counter);
57982 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
57983 }
57984
57985 void nfs_fattr_init(struct nfs_fattr *fattr)
57986 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
57987 index 419572f..5414a23 100644
57988 --- a/fs/nfsd/nfs4proc.c
57989 +++ b/fs/nfsd/nfs4proc.c
57990 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
57991 nfsd4op_rsize op_rsize_bop;
57992 stateid_getter op_get_currentstateid;
57993 stateid_setter op_set_currentstateid;
57994 -};
57995 +} __do_const;
57996
57997 static struct nfsd4_operation nfsd4_ops[];
57998
57999 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58000 index c2a4701..fd80e29 100644
58001 --- a/fs/nfsd/nfs4xdr.c
58002 +++ b/fs/nfsd/nfs4xdr.c
58003 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58004
58005 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58006
58007 -static nfsd4_dec nfsd4_dec_ops[] = {
58008 +static const nfsd4_dec nfsd4_dec_ops[] = {
58009 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58010 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58011 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58012 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58013 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58014 };
58015
58016 -static nfsd4_dec nfsd41_dec_ops[] = {
58017 +static const nfsd4_dec nfsd41_dec_ops[] = {
58018 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58019 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58020 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58021 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58022 };
58023
58024 struct nfsd4_minorversion_ops {
58025 - nfsd4_dec *decoders;
58026 + const nfsd4_dec *decoders;
58027 int nops;
58028 };
58029
58030 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58031 index e76244e..9fe8f2f1 100644
58032 --- a/fs/nfsd/nfscache.c
58033 +++ b/fs/nfsd/nfscache.c
58034 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58035 {
58036 struct svc_cacherep *rp = rqstp->rq_cacherep;
58037 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58038 - int len;
58039 + long len;
58040 size_t bufsize = 0;
58041
58042 if (!rp)
58043 return;
58044
58045 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58046 - len >>= 2;
58047 + if (statp) {
58048 + len = (char*)statp - (char*)resv->iov_base;
58049 + len = resv->iov_len - len;
58050 + len >>= 2;
58051 + }
58052
58053 /* Don't cache excessive amounts of data and XDR failures */
58054 if (!statp || len > (256 >> 2)) {
58055 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58056 index c827acb..b253b77 100644
58057 --- a/fs/nfsd/vfs.c
58058 +++ b/fs/nfsd/vfs.c
58059 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58060 } else {
58061 oldfs = get_fs();
58062 set_fs(KERNEL_DS);
58063 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58064 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58065 set_fs(oldfs);
58066 }
58067
58068 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58069
58070 /* Write the data. */
58071 oldfs = get_fs(); set_fs(KERNEL_DS);
58072 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58073 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58074 set_fs(oldfs);
58075 if (host_err < 0)
58076 goto out_nfserr;
58077 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58078 */
58079
58080 oldfs = get_fs(); set_fs(KERNEL_DS);
58081 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58082 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58083 set_fs(oldfs);
58084
58085 if (host_err < 0)
58086 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58087 index fea6bd5..8ee9d81 100644
58088 --- a/fs/nls/nls_base.c
58089 +++ b/fs/nls/nls_base.c
58090 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58091
58092 int register_nls(struct nls_table * nls)
58093 {
58094 - struct nls_table ** tmp = &tables;
58095 + struct nls_table *tmp = tables;
58096
58097 if (nls->next)
58098 return -EBUSY;
58099
58100 spin_lock(&nls_lock);
58101 - while (*tmp) {
58102 - if (nls == *tmp) {
58103 + while (tmp) {
58104 + if (nls == tmp) {
58105 spin_unlock(&nls_lock);
58106 return -EBUSY;
58107 }
58108 - tmp = &(*tmp)->next;
58109 + tmp = tmp->next;
58110 }
58111 - nls->next = tables;
58112 + pax_open_kernel();
58113 + *(struct nls_table **)&nls->next = tables;
58114 + pax_close_kernel();
58115 tables = nls;
58116 spin_unlock(&nls_lock);
58117 return 0;
58118 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58119
58120 int unregister_nls(struct nls_table * nls)
58121 {
58122 - struct nls_table ** tmp = &tables;
58123 + struct nls_table * const * tmp = &tables;
58124
58125 spin_lock(&nls_lock);
58126 while (*tmp) {
58127 if (nls == *tmp) {
58128 - *tmp = nls->next;
58129 + pax_open_kernel();
58130 + *(struct nls_table **)tmp = nls->next;
58131 + pax_close_kernel();
58132 spin_unlock(&nls_lock);
58133 return 0;
58134 }
58135 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58136 index 7424929..35f6be5 100644
58137 --- a/fs/nls/nls_euc-jp.c
58138 +++ b/fs/nls/nls_euc-jp.c
58139 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58140 p_nls = load_nls("cp932");
58141
58142 if (p_nls) {
58143 - table.charset2upper = p_nls->charset2upper;
58144 - table.charset2lower = p_nls->charset2lower;
58145 + pax_open_kernel();
58146 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58147 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58148 + pax_close_kernel();
58149 return register_nls(&table);
58150 }
58151
58152 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58153 index e7bc1d7..06bd4bb 100644
58154 --- a/fs/nls/nls_koi8-ru.c
58155 +++ b/fs/nls/nls_koi8-ru.c
58156 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58157 p_nls = load_nls("koi8-u");
58158
58159 if (p_nls) {
58160 - table.charset2upper = p_nls->charset2upper;
58161 - table.charset2lower = p_nls->charset2lower;
58162 + pax_open_kernel();
58163 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58164 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58165 + pax_close_kernel();
58166 return register_nls(&table);
58167 }
58168
58169 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58170 index e44cb64..4807084 100644
58171 --- a/fs/notify/fanotify/fanotify_user.c
58172 +++ b/fs/notify/fanotify/fanotify_user.c
58173 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58174
58175 fd = fanotify_event_metadata.fd;
58176 ret = -EFAULT;
58177 - if (copy_to_user(buf, &fanotify_event_metadata,
58178 - fanotify_event_metadata.event_len))
58179 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58180 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58181 goto out_close_fd;
58182
58183 ret = prepare_for_access_response(group, event, fd);
58184 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58185 index 7b51b05..5ea5ef6 100644
58186 --- a/fs/notify/notification.c
58187 +++ b/fs/notify/notification.c
58188 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58189 * get set to 0 so it will never get 'freed'
58190 */
58191 static struct fsnotify_event *q_overflow_event;
58192 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58193 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58194
58195 /**
58196 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58197 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58198 */
58199 u32 fsnotify_get_cookie(void)
58200 {
58201 - return atomic_inc_return(&fsnotify_sync_cookie);
58202 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58203 }
58204 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58205
58206 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58207 index 9e38daf..5727cae 100644
58208 --- a/fs/ntfs/dir.c
58209 +++ b/fs/ntfs/dir.c
58210 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58211 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58212 ~(s64)(ndir->itype.index.block_size - 1)));
58213 /* Bounds checks. */
58214 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58215 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58216 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58217 "inode 0x%lx or driver bug.", vdir->i_ino);
58218 goto err_out;
58219 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58220 index c5670b8..d590213 100644
58221 --- a/fs/ntfs/file.c
58222 +++ b/fs/ntfs/file.c
58223 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58224 char *addr;
58225 size_t total = 0;
58226 unsigned len;
58227 - int left;
58228 + unsigned left;
58229
58230 do {
58231 len = PAGE_CACHE_SIZE - ofs;
58232 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58233 index 82650d5..db37dcf 100644
58234 --- a/fs/ntfs/super.c
58235 +++ b/fs/ntfs/super.c
58236 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58237 if (!silent)
58238 ntfs_error(sb, "Primary boot sector is invalid.");
58239 } else if (!silent)
58240 - ntfs_error(sb, read_err_str, "primary");
58241 + ntfs_error(sb, read_err_str, "%s", "primary");
58242 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58243 if (bh_primary)
58244 brelse(bh_primary);
58245 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58246 goto hotfix_primary_boot_sector;
58247 brelse(bh_backup);
58248 } else if (!silent)
58249 - ntfs_error(sb, read_err_str, "backup");
58250 + ntfs_error(sb, read_err_str, "%s", "backup");
58251 /* Try to read NT3.51- backup boot sector. */
58252 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58253 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58254 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58255 "sector.");
58256 brelse(bh_backup);
58257 } else if (!silent)
58258 - ntfs_error(sb, read_err_str, "backup");
58259 + ntfs_error(sb, read_err_str, "%s", "backup");
58260 /* We failed. Cleanup and return. */
58261 if (bh_primary)
58262 brelse(bh_primary);
58263 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58264 index aebeacd..0dcdd26 100644
58265 --- a/fs/ocfs2/localalloc.c
58266 +++ b/fs/ocfs2/localalloc.c
58267 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58268 goto bail;
58269 }
58270
58271 - atomic_inc(&osb->alloc_stats.moves);
58272 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58273
58274 bail:
58275 if (handle)
58276 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58277 index 3a90347..c40bef8 100644
58278 --- a/fs/ocfs2/ocfs2.h
58279 +++ b/fs/ocfs2/ocfs2.h
58280 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58281
58282 struct ocfs2_alloc_stats
58283 {
58284 - atomic_t moves;
58285 - atomic_t local_data;
58286 - atomic_t bitmap_data;
58287 - atomic_t bg_allocs;
58288 - atomic_t bg_extends;
58289 + atomic_unchecked_t moves;
58290 + atomic_unchecked_t local_data;
58291 + atomic_unchecked_t bitmap_data;
58292 + atomic_unchecked_t bg_allocs;
58293 + atomic_unchecked_t bg_extends;
58294 };
58295
58296 enum ocfs2_local_alloc_state
58297 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58298 index 5397c07..54afc55 100644
58299 --- a/fs/ocfs2/suballoc.c
58300 +++ b/fs/ocfs2/suballoc.c
58301 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58302 mlog_errno(status);
58303 goto bail;
58304 }
58305 - atomic_inc(&osb->alloc_stats.bg_extends);
58306 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58307
58308 /* You should never ask for this much metadata */
58309 BUG_ON(bits_wanted >
58310 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58311 mlog_errno(status);
58312 goto bail;
58313 }
58314 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58315 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58316
58317 *suballoc_loc = res.sr_bg_blkno;
58318 *suballoc_bit_start = res.sr_bit_offset;
58319 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58320 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58321 res->sr_bits);
58322
58323 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58324 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58325
58326 BUG_ON(res->sr_bits != 1);
58327
58328 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58329 mlog_errno(status);
58330 goto bail;
58331 }
58332 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58333 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58334
58335 BUG_ON(res.sr_bits != 1);
58336
58337 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58338 cluster_start,
58339 num_clusters);
58340 if (!status)
58341 - atomic_inc(&osb->alloc_stats.local_data);
58342 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58343 } else {
58344 if (min_clusters > (osb->bitmap_cpg - 1)) {
58345 /* The only paths asking for contiguousness
58346 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58347 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58348 res.sr_bg_blkno,
58349 res.sr_bit_offset);
58350 - atomic_inc(&osb->alloc_stats.bitmap_data);
58351 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58352 *num_clusters = res.sr_bits;
58353 }
58354 }
58355 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58356 index 121da2d..a0232bc 100644
58357 --- a/fs/ocfs2/super.c
58358 +++ b/fs/ocfs2/super.c
58359 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58360 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58361 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58362 "Stats",
58363 - atomic_read(&osb->alloc_stats.bitmap_data),
58364 - atomic_read(&osb->alloc_stats.local_data),
58365 - atomic_read(&osb->alloc_stats.bg_allocs),
58366 - atomic_read(&osb->alloc_stats.moves),
58367 - atomic_read(&osb->alloc_stats.bg_extends));
58368 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58369 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58370 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58371 + atomic_read_unchecked(&osb->alloc_stats.moves),
58372 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58373
58374 out += snprintf(buf + out, len - out,
58375 "%10s => State: %u Descriptor: %llu Size: %u bits "
58376 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58377 spin_lock_init(&osb->osb_xattr_lock);
58378 ocfs2_init_steal_slots(osb);
58379
58380 - atomic_set(&osb->alloc_stats.moves, 0);
58381 - atomic_set(&osb->alloc_stats.local_data, 0);
58382 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58383 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58384 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58385 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58386 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58387 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58388 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58389 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58390
58391 /* Copy the blockcheck stats from the superblock probe */
58392 osb->osb_ecc_stats = *stats;
58393 diff --git a/fs/open.c b/fs/open.c
58394 index 7931f76..7b03f3b 100644
58395 --- a/fs/open.c
58396 +++ b/fs/open.c
58397 @@ -32,6 +32,8 @@
58398 #include <linux/dnotify.h>
58399 #include <linux/compat.h>
58400
58401 +#define CREATE_TRACE_POINTS
58402 +#include <trace/events/fs.h>
58403 #include "internal.h"
58404
58405 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58406 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58407 error = locks_verify_truncate(inode, NULL, length);
58408 if (!error)
58409 error = security_path_truncate(path);
58410 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58411 + error = -EACCES;
58412 if (!error)
58413 error = do_truncate(path->dentry, length, 0, NULL);
58414
58415 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58416 error = locks_verify_truncate(inode, f.file, length);
58417 if (!error)
58418 error = security_path_truncate(&f.file->f_path);
58419 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58420 + error = -EACCES;
58421 if (!error)
58422 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58423 sb_end_write(inode->i_sb);
58424 @@ -360,6 +366,9 @@ retry:
58425 if (__mnt_is_readonly(path.mnt))
58426 res = -EROFS;
58427
58428 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58429 + res = -EACCES;
58430 +
58431 out_path_release:
58432 path_put(&path);
58433 if (retry_estale(res, lookup_flags)) {
58434 @@ -391,6 +400,8 @@ retry:
58435 if (error)
58436 goto dput_and_out;
58437
58438 + gr_log_chdir(path.dentry, path.mnt);
58439 +
58440 set_fs_pwd(current->fs, &path);
58441
58442 dput_and_out:
58443 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58444 goto out_putf;
58445
58446 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58447 +
58448 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58449 + error = -EPERM;
58450 +
58451 + if (!error)
58452 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58453 +
58454 if (!error)
58455 set_fs_pwd(current->fs, &f.file->f_path);
58456 out_putf:
58457 @@ -449,7 +467,13 @@ retry:
58458 if (error)
58459 goto dput_and_out;
58460
58461 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58462 + goto dput_and_out;
58463 +
58464 set_fs_root(current->fs, &path);
58465 +
58466 + gr_handle_chroot_chdir(&path);
58467 +
58468 error = 0;
58469 dput_and_out:
58470 path_put(&path);
58471 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58472 if (error)
58473 return error;
58474 mutex_lock(&inode->i_mutex);
58475 +
58476 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58477 + error = -EACCES;
58478 + goto out_unlock;
58479 + }
58480 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58481 + error = -EACCES;
58482 + goto out_unlock;
58483 + }
58484 +
58485 error = security_path_chmod(path, mode);
58486 if (error)
58487 goto out_unlock;
58488 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58489 uid = make_kuid(current_user_ns(), user);
58490 gid = make_kgid(current_user_ns(), group);
58491
58492 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58493 + return -EACCES;
58494 +
58495 newattrs.ia_valid = ATTR_CTIME;
58496 if (user != (uid_t) -1) {
58497 if (!uid_valid(uid))
58498 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58499 } else {
58500 fsnotify_open(f);
58501 fd_install(fd, f);
58502 + trace_do_sys_open(tmp->name, flags, mode);
58503 }
58504 }
58505 putname(tmp);
58506 diff --git a/fs/pipe.c b/fs/pipe.c
58507 index d2c45e1..009fe1c 100644
58508 --- a/fs/pipe.c
58509 +++ b/fs/pipe.c
58510 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58511
58512 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58513 {
58514 - if (pipe->files)
58515 + if (atomic_read(&pipe->files))
58516 mutex_lock_nested(&pipe->mutex, subclass);
58517 }
58518
58519 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58520
58521 void pipe_unlock(struct pipe_inode_info *pipe)
58522 {
58523 - if (pipe->files)
58524 + if (atomic_read(&pipe->files))
58525 mutex_unlock(&pipe->mutex);
58526 }
58527 EXPORT_SYMBOL(pipe_unlock);
58528 @@ -449,9 +449,9 @@ redo:
58529 }
58530 if (bufs) /* More to do? */
58531 continue;
58532 - if (!pipe->writers)
58533 + if (!atomic_read(&pipe->writers))
58534 break;
58535 - if (!pipe->waiting_writers) {
58536 + if (!atomic_read(&pipe->waiting_writers)) {
58537 /* syscall merging: Usually we must not sleep
58538 * if O_NONBLOCK is set, or if we got some data.
58539 * But if a writer sleeps in kernel space, then
58540 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58541 ret = 0;
58542 __pipe_lock(pipe);
58543
58544 - if (!pipe->readers) {
58545 + if (!atomic_read(&pipe->readers)) {
58546 send_sig(SIGPIPE, current, 0);
58547 ret = -EPIPE;
58548 goto out;
58549 @@ -562,7 +562,7 @@ redo1:
58550 for (;;) {
58551 int bufs;
58552
58553 - if (!pipe->readers) {
58554 + if (!atomic_read(&pipe->readers)) {
58555 send_sig(SIGPIPE, current, 0);
58556 if (!ret)
58557 ret = -EPIPE;
58558 @@ -653,9 +653,9 @@ redo2:
58559 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58560 do_wakeup = 0;
58561 }
58562 - pipe->waiting_writers++;
58563 + atomic_inc(&pipe->waiting_writers);
58564 pipe_wait(pipe);
58565 - pipe->waiting_writers--;
58566 + atomic_dec(&pipe->waiting_writers);
58567 }
58568 out:
58569 __pipe_unlock(pipe);
58570 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58571 mask = 0;
58572 if (filp->f_mode & FMODE_READ) {
58573 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58574 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58575 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58576 mask |= POLLHUP;
58577 }
58578
58579 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58580 * Most Unices do not set POLLERR for FIFOs but on Linux they
58581 * behave exactly like pipes for poll().
58582 */
58583 - if (!pipe->readers)
58584 + if (!atomic_read(&pipe->readers))
58585 mask |= POLLERR;
58586 }
58587
58588 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58589
58590 __pipe_lock(pipe);
58591 if (file->f_mode & FMODE_READ)
58592 - pipe->readers--;
58593 + atomic_dec(&pipe->readers);
58594 if (file->f_mode & FMODE_WRITE)
58595 - pipe->writers--;
58596 + atomic_dec(&pipe->writers);
58597
58598 - if (pipe->readers || pipe->writers) {
58599 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58600 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58601 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58602 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58603 }
58604 spin_lock(&inode->i_lock);
58605 - if (!--pipe->files) {
58606 + if (atomic_dec_and_test(&pipe->files)) {
58607 inode->i_pipe = NULL;
58608 kill = 1;
58609 }
58610 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58611 kfree(pipe);
58612 }
58613
58614 -static struct vfsmount *pipe_mnt __read_mostly;
58615 +struct vfsmount *pipe_mnt __read_mostly;
58616
58617 /*
58618 * pipefs_dname() is called from d_path().
58619 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58620 goto fail_iput;
58621
58622 inode->i_pipe = pipe;
58623 - pipe->files = 2;
58624 - pipe->readers = pipe->writers = 1;
58625 + atomic_set(&pipe->files, 2);
58626 + atomic_set(&pipe->readers, 1);
58627 + atomic_set(&pipe->writers, 1);
58628 inode->i_fop = &pipefifo_fops;
58629
58630 /*
58631 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58632 spin_lock(&inode->i_lock);
58633 if (inode->i_pipe) {
58634 pipe = inode->i_pipe;
58635 - pipe->files++;
58636 + atomic_inc(&pipe->files);
58637 spin_unlock(&inode->i_lock);
58638 } else {
58639 spin_unlock(&inode->i_lock);
58640 pipe = alloc_pipe_info();
58641 if (!pipe)
58642 return -ENOMEM;
58643 - pipe->files = 1;
58644 + atomic_set(&pipe->files, 1);
58645 spin_lock(&inode->i_lock);
58646 if (unlikely(inode->i_pipe)) {
58647 - inode->i_pipe->files++;
58648 + atomic_inc(&inode->i_pipe->files);
58649 spin_unlock(&inode->i_lock);
58650 free_pipe_info(pipe);
58651 pipe = inode->i_pipe;
58652 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58653 * opened, even when there is no process writing the FIFO.
58654 */
58655 pipe->r_counter++;
58656 - if (pipe->readers++ == 0)
58657 + if (atomic_inc_return(&pipe->readers) == 1)
58658 wake_up_partner(pipe);
58659
58660 - if (!is_pipe && !pipe->writers) {
58661 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58662 if ((filp->f_flags & O_NONBLOCK)) {
58663 /* suppress POLLHUP until we have
58664 * seen a writer */
58665 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58666 * errno=ENXIO when there is no process reading the FIFO.
58667 */
58668 ret = -ENXIO;
58669 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58670 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58671 goto err;
58672
58673 pipe->w_counter++;
58674 - if (!pipe->writers++)
58675 + if (atomic_inc_return(&pipe->writers) == 1)
58676 wake_up_partner(pipe);
58677
58678 - if (!is_pipe && !pipe->readers) {
58679 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58680 if (wait_for_partner(pipe, &pipe->r_counter))
58681 goto err_wr;
58682 }
58683 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58684 * the process can at least talk to itself.
58685 */
58686
58687 - pipe->readers++;
58688 - pipe->writers++;
58689 + atomic_inc(&pipe->readers);
58690 + atomic_inc(&pipe->writers);
58691 pipe->r_counter++;
58692 pipe->w_counter++;
58693 - if (pipe->readers == 1 || pipe->writers == 1)
58694 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58695 wake_up_partner(pipe);
58696 break;
58697
58698 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58699 return 0;
58700
58701 err_rd:
58702 - if (!--pipe->readers)
58703 + if (atomic_dec_and_test(&pipe->readers))
58704 wake_up_interruptible(&pipe->wait);
58705 ret = -ERESTARTSYS;
58706 goto err;
58707
58708 err_wr:
58709 - if (!--pipe->writers)
58710 + if (atomic_dec_and_test(&pipe->writers))
58711 wake_up_interruptible(&pipe->wait);
58712 ret = -ERESTARTSYS;
58713 goto err;
58714
58715 err:
58716 spin_lock(&inode->i_lock);
58717 - if (!--pipe->files) {
58718 + if (atomic_dec_and_test(&pipe->files)) {
58719 inode->i_pipe = NULL;
58720 kill = 1;
58721 }
58722 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58723 index 15af622..0e9f4467 100644
58724 --- a/fs/proc/Kconfig
58725 +++ b/fs/proc/Kconfig
58726 @@ -30,12 +30,12 @@ config PROC_FS
58727
58728 config PROC_KCORE
58729 bool "/proc/kcore support" if !ARM
58730 - depends on PROC_FS && MMU
58731 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58732
58733 config PROC_VMCORE
58734 bool "/proc/vmcore support"
58735 - depends on PROC_FS && CRASH_DUMP
58736 - default y
58737 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58738 + default n
58739 help
58740 Exports the dump image of crashed kernel in ELF format.
58741
58742 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58743 limited in memory.
58744
58745 config PROC_PAGE_MONITOR
58746 - default y
58747 - depends on PROC_FS && MMU
58748 + default n
58749 + depends on PROC_FS && MMU && !GRKERNSEC
58750 bool "Enable /proc page monitoring" if EXPERT
58751 help
58752 Various /proc files exist to monitor process memory utilization:
58753 diff --git a/fs/proc/array.c b/fs/proc/array.c
58754 index cbd0f1b..adec3f0 100644
58755 --- a/fs/proc/array.c
58756 +++ b/fs/proc/array.c
58757 @@ -60,6 +60,7 @@
58758 #include <linux/tty.h>
58759 #include <linux/string.h>
58760 #include <linux/mman.h>
58761 +#include <linux/grsecurity.h>
58762 #include <linux/proc_fs.h>
58763 #include <linux/ioport.h>
58764 #include <linux/uaccess.h>
58765 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
58766 seq_putc(m, '\n');
58767 }
58768
58769 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58770 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
58771 +{
58772 + if (p->mm)
58773 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
58774 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
58775 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
58776 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
58777 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
58778 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
58779 + else
58780 + seq_printf(m, "PaX:\t-----\n");
58781 +}
58782 +#endif
58783 +
58784 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58785 struct pid *pid, struct task_struct *task)
58786 {
58787 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58788 task_cpus_allowed(m, task);
58789 cpuset_task_status_allowed(m, task);
58790 task_context_switch_counts(m, task);
58791 +
58792 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58793 + task_pax(m, task);
58794 +#endif
58795 +
58796 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
58797 + task_grsec_rbac(m, task);
58798 +#endif
58799 +
58800 return 0;
58801 }
58802
58803 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58804 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58805 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58806 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58807 +#endif
58808 +
58809 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58810 struct pid *pid, struct task_struct *task, int whole)
58811 {
58812 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58813 char tcomm[sizeof(task->comm)];
58814 unsigned long flags;
58815
58816 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58817 + if (current->exec_id != m->exec_id) {
58818 + gr_log_badprocpid("stat");
58819 + return 0;
58820 + }
58821 +#endif
58822 +
58823 state = *get_task_state(task);
58824 vsize = eip = esp = 0;
58825 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
58826 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58827 gtime = task_gtime(task);
58828 }
58829
58830 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58831 + if (PAX_RAND_FLAGS(mm)) {
58832 + eip = 0;
58833 + esp = 0;
58834 + wchan = 0;
58835 + }
58836 +#endif
58837 +#ifdef CONFIG_GRKERNSEC_HIDESYM
58838 + wchan = 0;
58839 + eip =0;
58840 + esp =0;
58841 +#endif
58842 +
58843 /* scale priority and nice values from timeslices to -20..20 */
58844 /* to make it look like a "normal" Unix priority/nice value */
58845 priority = task_prio(task);
58846 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58847 seq_put_decimal_ull(m, ' ', vsize);
58848 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
58849 seq_put_decimal_ull(m, ' ', rsslim);
58850 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58851 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
58852 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
58853 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
58854 +#else
58855 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
58856 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
58857 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
58858 +#endif
58859 seq_put_decimal_ull(m, ' ', esp);
58860 seq_put_decimal_ull(m, ' ', eip);
58861 /* The signal information here is obsolete.
58862 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58863 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
58864 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
58865
58866 - if (mm && permitted) {
58867 + if (mm && permitted
58868 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58869 + && !PAX_RAND_FLAGS(mm)
58870 +#endif
58871 + ) {
58872 seq_put_decimal_ull(m, ' ', mm->start_data);
58873 seq_put_decimal_ull(m, ' ', mm->end_data);
58874 seq_put_decimal_ull(m, ' ', mm->start_brk);
58875 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
58876 struct pid *pid, struct task_struct *task)
58877 {
58878 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
58879 - struct mm_struct *mm = get_task_mm(task);
58880 + struct mm_struct *mm;
58881
58882 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58883 + if (current->exec_id != m->exec_id) {
58884 + gr_log_badprocpid("statm");
58885 + return 0;
58886 + }
58887 +#endif
58888 + mm = get_task_mm(task);
58889 if (mm) {
58890 size = task_statm(mm, &shared, &text, &data, &resident);
58891 mmput(mm);
58892 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
58893 return 0;
58894 }
58895
58896 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
58897 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
58898 +{
58899 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
58900 +}
58901 +#endif
58902 +
58903 #ifdef CONFIG_CHECKPOINT_RESTORE
58904 static struct pid *
58905 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
58906 diff --git a/fs/proc/base.c b/fs/proc/base.c
58907 index 1485e38..8ad4236 100644
58908 --- a/fs/proc/base.c
58909 +++ b/fs/proc/base.c
58910 @@ -113,6 +113,14 @@ struct pid_entry {
58911 union proc_op op;
58912 };
58913
58914 +struct getdents_callback {
58915 + struct linux_dirent __user * current_dir;
58916 + struct linux_dirent __user * previous;
58917 + struct file * file;
58918 + int count;
58919 + int error;
58920 +};
58921 +
58922 #define NOD(NAME, MODE, IOP, FOP, OP) { \
58923 .name = (NAME), \
58924 .len = sizeof(NAME) - 1, \
58925 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
58926 if (!mm->arg_end)
58927 goto out_mm; /* Shh! No looking before we're done */
58928
58929 + if (gr_acl_handle_procpidmem(task))
58930 + goto out_mm;
58931 +
58932 len = mm->arg_end - mm->arg_start;
58933
58934 if (len > PAGE_SIZE)
58935 @@ -237,12 +248,28 @@ out:
58936 return res;
58937 }
58938
58939 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58940 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58941 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58942 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58943 +#endif
58944 +
58945 static int proc_pid_auxv(struct task_struct *task, char *buffer)
58946 {
58947 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
58948 int res = PTR_ERR(mm);
58949 if (mm && !IS_ERR(mm)) {
58950 unsigned int nwords = 0;
58951 +
58952 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58953 + /* allow if we're currently ptracing this task */
58954 + if (PAX_RAND_FLAGS(mm) &&
58955 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
58956 + mmput(mm);
58957 + return 0;
58958 + }
58959 +#endif
58960 +
58961 do {
58962 nwords += 2;
58963 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
58964 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
58965 }
58966
58967
58968 -#ifdef CONFIG_KALLSYMS
58969 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
58970 /*
58971 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
58972 * Returns the resolved symbol. If that fails, simply return the address.
58973 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
58974 mutex_unlock(&task->signal->cred_guard_mutex);
58975 }
58976
58977 -#ifdef CONFIG_STACKTRACE
58978 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
58979
58980 #define MAX_STACK_TRACE_DEPTH 64
58981
58982 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
58983 return count;
58984 }
58985
58986 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
58987 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
58988 static int proc_pid_syscall(struct task_struct *task, char *buffer)
58989 {
58990 long nr;
58991 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
58992 /************************************************************************/
58993
58994 /* permission checks */
58995 -static int proc_fd_access_allowed(struct inode *inode)
58996 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
58997 {
58998 struct task_struct *task;
58999 int allowed = 0;
59000 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59001 */
59002 task = get_proc_task(inode);
59003 if (task) {
59004 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59005 + if (log)
59006 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59007 + else
59008 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59009 put_task_struct(task);
59010 }
59011 return allowed;
59012 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59013 struct task_struct *task,
59014 int hide_pid_min)
59015 {
59016 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59017 + return false;
59018 +
59019 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59020 + rcu_read_lock();
59021 + {
59022 + const struct cred *tmpcred = current_cred();
59023 + const struct cred *cred = __task_cred(task);
59024 +
59025 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59026 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59027 + || in_group_p(grsec_proc_gid)
59028 +#endif
59029 + ) {
59030 + rcu_read_unlock();
59031 + return true;
59032 + }
59033 + }
59034 + rcu_read_unlock();
59035 +
59036 + if (!pid->hide_pid)
59037 + return false;
59038 +#endif
59039 +
59040 if (pid->hide_pid < hide_pid_min)
59041 return true;
59042 if (in_group_p(pid->pid_gid))
59043 return true;
59044 +
59045 return ptrace_may_access(task, PTRACE_MODE_READ);
59046 }
59047
59048 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59049 put_task_struct(task);
59050
59051 if (!has_perms) {
59052 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59053 + {
59054 +#else
59055 if (pid->hide_pid == 2) {
59056 +#endif
59057 /*
59058 * Let's make getdents(), stat(), and open()
59059 * consistent with each other. If a process
59060 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59061 if (!task)
59062 return -ESRCH;
59063
59064 + if (gr_acl_handle_procpidmem(task)) {
59065 + put_task_struct(task);
59066 + return -EPERM;
59067 + }
59068 +
59069 mm = mm_access(task, mode);
59070 put_task_struct(task);
59071
59072 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59073
59074 file->private_data = mm;
59075
59076 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59077 + file->f_version = current->exec_id;
59078 +#endif
59079 +
59080 return 0;
59081 }
59082
59083 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59084 ssize_t copied;
59085 char *page;
59086
59087 +#ifdef CONFIG_GRKERNSEC
59088 + if (write)
59089 + return -EPERM;
59090 +#endif
59091 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59092 + if (file->f_version != current->exec_id) {
59093 + gr_log_badprocpid("mem");
59094 + return 0;
59095 + }
59096 +#endif
59097 +
59098 if (!mm)
59099 return 0;
59100
59101 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59102 goto free;
59103
59104 while (count > 0) {
59105 - int this_len = min_t(int, count, PAGE_SIZE);
59106 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59107
59108 if (write && copy_from_user(page, buf, this_len)) {
59109 copied = -EFAULT;
59110 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59111 if (!mm)
59112 return 0;
59113
59114 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59115 + if (file->f_version != current->exec_id) {
59116 + gr_log_badprocpid("environ");
59117 + return 0;
59118 + }
59119 +#endif
59120 +
59121 page = (char *)__get_free_page(GFP_TEMPORARY);
59122 if (!page)
59123 return -ENOMEM;
59124 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59125 goto free;
59126 while (count > 0) {
59127 size_t this_len, max_len;
59128 - int retval;
59129 + ssize_t retval;
59130
59131 if (src >= (mm->env_end - mm->env_start))
59132 break;
59133 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59134 int error = -EACCES;
59135
59136 /* Are we allowed to snoop on the tasks file descriptors? */
59137 - if (!proc_fd_access_allowed(inode))
59138 + if (!proc_fd_access_allowed(inode, 0))
59139 goto out;
59140
59141 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59142 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59143 struct path path;
59144
59145 /* Are we allowed to snoop on the tasks file descriptors? */
59146 - if (!proc_fd_access_allowed(inode))
59147 - goto out;
59148 + /* logging this is needed for learning on chromium to work properly,
59149 + but we don't want to flood the logs from 'ps' which does a readlink
59150 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59151 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59152 + */
59153 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59154 + if (!proc_fd_access_allowed(inode,0))
59155 + goto out;
59156 + } else {
59157 + if (!proc_fd_access_allowed(inode,1))
59158 + goto out;
59159 + }
59160
59161 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59162 if (error)
59163 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59164 rcu_read_lock();
59165 cred = __task_cred(task);
59166 inode->i_uid = cred->euid;
59167 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59168 + inode->i_gid = grsec_proc_gid;
59169 +#else
59170 inode->i_gid = cred->egid;
59171 +#endif
59172 rcu_read_unlock();
59173 }
59174 security_task_to_inode(task, inode);
59175 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59176 return -ENOENT;
59177 }
59178 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59179 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59180 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59181 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59182 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59183 +#endif
59184 task_dumpable(task)) {
59185 cred = __task_cred(task);
59186 stat->uid = cred->euid;
59187 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59188 + stat->gid = grsec_proc_gid;
59189 +#else
59190 stat->gid = cred->egid;
59191 +#endif
59192 }
59193 }
59194 rcu_read_unlock();
59195 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59196
59197 if (task) {
59198 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59199 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59200 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59201 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59202 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59203 +#endif
59204 task_dumpable(task)) {
59205 rcu_read_lock();
59206 cred = __task_cred(task);
59207 inode->i_uid = cred->euid;
59208 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59209 + inode->i_gid = grsec_proc_gid;
59210 +#else
59211 inode->i_gid = cred->egid;
59212 +#endif
59213 rcu_read_unlock();
59214 } else {
59215 inode->i_uid = GLOBAL_ROOT_UID;
59216 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59217 if (!task)
59218 goto out_no_task;
59219
59220 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59221 + goto out;
59222 +
59223 /*
59224 * Yes, it does not scale. And it should not. Don't add
59225 * new entries into /proc/<tgid>/ without very good reasons.
59226 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59227 if (!task)
59228 return -ENOENT;
59229
59230 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59231 + goto out;
59232 +
59233 if (!dir_emit_dots(file, ctx))
59234 goto out;
59235
59236 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59237 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59238 #endif
59239 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59240 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59241 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59242 INF("syscall", S_IRUGO, proc_pid_syscall),
59243 #endif
59244 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59245 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59246 #ifdef CONFIG_SECURITY
59247 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59248 #endif
59249 -#ifdef CONFIG_KALLSYMS
59250 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59251 INF("wchan", S_IRUGO, proc_pid_wchan),
59252 #endif
59253 -#ifdef CONFIG_STACKTRACE
59254 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59255 ONE("stack", S_IRUGO, proc_pid_stack),
59256 #endif
59257 #ifdef CONFIG_SCHEDSTATS
59258 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59259 #ifdef CONFIG_HARDWALL
59260 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59261 #endif
59262 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59263 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59264 +#endif
59265 #ifdef CONFIG_USER_NS
59266 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59267 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59268 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59269 if (!inode)
59270 goto out;
59271
59272 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59273 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59274 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59275 + inode->i_gid = grsec_proc_gid;
59276 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59277 +#else
59278 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59279 +#endif
59280 inode->i_op = &proc_tgid_base_inode_operations;
59281 inode->i_fop = &proc_tgid_base_operations;
59282 inode->i_flags|=S_IMMUTABLE;
59283 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59284 if (!task)
59285 goto out;
59286
59287 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59288 + goto out_put_task;
59289 +
59290 result = proc_pid_instantiate(dir, dentry, task, NULL);
59291 +out_put_task:
59292 put_task_struct(task);
59293 out:
59294 return ERR_PTR(result);
59295 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59296 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59297 #endif
59298 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59299 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59300 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59301 INF("syscall", S_IRUGO, proc_pid_syscall),
59302 #endif
59303 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59304 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59305 #ifdef CONFIG_SECURITY
59306 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59307 #endif
59308 -#ifdef CONFIG_KALLSYMS
59309 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59310 INF("wchan", S_IRUGO, proc_pid_wchan),
59311 #endif
59312 -#ifdef CONFIG_STACKTRACE
59313 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59314 ONE("stack", S_IRUGO, proc_pid_stack),
59315 #endif
59316 #ifdef CONFIG_SCHEDSTATS
59317 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59318 index 82676e3..5f8518a 100644
59319 --- a/fs/proc/cmdline.c
59320 +++ b/fs/proc/cmdline.c
59321 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59322
59323 static int __init proc_cmdline_init(void)
59324 {
59325 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59326 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59327 +#else
59328 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59329 +#endif
59330 return 0;
59331 }
59332 module_init(proc_cmdline_init);
59333 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59334 index b143471..bb105e5 100644
59335 --- a/fs/proc/devices.c
59336 +++ b/fs/proc/devices.c
59337 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59338
59339 static int __init proc_devices_init(void)
59340 {
59341 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59342 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59343 +#else
59344 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59345 +#endif
59346 return 0;
59347 }
59348 module_init(proc_devices_init);
59349 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59350 index 0ff80f9..a1d7500 100644
59351 --- a/fs/proc/fd.c
59352 +++ b/fs/proc/fd.c
59353 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59354 if (!task)
59355 return -ENOENT;
59356
59357 - files = get_files_struct(task);
59358 + if (!gr_acl_handle_procpidmem(task))
59359 + files = get_files_struct(task);
59360 put_task_struct(task);
59361
59362 if (files) {
59363 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59364 */
59365 int proc_fd_permission(struct inode *inode, int mask)
59366 {
59367 + struct task_struct *task;
59368 int rv = generic_permission(inode, mask);
59369 - if (rv == 0)
59370 - return 0;
59371 +
59372 if (task_pid(current) == proc_pid(inode))
59373 rv = 0;
59374 +
59375 + task = get_proc_task(inode);
59376 + if (task == NULL)
59377 + return rv;
59378 +
59379 + if (gr_acl_handle_procpidmem(task))
59380 + rv = -EACCES;
59381 +
59382 + put_task_struct(task);
59383 +
59384 return rv;
59385 }
59386
59387 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59388 index 073aea6..0630370 100644
59389 --- a/fs/proc/inode.c
59390 +++ b/fs/proc/inode.c
59391 @@ -23,11 +23,17 @@
59392 #include <linux/slab.h>
59393 #include <linux/mount.h>
59394 #include <linux/magic.h>
59395 +#include <linux/grsecurity.h>
59396
59397 #include <asm/uaccess.h>
59398
59399 #include "internal.h"
59400
59401 +#ifdef CONFIG_PROC_SYSCTL
59402 +extern const struct inode_operations proc_sys_inode_operations;
59403 +extern const struct inode_operations proc_sys_dir_operations;
59404 +#endif
59405 +
59406 static void proc_evict_inode(struct inode *inode)
59407 {
59408 struct proc_dir_entry *de;
59409 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59410 ns = PROC_I(inode)->ns.ns;
59411 if (ns_ops && ns)
59412 ns_ops->put(ns);
59413 +
59414 +#ifdef CONFIG_PROC_SYSCTL
59415 + if (inode->i_op == &proc_sys_inode_operations ||
59416 + inode->i_op == &proc_sys_dir_operations)
59417 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59418 +#endif
59419 +
59420 }
59421
59422 static struct kmem_cache * proc_inode_cachep;
59423 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59424 if (de->mode) {
59425 inode->i_mode = de->mode;
59426 inode->i_uid = de->uid;
59427 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59428 + inode->i_gid = grsec_proc_gid;
59429 +#else
59430 inode->i_gid = de->gid;
59431 +#endif
59432 }
59433 if (de->size)
59434 inode->i_size = de->size;
59435 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59436 index 651d09a..60c73ae 100644
59437 --- a/fs/proc/internal.h
59438 +++ b/fs/proc/internal.h
59439 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59440 struct pid *, struct task_struct *);
59441 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59442 struct pid *, struct task_struct *);
59443 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59444 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59445 +#endif
59446
59447 /*
59448 * base.c
59449 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59450 index 06ea155..9a798c7 100644
59451 --- a/fs/proc/kcore.c
59452 +++ b/fs/proc/kcore.c
59453 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59454 * the addresses in the elf_phdr on our list.
59455 */
59456 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59457 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59458 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59459 + if (tsz > buflen)
59460 tsz = buflen;
59461 -
59462 +
59463 while (buflen) {
59464 struct kcore_list *m;
59465
59466 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59467 kfree(elf_buf);
59468 } else {
59469 if (kern_addr_valid(start)) {
59470 - unsigned long n;
59471 + char *elf_buf;
59472 + mm_segment_t oldfs;
59473
59474 - n = copy_to_user(buffer, (char *)start, tsz);
59475 - /*
59476 - * We cannot distinguish between fault on source
59477 - * and fault on destination. When this happens
59478 - * we clear too and hope it will trigger the
59479 - * EFAULT again.
59480 - */
59481 - if (n) {
59482 - if (clear_user(buffer + tsz - n,
59483 - n))
59484 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59485 + if (!elf_buf)
59486 + return -ENOMEM;
59487 + oldfs = get_fs();
59488 + set_fs(KERNEL_DS);
59489 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59490 + set_fs(oldfs);
59491 + if (copy_to_user(buffer, elf_buf, tsz)) {
59492 + kfree(elf_buf);
59493 return -EFAULT;
59494 + }
59495 }
59496 + set_fs(oldfs);
59497 + kfree(elf_buf);
59498 } else {
59499 if (clear_user(buffer, tsz))
59500 return -EFAULT;
59501 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59502
59503 static int open_kcore(struct inode *inode, struct file *filp)
59504 {
59505 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59506 + return -EPERM;
59507 +#endif
59508 if (!capable(CAP_SYS_RAWIO))
59509 return -EPERM;
59510 if (kcore_need_update)
59511 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59512 index 5aa847a..f77c8d4 100644
59513 --- a/fs/proc/meminfo.c
59514 +++ b/fs/proc/meminfo.c
59515 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59516 vmi.used >> 10,
59517 vmi.largest_chunk >> 10
59518 #ifdef CONFIG_MEMORY_FAILURE
59519 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59520 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59521 #endif
59522 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59523 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59524 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59525 index ccfd99b..1b7e255 100644
59526 --- a/fs/proc/nommu.c
59527 +++ b/fs/proc/nommu.c
59528 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59529 if (len < 1)
59530 len = 1;
59531 seq_printf(m, "%*c", len, ' ');
59532 - seq_path(m, &file->f_path, "");
59533 + seq_path(m, &file->f_path, "\n\\");
59534 }
59535
59536 seq_putc(m, '\n');
59537 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59538 index 4677bb7..408e936 100644
59539 --- a/fs/proc/proc_net.c
59540 +++ b/fs/proc/proc_net.c
59541 @@ -23,6 +23,7 @@
59542 #include <linux/nsproxy.h>
59543 #include <net/net_namespace.h>
59544 #include <linux/seq_file.h>
59545 +#include <linux/grsecurity.h>
59546
59547 #include "internal.h"
59548
59549 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59550 struct task_struct *task;
59551 struct nsproxy *ns;
59552 struct net *net = NULL;
59553 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59554 + const struct cred *cred = current_cred();
59555 +#endif
59556 +
59557 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59558 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59559 + return net;
59560 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59561 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59562 + return net;
59563 +#endif
59564
59565 rcu_read_lock();
59566 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59567 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59568 index 7129046..f2779c6 100644
59569 --- a/fs/proc/proc_sysctl.c
59570 +++ b/fs/proc/proc_sysctl.c
59571 @@ -13,11 +13,15 @@
59572 #include <linux/module.h>
59573 #include "internal.h"
59574
59575 +extern int gr_handle_chroot_sysctl(const int op);
59576 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59577 + const int op);
59578 +
59579 static const struct dentry_operations proc_sys_dentry_operations;
59580 static const struct file_operations proc_sys_file_operations;
59581 -static const struct inode_operations proc_sys_inode_operations;
59582 +const struct inode_operations proc_sys_inode_operations;
59583 static const struct file_operations proc_sys_dir_file_operations;
59584 -static const struct inode_operations proc_sys_dir_operations;
59585 +const struct inode_operations proc_sys_dir_operations;
59586
59587 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59588 {
59589 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59590
59591 err = NULL;
59592 d_set_d_op(dentry, &proc_sys_dentry_operations);
59593 +
59594 + gr_handle_proc_create(dentry, inode);
59595 +
59596 d_add(dentry, inode);
59597
59598 out:
59599 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59600 struct inode *inode = file_inode(filp);
59601 struct ctl_table_header *head = grab_header(inode);
59602 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59603 + int op = write ? MAY_WRITE : MAY_READ;
59604 ssize_t error;
59605 size_t res;
59606
59607 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59608 * and won't be until we finish.
59609 */
59610 error = -EPERM;
59611 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59612 + if (sysctl_perm(head, table, op))
59613 goto out;
59614
59615 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59616 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59617 if (!table->proc_handler)
59618 goto out;
59619
59620 +#ifdef CONFIG_GRKERNSEC
59621 + error = -EPERM;
59622 + if (gr_handle_chroot_sysctl(op))
59623 + goto out;
59624 + dget(filp->f_path.dentry);
59625 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59626 + dput(filp->f_path.dentry);
59627 + goto out;
59628 + }
59629 + dput(filp->f_path.dentry);
59630 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59631 + goto out;
59632 + if (write && !capable(CAP_SYS_ADMIN))
59633 + goto out;
59634 +#endif
59635 +
59636 /* careful: calling conventions are nasty here */
59637 res = count;
59638 error = table->proc_handler(table, write, buf, &res, ppos);
59639 @@ -598,6 +622,9 @@ static bool proc_sys_fill_cache(struct file *file,
59640 return false;
59641 } else {
59642 d_set_d_op(child, &proc_sys_dentry_operations);
59643 +
59644 + gr_handle_proc_create(child, inode);
59645 +
59646 d_add(child, inode);
59647 }
59648 } else {
59649 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59650 if ((*pos)++ < ctx->pos)
59651 return true;
59652
59653 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59654 + return 0;
59655 +
59656 if (unlikely(S_ISLNK(table->mode)))
59657 res = proc_sys_link_fill_cache(file, ctx, head, table);
59658 else
59659 @@ -734,6 +764,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59660 if (IS_ERR(head))
59661 return PTR_ERR(head);
59662
59663 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59664 + return -ENOENT;
59665 +
59666 generic_fillattr(inode, stat);
59667 if (table)
59668 stat->mode = (stat->mode & S_IFMT) | table->mode;
59669 @@ -756,13 +789,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59670 .llseek = generic_file_llseek,
59671 };
59672
59673 -static const struct inode_operations proc_sys_inode_operations = {
59674 +const struct inode_operations proc_sys_inode_operations = {
59675 .permission = proc_sys_permission,
59676 .setattr = proc_sys_setattr,
59677 .getattr = proc_sys_getattr,
59678 };
59679
59680 -static const struct inode_operations proc_sys_dir_operations = {
59681 +const struct inode_operations proc_sys_dir_operations = {
59682 .lookup = proc_sys_lookup,
59683 .permission = proc_sys_permission,
59684 .setattr = proc_sys_setattr,
59685 @@ -839,7 +872,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59686 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59687 const char *name, int namelen)
59688 {
59689 - struct ctl_table *table;
59690 + ctl_table_no_const *table;
59691 struct ctl_dir *new;
59692 struct ctl_node *node;
59693 char *new_name;
59694 @@ -851,7 +884,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59695 return NULL;
59696
59697 node = (struct ctl_node *)(new + 1);
59698 - table = (struct ctl_table *)(node + 1);
59699 + table = (ctl_table_no_const *)(node + 1);
59700 new_name = (char *)(table + 2);
59701 memcpy(new_name, name, namelen);
59702 new_name[namelen] = '\0';
59703 @@ -1020,7 +1053,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59704 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59705 struct ctl_table_root *link_root)
59706 {
59707 - struct ctl_table *link_table, *entry, *link;
59708 + ctl_table_no_const *link_table, *link;
59709 + struct ctl_table *entry;
59710 struct ctl_table_header *links;
59711 struct ctl_node *node;
59712 char *link_name;
59713 @@ -1043,7 +1077,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59714 return NULL;
59715
59716 node = (struct ctl_node *)(links + 1);
59717 - link_table = (struct ctl_table *)(node + nr_entries);
59718 + link_table = (ctl_table_no_const *)(node + nr_entries);
59719 link_name = (char *)&link_table[nr_entries + 1];
59720
59721 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59722 @@ -1291,8 +1325,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59723 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59724 struct ctl_table *table)
59725 {
59726 - struct ctl_table *ctl_table_arg = NULL;
59727 - struct ctl_table *entry, *files;
59728 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59729 + struct ctl_table *entry;
59730 int nr_files = 0;
59731 int nr_dirs = 0;
59732 int err = -ENOMEM;
59733 @@ -1304,10 +1338,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59734 nr_files++;
59735 }
59736
59737 - files = table;
59738 /* If there are mixed files and directories we need a new table */
59739 if (nr_dirs && nr_files) {
59740 - struct ctl_table *new;
59741 + ctl_table_no_const *new;
59742 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59743 GFP_KERNEL);
59744 if (!files)
59745 @@ -1325,7 +1358,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59746 /* Register everything except a directory full of subdirectories */
59747 if (nr_files || !nr_dirs) {
59748 struct ctl_table_header *header;
59749 - header = __register_sysctl_table(set, path, files);
59750 + header = __register_sysctl_table(set, path, files ? files : table);
59751 if (!header) {
59752 kfree(ctl_table_arg);
59753 goto out;
59754 diff --git a/fs/proc/root.c b/fs/proc/root.c
59755 index 0e0e83c..005ba6a 100644
59756 --- a/fs/proc/root.c
59757 +++ b/fs/proc/root.c
59758 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
59759 #ifdef CONFIG_PROC_DEVICETREE
59760 proc_device_tree_init();
59761 #endif
59762 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59763 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59764 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
59765 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59766 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
59767 +#endif
59768 +#else
59769 proc_mkdir("bus", NULL);
59770 +#endif
59771 proc_sys_init();
59772 }
59773
59774 diff --git a/fs/proc/self.c b/fs/proc/self.c
59775 index 6b6a993..807cccc 100644
59776 --- a/fs/proc/self.c
59777 +++ b/fs/proc/self.c
59778 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
59779 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
59780 void *cookie)
59781 {
59782 - char *s = nd_get_link(nd);
59783 + const char *s = nd_get_link(nd);
59784 if (!IS_ERR(s))
59785 kfree(s);
59786 }
59787 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
59788 index 107d026..c715aeb 100644
59789 --- a/fs/proc/task_mmu.c
59790 +++ b/fs/proc/task_mmu.c
59791 @@ -12,12 +12,19 @@
59792 #include <linux/swap.h>
59793 #include <linux/swapops.h>
59794 #include <linux/mmu_notifier.h>
59795 +#include <linux/grsecurity.h>
59796
59797 #include <asm/elf.h>
59798 #include <asm/uaccess.h>
59799 #include <asm/tlbflush.h>
59800 #include "internal.h"
59801
59802 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59803 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59804 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59805 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59806 +#endif
59807 +
59808 void task_mem(struct seq_file *m, struct mm_struct *mm)
59809 {
59810 unsigned long data, text, lib, swap;
59811 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59812 "VmExe:\t%8lu kB\n"
59813 "VmLib:\t%8lu kB\n"
59814 "VmPTE:\t%8lu kB\n"
59815 - "VmSwap:\t%8lu kB\n",
59816 - hiwater_vm << (PAGE_SHIFT-10),
59817 + "VmSwap:\t%8lu kB\n"
59818 +
59819 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59820 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
59821 +#endif
59822 +
59823 + ,hiwater_vm << (PAGE_SHIFT-10),
59824 total_vm << (PAGE_SHIFT-10),
59825 mm->locked_vm << (PAGE_SHIFT-10),
59826 mm->pinned_vm << (PAGE_SHIFT-10),
59827 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59828 data << (PAGE_SHIFT-10),
59829 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
59830 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
59831 - swap << (PAGE_SHIFT-10));
59832 + swap << (PAGE_SHIFT-10)
59833 +
59834 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59835 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59836 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
59837 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
59838 +#else
59839 + , mm->context.user_cs_base
59840 + , mm->context.user_cs_limit
59841 +#endif
59842 +#endif
59843 +
59844 + );
59845 }
59846
59847 unsigned long task_vsize(struct mm_struct *mm)
59848 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59849 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
59850 }
59851
59852 - /* We don't show the stack guard page in /proc/maps */
59853 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59854 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
59855 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
59856 +#else
59857 start = vma->vm_start;
59858 - if (stack_guard_page_start(vma, start))
59859 - start += PAGE_SIZE;
59860 end = vma->vm_end;
59861 - if (stack_guard_page_end(vma, end))
59862 - end -= PAGE_SIZE;
59863 +#endif
59864
59865 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
59866 start,
59867 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59868 flags & VM_WRITE ? 'w' : '-',
59869 flags & VM_EXEC ? 'x' : '-',
59870 flags & VM_MAYSHARE ? 's' : 'p',
59871 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59872 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
59873 +#else
59874 pgoff,
59875 +#endif
59876 MAJOR(dev), MINOR(dev), ino, &len);
59877
59878 /*
59879 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59880 */
59881 if (file) {
59882 pad_len_spaces(m, len);
59883 - seq_path(m, &file->f_path, "\n");
59884 + seq_path(m, &file->f_path, "\n\\");
59885 goto done;
59886 }
59887
59888 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59889 * Thread stack in /proc/PID/task/TID/maps or
59890 * the main process stack.
59891 */
59892 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
59893 - vma->vm_end >= mm->start_stack)) {
59894 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
59895 + (vma->vm_start <= mm->start_stack &&
59896 + vma->vm_end >= mm->start_stack)) {
59897 name = "[stack]";
59898 } else {
59899 /* Thread stack in /proc/PID/maps */
59900 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
59901 struct proc_maps_private *priv = m->private;
59902 struct task_struct *task = priv->task;
59903
59904 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59905 + if (current->exec_id != m->exec_id) {
59906 + gr_log_badprocpid("maps");
59907 + return 0;
59908 + }
59909 +#endif
59910 +
59911 show_map_vma(m, vma, is_pid);
59912
59913 if (m->count < m->size) /* vma is copied successfully */
59914 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
59915 .private = &mss,
59916 };
59917
59918 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59919 + if (current->exec_id != m->exec_id) {
59920 + gr_log_badprocpid("smaps");
59921 + return 0;
59922 + }
59923 +#endif
59924 memset(&mss, 0, sizeof mss);
59925 - mss.vma = vma;
59926 - /* mmap_sem is held in m_start */
59927 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
59928 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
59929 -
59930 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59931 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
59932 +#endif
59933 + mss.vma = vma;
59934 + /* mmap_sem is held in m_start */
59935 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
59936 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
59937 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59938 + }
59939 +#endif
59940 show_map_vma(m, vma, is_pid);
59941
59942 seq_printf(m,
59943 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
59944 "KernelPageSize: %8lu kB\n"
59945 "MMUPageSize: %8lu kB\n"
59946 "Locked: %8lu kB\n",
59947 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59948 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
59949 +#else
59950 (vma->vm_end - vma->vm_start) >> 10,
59951 +#endif
59952 mss.resident >> 10,
59953 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
59954 mss.shared_clean >> 10,
59955 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
59956 int n;
59957 char buffer[50];
59958
59959 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59960 + if (current->exec_id != m->exec_id) {
59961 + gr_log_badprocpid("numa_maps");
59962 + return 0;
59963 + }
59964 +#endif
59965 +
59966 if (!mm)
59967 return 0;
59968
59969 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
59970 mpol_to_str(buffer, sizeof(buffer), pol);
59971 mpol_cond_put(pol);
59972
59973 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59974 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
59975 +#else
59976 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
59977 +#endif
59978
59979 if (file) {
59980 seq_printf(m, " file=");
59981 - seq_path(m, &file->f_path, "\n\t= ");
59982 + seq_path(m, &file->f_path, "\n\t\\= ");
59983 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
59984 seq_printf(m, " heap");
59985 } else {
59986 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
59987 index 56123a6..5a2f6ec 100644
59988 --- a/fs/proc/task_nommu.c
59989 +++ b/fs/proc/task_nommu.c
59990 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59991 else
59992 bytes += kobjsize(mm);
59993
59994 - if (current->fs && current->fs->users > 1)
59995 + if (current->fs && atomic_read(&current->fs->users) > 1)
59996 sbytes += kobjsize(current->fs);
59997 else
59998 bytes += kobjsize(current->fs);
59999 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60000
60001 if (file) {
60002 pad_len_spaces(m, len);
60003 - seq_path(m, &file->f_path, "");
60004 + seq_path(m, &file->f_path, "\n\\");
60005 } else if (mm) {
60006 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60007
60008 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60009 index a1a16eb..6be46ed 100644
60010 --- a/fs/proc/vmcore.c
60011 +++ b/fs/proc/vmcore.c
60012 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60013 nr_bytes = count;
60014
60015 /* If pfn is not ram, return zeros for sparse dump files */
60016 - if (pfn_is_ram(pfn) == 0)
60017 - memset(buf, 0, nr_bytes);
60018 - else {
60019 + if (pfn_is_ram(pfn) == 0) {
60020 + if (userbuf) {
60021 + if (clear_user((char __force_user *)buf, nr_bytes))
60022 + return -EFAULT;
60023 + } else
60024 + memset(buf, 0, nr_bytes);
60025 + } else {
60026 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60027 offset, userbuf);
60028 if (tmp < 0)
60029 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60030 if (*fpos < m->offset + m->size) {
60031 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60032 start = m->paddr + *fpos - m->offset;
60033 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60034 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60035 if (tmp < 0)
60036 return tmp;
60037 buflen -= tsz;
60038 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60039 index b00fcc9..e0c6381 100644
60040 --- a/fs/qnx6/qnx6.h
60041 +++ b/fs/qnx6/qnx6.h
60042 @@ -74,7 +74,7 @@ enum {
60043 BYTESEX_BE,
60044 };
60045
60046 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60047 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60048 {
60049 if (sbi->s_bytesex == BYTESEX_LE)
60050 return le64_to_cpu((__force __le64)n);
60051 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60052 return (__force __fs64)cpu_to_be64(n);
60053 }
60054
60055 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60056 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60057 {
60058 if (sbi->s_bytesex == BYTESEX_LE)
60059 return le32_to_cpu((__force __le32)n);
60060 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60061 index 16e8abb..2dcf914 100644
60062 --- a/fs/quota/netlink.c
60063 +++ b/fs/quota/netlink.c
60064 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60065 void quota_send_warning(struct kqid qid, dev_t dev,
60066 const char warntype)
60067 {
60068 - static atomic_t seq;
60069 + static atomic_unchecked_t seq;
60070 struct sk_buff *skb;
60071 void *msg_head;
60072 int ret;
60073 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60074 "VFS: Not enough memory to send quota warning.\n");
60075 return;
60076 }
60077 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60078 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60079 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60080 if (!msg_head) {
60081 printk(KERN_ERR
60082 diff --git a/fs/read_write.c b/fs/read_write.c
60083 index 122a384..0b7ecf2 100644
60084 --- a/fs/read_write.c
60085 +++ b/fs/read_write.c
60086 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60087
60088 old_fs = get_fs();
60089 set_fs(get_ds());
60090 - p = (__force const char __user *)buf;
60091 + p = (const char __force_user *)buf;
60092 if (count > MAX_RW_COUNT)
60093 count = MAX_RW_COUNT;
60094 if (file->f_op->write)
60095 diff --git a/fs/readdir.c b/fs/readdir.c
60096 index 93d71e5..6a14be8 100644
60097 --- a/fs/readdir.c
60098 +++ b/fs/readdir.c
60099 @@ -17,6 +17,7 @@
60100 #include <linux/security.h>
60101 #include <linux/syscalls.h>
60102 #include <linux/unistd.h>
60103 +#include <linux/namei.h>
60104
60105 #include <asm/uaccess.h>
60106
60107 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60108 struct readdir_callback {
60109 struct dir_context ctx;
60110 struct old_linux_dirent __user * dirent;
60111 + struct file * file;
60112 int result;
60113 };
60114
60115 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60116 buf->result = -EOVERFLOW;
60117 return -EOVERFLOW;
60118 }
60119 +
60120 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60121 + return 0;
60122 +
60123 buf->result++;
60124 dirent = buf->dirent;
60125 if (!access_ok(VERIFY_WRITE, dirent,
60126 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60127 if (!f.file)
60128 return -EBADF;
60129
60130 + buf.file = f.file;
60131 error = iterate_dir(f.file, &buf.ctx);
60132 if (buf.result)
60133 error = buf.result;
60134 @@ -142,6 +149,7 @@ struct getdents_callback {
60135 struct dir_context ctx;
60136 struct linux_dirent __user * current_dir;
60137 struct linux_dirent __user * previous;
60138 + struct file * file;
60139 int count;
60140 int error;
60141 };
60142 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60143 buf->error = -EOVERFLOW;
60144 return -EOVERFLOW;
60145 }
60146 +
60147 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60148 + return 0;
60149 +
60150 dirent = buf->previous;
60151 if (dirent) {
60152 if (__put_user(offset, &dirent->d_off))
60153 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60154 if (!f.file)
60155 return -EBADF;
60156
60157 + buf.file = f.file;
60158 error = iterate_dir(f.file, &buf.ctx);
60159 if (error >= 0)
60160 error = buf.error;
60161 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60162 struct dir_context ctx;
60163 struct linux_dirent64 __user * current_dir;
60164 struct linux_dirent64 __user * previous;
60165 + struct file *file;
60166 int count;
60167 int error;
60168 };
60169 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60170 buf->error = -EINVAL; /* only used if we fail.. */
60171 if (reclen > buf->count)
60172 return -EINVAL;
60173 +
60174 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60175 + return 0;
60176 +
60177 dirent = buf->previous;
60178 if (dirent) {
60179 if (__put_user(offset, &dirent->d_off))
60180 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60181 if (!f.file)
60182 return -EBADF;
60183
60184 + buf.file = f.file;
60185 error = iterate_dir(f.file, &buf.ctx);
60186 if (error >= 0)
60187 error = buf.error;
60188 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60189 index 2b7882b..1c5ef48 100644
60190 --- a/fs/reiserfs/do_balan.c
60191 +++ b/fs/reiserfs/do_balan.c
60192 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60193 return;
60194 }
60195
60196 - atomic_inc(&(fs_generation(tb->tb_sb)));
60197 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60198 do_balance_starts(tb);
60199
60200 /* balance leaf returns 0 except if combining L R and S into
60201 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60202 index a958444..42b2323 100644
60203 --- a/fs/reiserfs/procfs.c
60204 +++ b/fs/reiserfs/procfs.c
60205 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60206 "SMALL_TAILS " : "NO_TAILS ",
60207 replay_only(sb) ? "REPLAY_ONLY " : "",
60208 convert_reiserfs(sb) ? "CONV " : "",
60209 - atomic_read(&r->s_generation_counter),
60210 + atomic_read_unchecked(&r->s_generation_counter),
60211 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60212 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60213 SF(s_good_search_by_key_reada), SF(s_bmaps),
60214 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60215 index 3df5ce6..8c0f4b0 100644
60216 --- a/fs/reiserfs/reiserfs.h
60217 +++ b/fs/reiserfs/reiserfs.h
60218 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60219 /* Comment? -Hans */
60220 wait_queue_head_t s_wait;
60221 /* To be obsoleted soon by per buffer seals.. -Hans */
60222 - atomic_t s_generation_counter; // increased by one every time the
60223 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60224 // tree gets re-balanced
60225 unsigned long s_properties; /* File system properties. Currently holds
60226 on-disk FS format */
60227 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60228 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60229
60230 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60231 -#define get_generation(s) atomic_read (&fs_generation(s))
60232 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60233 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60234 #define __fs_changed(gen,s) (gen != get_generation (s))
60235 #define fs_changed(gen,s) \
60236 diff --git a/fs/select.c b/fs/select.c
60237 index 35d4adc7..d6c60db 100644
60238 --- a/fs/select.c
60239 +++ b/fs/select.c
60240 @@ -20,6 +20,7 @@
60241 #include <linux/export.h>
60242 #include <linux/slab.h>
60243 #include <linux/poll.h>
60244 +#include <linux/security.h>
60245 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60246 #include <linux/file.h>
60247 #include <linux/fdtable.h>
60248 @@ -881,6 +882,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60249 struct poll_list *walk = head;
60250 unsigned long todo = nfds;
60251
60252 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60253 if (nfds > rlimit(RLIMIT_NOFILE))
60254 return -EINVAL;
60255
60256 diff --git a/fs/seq_file.c b/fs/seq_file.c
60257 index 3135c25..d0395dd 100644
60258 --- a/fs/seq_file.c
60259 +++ b/fs/seq_file.c
60260 @@ -10,6 +10,7 @@
60261 #include <linux/seq_file.h>
60262 #include <linux/slab.h>
60263 #include <linux/cred.h>
60264 +#include <linux/sched.h>
60265
60266 #include <asm/uaccess.h>
60267 #include <asm/page.h>
60268 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60269 #ifdef CONFIG_USER_NS
60270 p->user_ns = file->f_cred->user_ns;
60271 #endif
60272 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60273 + p->exec_id = current->exec_id;
60274 +#endif
60275
60276 /*
60277 * Wrappers around seq_open(e.g. swaps_open) need to be
60278 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60279 return 0;
60280 }
60281 if (!m->buf) {
60282 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60283 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60284 if (!m->buf)
60285 return -ENOMEM;
60286 }
60287 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60288 Eoverflow:
60289 m->op->stop(m, p);
60290 kfree(m->buf);
60291 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60292 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60293 return !m->buf ? -ENOMEM : -EAGAIN;
60294 }
60295
60296 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60297
60298 /* grab buffer if we didn't have one */
60299 if (!m->buf) {
60300 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60301 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60302 if (!m->buf)
60303 goto Enomem;
60304 }
60305 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60306 goto Fill;
60307 m->op->stop(m, p);
60308 kfree(m->buf);
60309 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60310 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60311 if (!m->buf)
60312 goto Enomem;
60313 m->count = 0;
60314 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
60315 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60316 void *data)
60317 {
60318 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60319 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60320 int res = -ENOMEM;
60321
60322 if (op) {
60323 diff --git a/fs/splice.c b/fs/splice.c
60324 index 3b7ee65..87fc2e4 100644
60325 --- a/fs/splice.c
60326 +++ b/fs/splice.c
60327 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60328 pipe_lock(pipe);
60329
60330 for (;;) {
60331 - if (!pipe->readers) {
60332 + if (!atomic_read(&pipe->readers)) {
60333 send_sig(SIGPIPE, current, 0);
60334 if (!ret)
60335 ret = -EPIPE;
60336 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60337 page_nr++;
60338 ret += buf->len;
60339
60340 - if (pipe->files)
60341 + if (atomic_read(&pipe->files))
60342 do_wakeup = 1;
60343
60344 if (!--spd->nr_pages)
60345 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60346 do_wakeup = 0;
60347 }
60348
60349 - pipe->waiting_writers++;
60350 + atomic_inc(&pipe->waiting_writers);
60351 pipe_wait(pipe);
60352 - pipe->waiting_writers--;
60353 + atomic_dec(&pipe->waiting_writers);
60354 }
60355
60356 pipe_unlock(pipe);
60357 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60358 old_fs = get_fs();
60359 set_fs(get_ds());
60360 /* The cast to a user pointer is valid due to the set_fs() */
60361 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60362 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60363 set_fs(old_fs);
60364
60365 return res;
60366 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60367 old_fs = get_fs();
60368 set_fs(get_ds());
60369 /* The cast to a user pointer is valid due to the set_fs() */
60370 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60371 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60372 set_fs(old_fs);
60373
60374 return res;
60375 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60376 goto err;
60377
60378 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60379 - vec[i].iov_base = (void __user *) page_address(page);
60380 + vec[i].iov_base = (void __force_user *) page_address(page);
60381 vec[i].iov_len = this_len;
60382 spd.pages[i] = page;
60383 spd.nr_pages++;
60384 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60385 ops->release(pipe, buf);
60386 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60387 pipe->nrbufs--;
60388 - if (pipe->files)
60389 + if (atomic_read(&pipe->files))
60390 sd->need_wakeup = true;
60391 }
60392
60393 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60394 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60395 {
60396 while (!pipe->nrbufs) {
60397 - if (!pipe->writers)
60398 + if (!atomic_read(&pipe->writers))
60399 return 0;
60400
60401 - if (!pipe->waiting_writers && sd->num_spliced)
60402 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60403 return 0;
60404
60405 if (sd->flags & SPLICE_F_NONBLOCK)
60406 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60407 * out of the pipe right after the splice_to_pipe(). So set
60408 * PIPE_READERS appropriately.
60409 */
60410 - pipe->readers = 1;
60411 + atomic_set(&pipe->readers, 1);
60412
60413 current->splice_pipe = pipe;
60414 }
60415 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60416
60417 partial[buffers].offset = off;
60418 partial[buffers].len = plen;
60419 + partial[buffers].private = 0;
60420
60421 off = 0;
60422 len -= plen;
60423 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60424 ret = -ERESTARTSYS;
60425 break;
60426 }
60427 - if (!pipe->writers)
60428 + if (!atomic_read(&pipe->writers))
60429 break;
60430 - if (!pipe->waiting_writers) {
60431 + if (!atomic_read(&pipe->waiting_writers)) {
60432 if (flags & SPLICE_F_NONBLOCK) {
60433 ret = -EAGAIN;
60434 break;
60435 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60436 pipe_lock(pipe);
60437
60438 while (pipe->nrbufs >= pipe->buffers) {
60439 - if (!pipe->readers) {
60440 + if (!atomic_read(&pipe->readers)) {
60441 send_sig(SIGPIPE, current, 0);
60442 ret = -EPIPE;
60443 break;
60444 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60445 ret = -ERESTARTSYS;
60446 break;
60447 }
60448 - pipe->waiting_writers++;
60449 + atomic_inc(&pipe->waiting_writers);
60450 pipe_wait(pipe);
60451 - pipe->waiting_writers--;
60452 + atomic_dec(&pipe->waiting_writers);
60453 }
60454
60455 pipe_unlock(pipe);
60456 @@ -1862,14 +1863,14 @@ retry:
60457 pipe_double_lock(ipipe, opipe);
60458
60459 do {
60460 - if (!opipe->readers) {
60461 + if (!atomic_read(&opipe->readers)) {
60462 send_sig(SIGPIPE, current, 0);
60463 if (!ret)
60464 ret = -EPIPE;
60465 break;
60466 }
60467
60468 - if (!ipipe->nrbufs && !ipipe->writers)
60469 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60470 break;
60471
60472 /*
60473 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60474 pipe_double_lock(ipipe, opipe);
60475
60476 do {
60477 - if (!opipe->readers) {
60478 + if (!atomic_read(&opipe->readers)) {
60479 send_sig(SIGPIPE, current, 0);
60480 if (!ret)
60481 ret = -EPIPE;
60482 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60483 * return EAGAIN if we have the potential of some data in the
60484 * future, otherwise just return 0
60485 */
60486 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60487 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60488 ret = -EAGAIN;
60489
60490 pipe_unlock(ipipe);
60491 diff --git a/fs/stat.c b/fs/stat.c
60492 index 04ce1ac..a13dd1e 100644
60493 --- a/fs/stat.c
60494 +++ b/fs/stat.c
60495 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60496 stat->gid = inode->i_gid;
60497 stat->rdev = inode->i_rdev;
60498 stat->size = i_size_read(inode);
60499 - stat->atime = inode->i_atime;
60500 - stat->mtime = inode->i_mtime;
60501 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60502 + stat->atime = inode->i_ctime;
60503 + stat->mtime = inode->i_ctime;
60504 + } else {
60505 + stat->atime = inode->i_atime;
60506 + stat->mtime = inode->i_mtime;
60507 + }
60508 stat->ctime = inode->i_ctime;
60509 stat->blksize = (1 << inode->i_blkbits);
60510 stat->blocks = inode->i_blocks;
60511 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60512 if (retval)
60513 return retval;
60514
60515 - if (inode->i_op->getattr)
60516 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60517 + if (inode->i_op->getattr) {
60518 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60519 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60520 + stat->atime = stat->ctime;
60521 + stat->mtime = stat->ctime;
60522 + }
60523 + return retval;
60524 + }
60525
60526 generic_fillattr(inode, stat);
60527 return 0;
60528 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60529 index 15c68f9..36a8b3e 100644
60530 --- a/fs/sysfs/bin.c
60531 +++ b/fs/sysfs/bin.c
60532 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60533 return ret;
60534 }
60535
60536 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60537 - void *buf, int len, int write)
60538 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60539 + void *buf, size_t len, int write)
60540 {
60541 struct file *file = vma->vm_file;
60542 struct bin_buffer *bb = file->private_data;
60543 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60544 - int ret;
60545 + ssize_t ret;
60546
60547 if (!bb->vm_ops)
60548 return -EINVAL;
60549 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60550 index e068e74..92edeb8 100644
60551 --- a/fs/sysfs/dir.c
60552 +++ b/fs/sysfs/dir.c
60553 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60554 *
60555 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60556 */
60557 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60558 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60559 {
60560 unsigned long hash = init_name_hash();
60561 unsigned int len = strlen(name);
60562 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60563 struct sysfs_dirent *sd;
60564 int rc;
60565
60566 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60567 + const char *parent_name = parent_sd->s_name;
60568 +
60569 + mode = S_IFDIR | S_IRWXU;
60570 +
60571 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60572 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60573 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60574 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60575 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60576 +#endif
60577 +
60578 /* allocate */
60579 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60580 if (!sd)
60581 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60582 index d2bb7ed..fe8c331 100644
60583 --- a/fs/sysfs/file.c
60584 +++ b/fs/sysfs/file.c
60585 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60586
60587 struct sysfs_open_dirent {
60588 atomic_t refcnt;
60589 - atomic_t event;
60590 + atomic_unchecked_t event;
60591 wait_queue_head_t poll;
60592 struct list_head buffers; /* goes through sysfs_buffer.list */
60593 };
60594 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60595 if (!sysfs_get_active(attr_sd))
60596 return -ENODEV;
60597
60598 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60599 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60600 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60601
60602 sysfs_put_active(attr_sd);
60603 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60604 return -ENOMEM;
60605
60606 atomic_set(&new_od->refcnt, 0);
60607 - atomic_set(&new_od->event, 1);
60608 + atomic_set_unchecked(&new_od->event, 1);
60609 init_waitqueue_head(&new_od->poll);
60610 INIT_LIST_HEAD(&new_od->buffers);
60611 goto retry;
60612 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60613
60614 sysfs_put_active(attr_sd);
60615
60616 - if (buffer->event != atomic_read(&od->event))
60617 + if (buffer->event != atomic_read_unchecked(&od->event))
60618 goto trigger;
60619
60620 return DEFAULT_POLLMASK;
60621 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60622 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60623 od = sd->s_attr.open;
60624 if (od) {
60625 - atomic_inc(&od->event);
60626 + atomic_inc_unchecked(&od->event);
60627 wake_up_interruptible(&od->poll);
60628 }
60629 }
60630 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60631 index 8c940df..25b733e 100644
60632 --- a/fs/sysfs/symlink.c
60633 +++ b/fs/sysfs/symlink.c
60634 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60635
60636 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60637 {
60638 - char *page = nd_get_link(nd);
60639 + const char *page = nd_get_link(nd);
60640 if (!IS_ERR(page))
60641 free_page((unsigned long)page);
60642 }
60643 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60644 index 69d4889..a810bd4 100644
60645 --- a/fs/sysv/sysv.h
60646 +++ b/fs/sysv/sysv.h
60647 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60648 #endif
60649 }
60650
60651 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60652 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60653 {
60654 if (sbi->s_bytesex == BYTESEX_PDP)
60655 return PDP_swab((__force __u32)n);
60656 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60657 index e18b988..f1d4ad0f 100644
60658 --- a/fs/ubifs/io.c
60659 +++ b/fs/ubifs/io.c
60660 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60661 return err;
60662 }
60663
60664 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60665 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60666 {
60667 int err;
60668
60669 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60670 index c175b4d..8f36a16 100644
60671 --- a/fs/udf/misc.c
60672 +++ b/fs/udf/misc.c
60673 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60674
60675 u8 udf_tag_checksum(const struct tag *t)
60676 {
60677 - u8 *data = (u8 *)t;
60678 + const u8 *data = (const u8 *)t;
60679 u8 checksum = 0;
60680 int i;
60681 for (i = 0; i < sizeof(struct tag); ++i)
60682 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60683 index 8d974c4..b82f6ec 100644
60684 --- a/fs/ufs/swab.h
60685 +++ b/fs/ufs/swab.h
60686 @@ -22,7 +22,7 @@ enum {
60687 BYTESEX_BE
60688 };
60689
60690 -static inline u64
60691 +static inline u64 __intentional_overflow(-1)
60692 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60693 {
60694 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60695 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60696 return (__force __fs64)cpu_to_be64(n);
60697 }
60698
60699 -static inline u32
60700 +static inline u32 __intentional_overflow(-1)
60701 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60702 {
60703 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60704 diff --git a/fs/utimes.c b/fs/utimes.c
60705 index f4fb7ec..3fe03c0 100644
60706 --- a/fs/utimes.c
60707 +++ b/fs/utimes.c
60708 @@ -1,6 +1,7 @@
60709 #include <linux/compiler.h>
60710 #include <linux/file.h>
60711 #include <linux/fs.h>
60712 +#include <linux/security.h>
60713 #include <linux/linkage.h>
60714 #include <linux/mount.h>
60715 #include <linux/namei.h>
60716 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60717 goto mnt_drop_write_and_out;
60718 }
60719 }
60720 +
60721 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60722 + error = -EACCES;
60723 + goto mnt_drop_write_and_out;
60724 + }
60725 +
60726 mutex_lock(&inode->i_mutex);
60727 error = notify_change(path->dentry, &newattrs);
60728 mutex_unlock(&inode->i_mutex);
60729 diff --git a/fs/xattr.c b/fs/xattr.c
60730 index 3377dff..4d074d9 100644
60731 --- a/fs/xattr.c
60732 +++ b/fs/xattr.c
60733 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60734 return rc;
60735 }
60736
60737 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60738 +ssize_t
60739 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60740 +{
60741 + struct inode *inode = dentry->d_inode;
60742 + ssize_t error;
60743 +
60744 + error = inode_permission(inode, MAY_EXEC);
60745 + if (error)
60746 + return error;
60747 +
60748 + if (inode->i_op->getxattr)
60749 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60750 + else
60751 + error = -EOPNOTSUPP;
60752 +
60753 + return error;
60754 +}
60755 +EXPORT_SYMBOL(pax_getxattr);
60756 +#endif
60757 +
60758 ssize_t
60759 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
60760 {
60761 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
60762 * Extended attribute SET operations
60763 */
60764 static long
60765 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
60766 +setxattr(struct path *path, const char __user *name, const void __user *value,
60767 size_t size, int flags)
60768 {
60769 int error;
60770 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
60771 posix_acl_fix_xattr_from_user(kvalue, size);
60772 }
60773
60774 - error = vfs_setxattr(d, kname, kvalue, size, flags);
60775 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
60776 + error = -EACCES;
60777 + goto out;
60778 + }
60779 +
60780 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
60781 out:
60782 if (vvalue)
60783 vfree(vvalue);
60784 @@ -377,7 +403,7 @@ retry:
60785 return error;
60786 error = mnt_want_write(path.mnt);
60787 if (!error) {
60788 - error = setxattr(path.dentry, name, value, size, flags);
60789 + error = setxattr(&path, name, value, size, flags);
60790 mnt_drop_write(path.mnt);
60791 }
60792 path_put(&path);
60793 @@ -401,7 +427,7 @@ retry:
60794 return error;
60795 error = mnt_want_write(path.mnt);
60796 if (!error) {
60797 - error = setxattr(path.dentry, name, value, size, flags);
60798 + error = setxattr(&path, name, value, size, flags);
60799 mnt_drop_write(path.mnt);
60800 }
60801 path_put(&path);
60802 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
60803 const void __user *,value, size_t, size, int, flags)
60804 {
60805 struct fd f = fdget(fd);
60806 - struct dentry *dentry;
60807 int error = -EBADF;
60808
60809 if (!f.file)
60810 return error;
60811 - dentry = f.file->f_path.dentry;
60812 - audit_inode(NULL, dentry, 0);
60813 + audit_inode(NULL, f.file->f_path.dentry, 0);
60814 error = mnt_want_write_file(f.file);
60815 if (!error) {
60816 - error = setxattr(dentry, name, value, size, flags);
60817 + error = setxattr(&f.file->f_path, name, value, size, flags);
60818 mnt_drop_write_file(f.file);
60819 }
60820 fdput(f);
60821 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
60822 index 9fbea87..6b19972 100644
60823 --- a/fs/xattr_acl.c
60824 +++ b/fs/xattr_acl.c
60825 @@ -76,8 +76,8 @@ struct posix_acl *
60826 posix_acl_from_xattr(struct user_namespace *user_ns,
60827 const void *value, size_t size)
60828 {
60829 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
60830 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
60831 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
60832 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
60833 int count;
60834 struct posix_acl *acl;
60835 struct posix_acl_entry *acl_e;
60836 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
60837 index 05c698c..6b918af 100644
60838 --- a/fs/xfs/xfs_bmap.c
60839 +++ b/fs/xfs/xfs_bmap.c
60840 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
60841
60842 #else
60843 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
60844 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
60845 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
60846 #endif /* DEBUG */
60847
60848 /*
60849 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
60850 index 97676a3..399a75d 100644
60851 --- a/fs/xfs/xfs_dir2_sf.c
60852 +++ b/fs/xfs/xfs_dir2_sf.c
60853 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
60854
60855 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
60856 ctx->pos = off & 0x7fffffff;
60857 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
60858 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
60859 + char name[sfep->namelen];
60860 + memcpy(name, sfep->name, sfep->namelen);
60861 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
60862 + return 0;
60863 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
60864 ino, DT_UNKNOWN))
60865 return 0;
60866 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
60867 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
60868 index 6e2bca5..6ce80d3 100644
60869 --- a/fs/xfs/xfs_ioctl.c
60870 +++ b/fs/xfs/xfs_ioctl.c
60871 @@ -127,7 +127,7 @@ xfs_find_handle(
60872 }
60873
60874 error = -EFAULT;
60875 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
60876 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
60877 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
60878 goto out_put;
60879
60880 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
60881 index 96dda62..d6c6a52 100644
60882 --- a/fs/xfs/xfs_iops.c
60883 +++ b/fs/xfs/xfs_iops.c
60884 @@ -395,7 +395,7 @@ xfs_vn_put_link(
60885 struct nameidata *nd,
60886 void *p)
60887 {
60888 - char *s = nd_get_link(nd);
60889 + const char *s = nd_get_link(nd);
60890
60891 if (!IS_ERR(s))
60892 kfree(s);
60893 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
60894 new file mode 100644
60895 index 0000000..0fd7c82
60896 --- /dev/null
60897 +++ b/grsecurity/Kconfig
60898 @@ -0,0 +1,1080 @@
60899 +#
60900 +# grecurity configuration
60901 +#
60902 +menu "Memory Protections"
60903 +depends on GRKERNSEC
60904 +
60905 +config GRKERNSEC_KMEM
60906 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
60907 + default y if GRKERNSEC_CONFIG_AUTO
60908 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
60909 + help
60910 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
60911 + be written to or read from to modify or leak the contents of the running
60912 + kernel. /dev/port will also not be allowed to be opened and support
60913 + for /dev/cpu/*/msr will be removed. If you have module
60914 + support disabled, enabling this will close up five ways that are
60915 + currently used to insert malicious code into the running kernel.
60916 +
60917 + Even with all these features enabled, we still highly recommend that
60918 + you use the RBAC system, as it is still possible for an attacker to
60919 + modify the running kernel through privileged I/O granted by ioperm/iopl.
60920 +
60921 + If you are not using XFree86, you may be able to stop this additional
60922 + case by enabling the 'Disable privileged I/O' option. Though nothing
60923 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
60924 + but only to video memory, which is the only writing we allow in this
60925 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
60926 + not be allowed to mprotect it with PROT_WRITE later.
60927 + Enabling this feature will prevent the "cpupower" and "powertop" tools
60928 + from working.
60929 +
60930 + It is highly recommended that you say Y here if you meet all the
60931 + conditions above.
60932 +
60933 +config GRKERNSEC_VM86
60934 + bool "Restrict VM86 mode"
60935 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
60936 + depends on X86_32
60937 +
60938 + help
60939 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
60940 + make use of a special execution mode on 32bit x86 processors called
60941 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
60942 + video cards and will still work with this option enabled. The purpose
60943 + of the option is to prevent exploitation of emulation errors in
60944 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
60945 + Nearly all users should be able to enable this option.
60946 +
60947 +config GRKERNSEC_IO
60948 + bool "Disable privileged I/O"
60949 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
60950 + depends on X86
60951 + select RTC_CLASS
60952 + select RTC_INTF_DEV
60953 + select RTC_DRV_CMOS
60954 +
60955 + help
60956 + If you say Y here, all ioperm and iopl calls will return an error.
60957 + Ioperm and iopl can be used to modify the running kernel.
60958 + Unfortunately, some programs need this access to operate properly,
60959 + the most notable of which are XFree86 and hwclock. hwclock can be
60960 + remedied by having RTC support in the kernel, so real-time
60961 + clock support is enabled if this option is enabled, to ensure
60962 + that hwclock operates correctly. XFree86 still will not
60963 + operate correctly with this option enabled, so DO NOT CHOOSE Y
60964 + IF YOU USE XFree86. If you use XFree86 and you still want to
60965 + protect your kernel against modification, use the RBAC system.
60966 +
60967 +config GRKERNSEC_JIT_HARDEN
60968 + bool "Harden BPF JIT against spray attacks"
60969 + default y if GRKERNSEC_CONFIG_AUTO
60970 + depends on BPF_JIT
60971 + help
60972 + If you say Y here, the native code generated by the kernel's Berkeley
60973 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
60974 + attacks that attempt to fit attacker-beneficial instructions in
60975 + 32bit immediate fields of JIT-generated native instructions. The
60976 + attacker will generally aim to cause an unintended instruction sequence
60977 + of JIT-generated native code to execute by jumping into the middle of
60978 + a generated instruction. This feature effectively randomizes the 32bit
60979 + immediate constants present in the generated code to thwart such attacks.
60980 +
60981 + If you're using KERNEXEC, it's recommended that you enable this option
60982 + to supplement the hardening of the kernel.
60983 +
60984 +config GRKERNSEC_PERF_HARDEN
60985 + bool "Disable unprivileged PERF_EVENTS usage by default"
60986 + default y if GRKERNSEC_CONFIG_AUTO
60987 + depends on PERF_EVENTS
60988 + help
60989 + If you say Y here, the range of acceptable values for the
60990 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
60991 + default to a new value: 3. When the sysctl is set to this value, no
60992 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
60993 +
60994 + Though PERF_EVENTS can be used legitimately for performance monitoring
60995 + and low-level application profiling, it is forced on regardless of
60996 + configuration, has been at fault for several vulnerabilities, and
60997 + creates new opportunities for side channels and other information leaks.
60998 +
60999 + This feature puts PERF_EVENTS into a secure default state and permits
61000 + the administrator to change out of it temporarily if unprivileged
61001 + application profiling is needed.
61002 +
61003 +config GRKERNSEC_RAND_THREADSTACK
61004 + bool "Insert random gaps between thread stacks"
61005 + default y if GRKERNSEC_CONFIG_AUTO
61006 + depends on PAX_RANDMMAP && !PPC
61007 + help
61008 + If you say Y here, a random-sized gap will be enforced between allocated
61009 + thread stacks. Glibc's NPTL and other threading libraries that
61010 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61011 + The implementation currently provides 8 bits of entropy for the gap.
61012 +
61013 + Many distributions do not compile threaded remote services with the
61014 + -fstack-check argument to GCC, causing the variable-sized stack-based
61015 + allocator, alloca(), to not probe the stack on allocation. This
61016 + permits an unbounded alloca() to skip over any guard page and potentially
61017 + modify another thread's stack reliably. An enforced random gap
61018 + reduces the reliability of such an attack and increases the chance
61019 + that such a read/write to another thread's stack instead lands in
61020 + an unmapped area, causing a crash and triggering grsecurity's
61021 + anti-bruteforcing logic.
61022 +
61023 +config GRKERNSEC_PROC_MEMMAP
61024 + bool "Harden ASLR against information leaks and entropy reduction"
61025 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61026 + depends on PAX_NOEXEC || PAX_ASLR
61027 + help
61028 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61029 + give no information about the addresses of its mappings if
61030 + PaX features that rely on random addresses are enabled on the task.
61031 + In addition to sanitizing this information and disabling other
61032 + dangerous sources of information, this option causes reads of sensitive
61033 + /proc/<pid> entries where the file descriptor was opened in a different
61034 + task than the one performing the read. Such attempts are logged.
61035 + This option also limits argv/env strings for suid/sgid binaries
61036 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61037 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61038 + binaries to prevent alternative mmap layouts from being abused.
61039 +
61040 + If you use PaX it is essential that you say Y here as it closes up
61041 + several holes that make full ASLR useless locally.
61042 +
61043 +config GRKERNSEC_BRUTE
61044 + bool "Deter exploit bruteforcing"
61045 + default y if GRKERNSEC_CONFIG_AUTO
61046 + help
61047 + If you say Y here, attempts to bruteforce exploits against forking
61048 + daemons such as apache or sshd, as well as against suid/sgid binaries
61049 + will be deterred. When a child of a forking daemon is killed by PaX
61050 + or crashes due to an illegal instruction or other suspicious signal,
61051 + the parent process will be delayed 30 seconds upon every subsequent
61052 + fork until the administrator is able to assess the situation and
61053 + restart the daemon.
61054 + In the suid/sgid case, the attempt is logged, the user has all their
61055 + existing instances of the suid/sgid binary terminated and will
61056 + be unable to execute any suid/sgid binaries for 15 minutes.
61057 +
61058 + It is recommended that you also enable signal logging in the auditing
61059 + section so that logs are generated when a process triggers a suspicious
61060 + signal.
61061 + If the sysctl option is enabled, a sysctl option with name
61062 + "deter_bruteforce" is created.
61063 +
61064 +
61065 +config GRKERNSEC_MODHARDEN
61066 + bool "Harden module auto-loading"
61067 + default y if GRKERNSEC_CONFIG_AUTO
61068 + depends on MODULES
61069 + help
61070 + If you say Y here, module auto-loading in response to use of some
61071 + feature implemented by an unloaded module will be restricted to
61072 + root users. Enabling this option helps defend against attacks
61073 + by unprivileged users who abuse the auto-loading behavior to
61074 + cause a vulnerable module to load that is then exploited.
61075 +
61076 + If this option prevents a legitimate use of auto-loading for a
61077 + non-root user, the administrator can execute modprobe manually
61078 + with the exact name of the module mentioned in the alert log.
61079 + Alternatively, the administrator can add the module to the list
61080 + of modules loaded at boot by modifying init scripts.
61081 +
61082 + Modification of init scripts will most likely be needed on
61083 + Ubuntu servers with encrypted home directory support enabled,
61084 + as the first non-root user logging in will cause the ecb(aes),
61085 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61086 +
61087 +config GRKERNSEC_HIDESYM
61088 + bool "Hide kernel symbols"
61089 + default y if GRKERNSEC_CONFIG_AUTO
61090 + select PAX_USERCOPY_SLABS
61091 + help
61092 + If you say Y here, getting information on loaded modules, and
61093 + displaying all kernel symbols through a syscall will be restricted
61094 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61095 + /proc/kallsyms will be restricted to the root user. The RBAC
61096 + system can hide that entry even from root.
61097 +
61098 + This option also prevents leaking of kernel addresses through
61099 + several /proc entries.
61100 +
61101 + Note that this option is only effective provided the following
61102 + conditions are met:
61103 + 1) The kernel using grsecurity is not precompiled by some distribution
61104 + 2) You have also enabled GRKERNSEC_DMESG
61105 + 3) You are using the RBAC system and hiding other files such as your
61106 + kernel image and System.map. Alternatively, enabling this option
61107 + causes the permissions on /boot, /lib/modules, and the kernel
61108 + source directory to change at compile time to prevent
61109 + reading by non-root users.
61110 + If the above conditions are met, this option will aid in providing a
61111 + useful protection against local kernel exploitation of overflows
61112 + and arbitrary read/write vulnerabilities.
61113 +
61114 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61115 + in addition to this feature.
61116 +
61117 +config GRKERNSEC_KERN_LOCKOUT
61118 + bool "Active kernel exploit response"
61119 + default y if GRKERNSEC_CONFIG_AUTO
61120 + depends on X86 || ARM || PPC || SPARC
61121 + help
61122 + If you say Y here, when a PaX alert is triggered due to suspicious
61123 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61124 + or an OOPS occurs due to bad memory accesses, instead of just
61125 + terminating the offending process (and potentially allowing
61126 + a subsequent exploit from the same user), we will take one of two
61127 + actions:
61128 + If the user was root, we will panic the system
61129 + If the user was non-root, we will log the attempt, terminate
61130 + all processes owned by the user, then prevent them from creating
61131 + any new processes until the system is restarted
61132 + This deters repeated kernel exploitation/bruteforcing attempts
61133 + and is useful for later forensics.
61134 +
61135 +endmenu
61136 +menu "Role Based Access Control Options"
61137 +depends on GRKERNSEC
61138 +
61139 +config GRKERNSEC_RBAC_DEBUG
61140 + bool
61141 +
61142 +config GRKERNSEC_NO_RBAC
61143 + bool "Disable RBAC system"
61144 + help
61145 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61146 + preventing the RBAC system from being enabled. You should only say Y
61147 + here if you have no intention of using the RBAC system, so as to prevent
61148 + an attacker with root access from misusing the RBAC system to hide files
61149 + and processes when loadable module support and /dev/[k]mem have been
61150 + locked down.
61151 +
61152 +config GRKERNSEC_ACL_HIDEKERN
61153 + bool "Hide kernel processes"
61154 + help
61155 + If you say Y here, all kernel threads will be hidden to all
61156 + processes but those whose subject has the "view hidden processes"
61157 + flag.
61158 +
61159 +config GRKERNSEC_ACL_MAXTRIES
61160 + int "Maximum tries before password lockout"
61161 + default 3
61162 + help
61163 + This option enforces the maximum number of times a user can attempt
61164 + to authorize themselves with the grsecurity RBAC system before being
61165 + denied the ability to attempt authorization again for a specified time.
61166 + The lower the number, the harder it will be to brute-force a password.
61167 +
61168 +config GRKERNSEC_ACL_TIMEOUT
61169 + int "Time to wait after max password tries, in seconds"
61170 + default 30
61171 + help
61172 + This option specifies the time the user must wait after attempting to
61173 + authorize to the RBAC system with the maximum number of invalid
61174 + passwords. The higher the number, the harder it will be to brute-force
61175 + a password.
61176 +
61177 +endmenu
61178 +menu "Filesystem Protections"
61179 +depends on GRKERNSEC
61180 +
61181 +config GRKERNSEC_PROC
61182 + bool "Proc restrictions"
61183 + default y if GRKERNSEC_CONFIG_AUTO
61184 + help
61185 + If you say Y here, the permissions of the /proc filesystem
61186 + will be altered to enhance system security and privacy. You MUST
61187 + choose either a user only restriction or a user and group restriction.
61188 + Depending upon the option you choose, you can either restrict users to
61189 + see only the processes they themselves run, or choose a group that can
61190 + view all processes and files normally restricted to root if you choose
61191 + the "restrict to user only" option. NOTE: If you're running identd or
61192 + ntpd as a non-root user, you will have to run it as the group you
61193 + specify here.
61194 +
61195 +config GRKERNSEC_PROC_USER
61196 + bool "Restrict /proc to user only"
61197 + depends on GRKERNSEC_PROC
61198 + help
61199 + If you say Y here, non-root users will only be able to view their own
61200 + processes, and restricts them from viewing network-related information,
61201 + and viewing kernel symbol and module information.
61202 +
61203 +config GRKERNSEC_PROC_USERGROUP
61204 + bool "Allow special group"
61205 + default y if GRKERNSEC_CONFIG_AUTO
61206 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61207 + help
61208 + If you say Y here, you will be able to select a group that will be
61209 + able to view all processes and network-related information. If you've
61210 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61211 + remain hidden. This option is useful if you want to run identd as
61212 + a non-root user. The group you select may also be chosen at boot time
61213 + via "grsec_proc_gid=" on the kernel commandline.
61214 +
61215 +config GRKERNSEC_PROC_GID
61216 + int "GID for special group"
61217 + depends on GRKERNSEC_PROC_USERGROUP
61218 + default 1001
61219 +
61220 +config GRKERNSEC_PROC_ADD
61221 + bool "Additional restrictions"
61222 + default y if GRKERNSEC_CONFIG_AUTO
61223 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61224 + help
61225 + If you say Y here, additional restrictions will be placed on
61226 + /proc that keep normal users from viewing device information and
61227 + slabinfo information that could be useful for exploits.
61228 +
61229 +config GRKERNSEC_LINK
61230 + bool "Linking restrictions"
61231 + default y if GRKERNSEC_CONFIG_AUTO
61232 + help
61233 + If you say Y here, /tmp race exploits will be prevented, since users
61234 + will no longer be able to follow symlinks owned by other users in
61235 + world-writable +t directories (e.g. /tmp), unless the owner of the
61236 + symlink is the owner of the directory. users will also not be
61237 + able to hardlink to files they do not own. If the sysctl option is
61238 + enabled, a sysctl option with name "linking_restrictions" is created.
61239 +
61240 +config GRKERNSEC_SYMLINKOWN
61241 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61242 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61243 + help
61244 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61245 + that prevents it from being used as a security feature. As Apache
61246 + verifies the symlink by performing a stat() against the target of
61247 + the symlink before it is followed, an attacker can setup a symlink
61248 + to point to a same-owned file, then replace the symlink with one
61249 + that targets another user's file just after Apache "validates" the
61250 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61251 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61252 + will be in place for the group you specify. If the sysctl option
61253 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61254 + created.
61255 +
61256 +config GRKERNSEC_SYMLINKOWN_GID
61257 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61258 + depends on GRKERNSEC_SYMLINKOWN
61259 + default 1006
61260 + help
61261 + Setting this GID determines what group kernel-enforced
61262 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61263 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61264 +
61265 +config GRKERNSEC_FIFO
61266 + bool "FIFO restrictions"
61267 + default y if GRKERNSEC_CONFIG_AUTO
61268 + help
61269 + If you say Y here, users will not be able to write to FIFOs they don't
61270 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61271 + the FIFO is the same owner of the directory it's held in. If the sysctl
61272 + option is enabled, a sysctl option with name "fifo_restrictions" is
61273 + created.
61274 +
61275 +config GRKERNSEC_SYSFS_RESTRICT
61276 + bool "Sysfs/debugfs restriction"
61277 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61278 + depends on SYSFS
61279 + help
61280 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61281 + any filesystem normally mounted under it (e.g. debugfs) will be
61282 + mostly accessible only by root. These filesystems generally provide access
61283 + to hardware and debug information that isn't appropriate for unprivileged
61284 + users of the system. Sysfs and debugfs have also become a large source
61285 + of new vulnerabilities, ranging from infoleaks to local compromise.
61286 + There has been very little oversight with an eye toward security involved
61287 + in adding new exporters of information to these filesystems, so their
61288 + use is discouraged.
61289 + For reasons of compatibility, a few directories have been whitelisted
61290 + for access by non-root users:
61291 + /sys/fs/selinux
61292 + /sys/fs/fuse
61293 + /sys/devices/system/cpu
61294 +
61295 +config GRKERNSEC_ROFS
61296 + bool "Runtime read-only mount protection"
61297 + depends on SYSCTL
61298 + help
61299 + If you say Y here, a sysctl option with name "romount_protect" will
61300 + be created. By setting this option to 1 at runtime, filesystems
61301 + will be protected in the following ways:
61302 + * No new writable mounts will be allowed
61303 + * Existing read-only mounts won't be able to be remounted read/write
61304 + * Write operations will be denied on all block devices
61305 + This option acts independently of grsec_lock: once it is set to 1,
61306 + it cannot be turned off. Therefore, please be mindful of the resulting
61307 + behavior if this option is enabled in an init script on a read-only
61308 + filesystem. This feature is mainly intended for secure embedded systems.
61309 +
61310 +config GRKERNSEC_DEVICE_SIDECHANNEL
61311 + bool "Eliminate stat/notify-based device sidechannels"
61312 + default y if GRKERNSEC_CONFIG_AUTO
61313 + help
61314 + If you say Y here, timing analyses on block or character
61315 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61316 + will be thwarted for unprivileged users. If a process without
61317 + CAP_MKNOD stats such a device, the last access and last modify times
61318 + will match the device's create time. No access or modify events
61319 + will be triggered through inotify/dnotify/fanotify for such devices.
61320 + This feature will prevent attacks that may at a minimum
61321 + allow an attacker to determine the administrator's password length.
61322 +
61323 +config GRKERNSEC_CHROOT
61324 + bool "Chroot jail restrictions"
61325 + default y if GRKERNSEC_CONFIG_AUTO
61326 + help
61327 + If you say Y here, you will be able to choose several options that will
61328 + make breaking out of a chrooted jail much more difficult. If you
61329 + encounter no software incompatibilities with the following options, it
61330 + is recommended that you enable each one.
61331 +
61332 +config GRKERNSEC_CHROOT_MOUNT
61333 + bool "Deny mounts"
61334 + default y if GRKERNSEC_CONFIG_AUTO
61335 + depends on GRKERNSEC_CHROOT
61336 + help
61337 + If you say Y here, processes inside a chroot will not be able to
61338 + mount or remount filesystems. If the sysctl option is enabled, a
61339 + sysctl option with name "chroot_deny_mount" is created.
61340 +
61341 +config GRKERNSEC_CHROOT_DOUBLE
61342 + bool "Deny double-chroots"
61343 + default y if GRKERNSEC_CONFIG_AUTO
61344 + depends on GRKERNSEC_CHROOT
61345 + help
61346 + If you say Y here, processes inside a chroot will not be able to chroot
61347 + again outside the chroot. This is a widely used method of breaking
61348 + out of a chroot jail and should not be allowed. If the sysctl
61349 + option is enabled, a sysctl option with name
61350 + "chroot_deny_chroot" is created.
61351 +
61352 +config GRKERNSEC_CHROOT_PIVOT
61353 + bool "Deny pivot_root in chroot"
61354 + default y if GRKERNSEC_CONFIG_AUTO
61355 + depends on GRKERNSEC_CHROOT
61356 + help
61357 + If you say Y here, processes inside a chroot will not be able to use
61358 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61359 + works similar to chroot in that it changes the root filesystem. This
61360 + function could be misused in a chrooted process to attempt to break out
61361 + of the chroot, and therefore should not be allowed. If the sysctl
61362 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61363 + created.
61364 +
61365 +config GRKERNSEC_CHROOT_CHDIR
61366 + bool "Enforce chdir(\"/\") on all chroots"
61367 + default y if GRKERNSEC_CONFIG_AUTO
61368 + depends on GRKERNSEC_CHROOT
61369 + help
61370 + If you say Y here, the current working directory of all newly-chrooted
61371 + applications will be set to the the root directory of the chroot.
61372 + The man page on chroot(2) states:
61373 + Note that this call does not change the current working
61374 + directory, so that `.' can be outside the tree rooted at
61375 + `/'. In particular, the super-user can escape from a
61376 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61377 +
61378 + It is recommended that you say Y here, since it's not known to break
61379 + any software. If the sysctl option is enabled, a sysctl option with
61380 + name "chroot_enforce_chdir" is created.
61381 +
61382 +config GRKERNSEC_CHROOT_CHMOD
61383 + bool "Deny (f)chmod +s"
61384 + default y if GRKERNSEC_CONFIG_AUTO
61385 + depends on GRKERNSEC_CHROOT
61386 + help
61387 + If you say Y here, processes inside a chroot will not be able to chmod
61388 + or fchmod files to make them have suid or sgid bits. This protects
61389 + against another published method of breaking a chroot. If the sysctl
61390 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61391 + created.
61392 +
61393 +config GRKERNSEC_CHROOT_FCHDIR
61394 + bool "Deny fchdir out of chroot"
61395 + default y if GRKERNSEC_CONFIG_AUTO
61396 + depends on GRKERNSEC_CHROOT
61397 + help
61398 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61399 + to a file descriptor of the chrooting process that points to a directory
61400 + outside the filesystem will be stopped. If the sysctl option
61401 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61402 +
61403 +config GRKERNSEC_CHROOT_MKNOD
61404 + bool "Deny mknod"
61405 + default y if GRKERNSEC_CONFIG_AUTO
61406 + depends on GRKERNSEC_CHROOT
61407 + help
61408 + If you say Y here, processes inside a chroot will not be allowed to
61409 + mknod. The problem with using mknod inside a chroot is that it
61410 + would allow an attacker to create a device entry that is the same
61411 + as one on the physical root of your system, which could range from
61412 + anything from the console device to a device for your harddrive (which
61413 + they could then use to wipe the drive or steal data). It is recommended
61414 + that you say Y here, unless you run into software incompatibilities.
61415 + If the sysctl option is enabled, a sysctl option with name
61416 + "chroot_deny_mknod" is created.
61417 +
61418 +config GRKERNSEC_CHROOT_SHMAT
61419 + bool "Deny shmat() out of chroot"
61420 + default y if GRKERNSEC_CONFIG_AUTO
61421 + depends on GRKERNSEC_CHROOT
61422 + help
61423 + If you say Y here, processes inside a chroot will not be able to attach
61424 + to shared memory segments that were created outside of the chroot jail.
61425 + It is recommended that you say Y here. If the sysctl option is enabled,
61426 + a sysctl option with name "chroot_deny_shmat" is created.
61427 +
61428 +config GRKERNSEC_CHROOT_UNIX
61429 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61430 + default y if GRKERNSEC_CONFIG_AUTO
61431 + depends on GRKERNSEC_CHROOT
61432 + help
61433 + If you say Y here, processes inside a chroot will not be able to
61434 + connect to abstract (meaning not belonging to a filesystem) Unix
61435 + domain sockets that were bound outside of a chroot. It is recommended
61436 + that you say Y here. If the sysctl option is enabled, a sysctl option
61437 + with name "chroot_deny_unix" is created.
61438 +
61439 +config GRKERNSEC_CHROOT_FINDTASK
61440 + bool "Protect outside processes"
61441 + default y if GRKERNSEC_CONFIG_AUTO
61442 + depends on GRKERNSEC_CHROOT
61443 + help
61444 + If you say Y here, processes inside a chroot will not be able to
61445 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61446 + getsid, or view any process outside of the chroot. If the sysctl
61447 + option is enabled, a sysctl option with name "chroot_findtask" is
61448 + created.
61449 +
61450 +config GRKERNSEC_CHROOT_NICE
61451 + bool "Restrict priority changes"
61452 + default y if GRKERNSEC_CONFIG_AUTO
61453 + depends on GRKERNSEC_CHROOT
61454 + help
61455 + If you say Y here, processes inside a chroot will not be able to raise
61456 + the priority of processes in the chroot, or alter the priority of
61457 + processes outside the chroot. This provides more security than simply
61458 + removing CAP_SYS_NICE from the process' capability set. If the
61459 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61460 + is created.
61461 +
61462 +config GRKERNSEC_CHROOT_SYSCTL
61463 + bool "Deny sysctl writes"
61464 + default y if GRKERNSEC_CONFIG_AUTO
61465 + depends on GRKERNSEC_CHROOT
61466 + help
61467 + If you say Y here, an attacker in a chroot will not be able to
61468 + write to sysctl entries, either by sysctl(2) or through a /proc
61469 + interface. It is strongly recommended that you say Y here. If the
61470 + sysctl option is enabled, a sysctl option with name
61471 + "chroot_deny_sysctl" is created.
61472 +
61473 +config GRKERNSEC_CHROOT_CAPS
61474 + bool "Capability restrictions"
61475 + default y if GRKERNSEC_CONFIG_AUTO
61476 + depends on GRKERNSEC_CHROOT
61477 + help
61478 + If you say Y here, the capabilities on all processes within a
61479 + chroot jail will be lowered to stop module insertion, raw i/o,
61480 + system and net admin tasks, rebooting the system, modifying immutable
61481 + files, modifying IPC owned by another, and changing the system time.
61482 + This is left an option because it can break some apps. Disable this
61483 + if your chrooted apps are having problems performing those kinds of
61484 + tasks. If the sysctl option is enabled, a sysctl option with
61485 + name "chroot_caps" is created.
61486 +
61487 +config GRKERNSEC_CHROOT_INITRD
61488 + bool "Exempt initrd tasks from restrictions"
61489 + default y if GRKERNSEC_CONFIG_AUTO
61490 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61491 + help
61492 + If you say Y here, tasks started prior to init will be exempted from
61493 + grsecurity's chroot restrictions. This option is mainly meant to
61494 + resolve Plymouth's performing privileged operations unnecessarily
61495 + in a chroot.
61496 +
61497 +endmenu
61498 +menu "Kernel Auditing"
61499 +depends on GRKERNSEC
61500 +
61501 +config GRKERNSEC_AUDIT_GROUP
61502 + bool "Single group for auditing"
61503 + help
61504 + If you say Y here, the exec and chdir logging features will only operate
61505 + on a group you specify. This option is recommended if you only want to
61506 + watch certain users instead of having a large amount of logs from the
61507 + entire system. If the sysctl option is enabled, a sysctl option with
61508 + name "audit_group" is created.
61509 +
61510 +config GRKERNSEC_AUDIT_GID
61511 + int "GID for auditing"
61512 + depends on GRKERNSEC_AUDIT_GROUP
61513 + default 1007
61514 +
61515 +config GRKERNSEC_EXECLOG
61516 + bool "Exec logging"
61517 + help
61518 + If you say Y here, all execve() calls will be logged (since the
61519 + other exec*() calls are frontends to execve(), all execution
61520 + will be logged). Useful for shell-servers that like to keep track
61521 + of their users. If the sysctl option is enabled, a sysctl option with
61522 + name "exec_logging" is created.
61523 + WARNING: This option when enabled will produce a LOT of logs, especially
61524 + on an active system.
61525 +
61526 +config GRKERNSEC_RESLOG
61527 + bool "Resource logging"
61528 + default y if GRKERNSEC_CONFIG_AUTO
61529 + help
61530 + If you say Y here, all attempts to overstep resource limits will
61531 + be logged with the resource name, the requested size, and the current
61532 + limit. It is highly recommended that you say Y here. If the sysctl
61533 + option is enabled, a sysctl option with name "resource_logging" is
61534 + created. If the RBAC system is enabled, the sysctl value is ignored.
61535 +
61536 +config GRKERNSEC_CHROOT_EXECLOG
61537 + bool "Log execs within chroot"
61538 + help
61539 + If you say Y here, all executions inside a chroot jail will be logged
61540 + to syslog. This can cause a large amount of logs if certain
61541 + applications (eg. djb's daemontools) are installed on the system, and
61542 + is therefore left as an option. If the sysctl option is enabled, a
61543 + sysctl option with name "chroot_execlog" is created.
61544 +
61545 +config GRKERNSEC_AUDIT_PTRACE
61546 + bool "Ptrace logging"
61547 + help
61548 + If you say Y here, all attempts to attach to a process via ptrace
61549 + will be logged. If the sysctl option is enabled, a sysctl option
61550 + with name "audit_ptrace" is created.
61551 +
61552 +config GRKERNSEC_AUDIT_CHDIR
61553 + bool "Chdir logging"
61554 + help
61555 + If you say Y here, all chdir() calls will be logged. If the sysctl
61556 + option is enabled, a sysctl option with name "audit_chdir" is created.
61557 +
61558 +config GRKERNSEC_AUDIT_MOUNT
61559 + bool "(Un)Mount logging"
61560 + help
61561 + If you say Y here, all mounts and unmounts will be logged. If the
61562 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61563 + created.
61564 +
61565 +config GRKERNSEC_SIGNAL
61566 + bool "Signal logging"
61567 + default y if GRKERNSEC_CONFIG_AUTO
61568 + help
61569 + If you say Y here, certain important signals will be logged, such as
61570 + SIGSEGV, which will as a result inform you of when a error in a program
61571 + occurred, which in some cases could mean a possible exploit attempt.
61572 + If the sysctl option is enabled, a sysctl option with name
61573 + "signal_logging" is created.
61574 +
61575 +config GRKERNSEC_FORKFAIL
61576 + bool "Fork failure logging"
61577 + help
61578 + If you say Y here, all failed fork() attempts will be logged.
61579 + This could suggest a fork bomb, or someone attempting to overstep
61580 + their process limit. If the sysctl option is enabled, a sysctl option
61581 + with name "forkfail_logging" is created.
61582 +
61583 +config GRKERNSEC_TIME
61584 + bool "Time change logging"
61585 + default y if GRKERNSEC_CONFIG_AUTO
61586 + help
61587 + If you say Y here, any changes of the system clock will be logged.
61588 + If the sysctl option is enabled, a sysctl option with name
61589 + "timechange_logging" is created.
61590 +
61591 +config GRKERNSEC_PROC_IPADDR
61592 + bool "/proc/<pid>/ipaddr support"
61593 + default y if GRKERNSEC_CONFIG_AUTO
61594 + help
61595 + If you say Y here, a new entry will be added to each /proc/<pid>
61596 + directory that contains the IP address of the person using the task.
61597 + The IP is carried across local TCP and AF_UNIX stream sockets.
61598 + This information can be useful for IDS/IPSes to perform remote response
61599 + to a local attack. The entry is readable by only the owner of the
61600 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61601 + the RBAC system), and thus does not create privacy concerns.
61602 +
61603 +config GRKERNSEC_RWXMAP_LOG
61604 + bool 'Denied RWX mmap/mprotect logging'
61605 + default y if GRKERNSEC_CONFIG_AUTO
61606 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61607 + help
61608 + If you say Y here, calls to mmap() and mprotect() with explicit
61609 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61610 + denied by the PAX_MPROTECT feature. This feature will also
61611 + log other problematic scenarios that can occur when PAX_MPROTECT
61612 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61613 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61614 + is created.
61615 +
61616 +endmenu
61617 +
61618 +menu "Executable Protections"
61619 +depends on GRKERNSEC
61620 +
61621 +config GRKERNSEC_DMESG
61622 + bool "Dmesg(8) restriction"
61623 + default y if GRKERNSEC_CONFIG_AUTO
61624 + help
61625 + If you say Y here, non-root users will not be able to use dmesg(8)
61626 + to view the contents of the kernel's circular log buffer.
61627 + The kernel's log buffer often contains kernel addresses and other
61628 + identifying information useful to an attacker in fingerprinting a
61629 + system for a targeted exploit.
61630 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61631 + created.
61632 +
61633 +config GRKERNSEC_HARDEN_PTRACE
61634 + bool "Deter ptrace-based process snooping"
61635 + default y if GRKERNSEC_CONFIG_AUTO
61636 + help
61637 + If you say Y here, TTY sniffers and other malicious monitoring
61638 + programs implemented through ptrace will be defeated. If you
61639 + have been using the RBAC system, this option has already been
61640 + enabled for several years for all users, with the ability to make
61641 + fine-grained exceptions.
61642 +
61643 + This option only affects the ability of non-root users to ptrace
61644 + processes that are not a descendent of the ptracing process.
61645 + This means that strace ./binary and gdb ./binary will still work,
61646 + but attaching to arbitrary processes will not. If the sysctl
61647 + option is enabled, a sysctl option with name "harden_ptrace" is
61648 + created.
61649 +
61650 +config GRKERNSEC_PTRACE_READEXEC
61651 + bool "Require read access to ptrace sensitive binaries"
61652 + default y if GRKERNSEC_CONFIG_AUTO
61653 + help
61654 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61655 + binaries. This option is useful in environments that
61656 + remove the read bits (e.g. file mode 4711) from suid binaries to
61657 + prevent infoleaking of their contents. This option adds
61658 + consistency to the use of that file mode, as the binary could normally
61659 + be read out when run without privileges while ptracing.
61660 +
61661 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61662 + is created.
61663 +
61664 +config GRKERNSEC_SETXID
61665 + bool "Enforce consistent multithreaded privileges"
61666 + default y if GRKERNSEC_CONFIG_AUTO
61667 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61668 + help
61669 + If you say Y here, a change from a root uid to a non-root uid
61670 + in a multithreaded application will cause the resulting uids,
61671 + gids, supplementary groups, and capabilities in that thread
61672 + to be propagated to the other threads of the process. In most
61673 + cases this is unnecessary, as glibc will emulate this behavior
61674 + on behalf of the application. Other libcs do not act in the
61675 + same way, allowing the other threads of the process to continue
61676 + running with root privileges. If the sysctl option is enabled,
61677 + a sysctl option with name "consistent_setxid" is created.
61678 +
61679 +config GRKERNSEC_TPE
61680 + bool "Trusted Path Execution (TPE)"
61681 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61682 + help
61683 + If you say Y here, you will be able to choose a gid to add to the
61684 + supplementary groups of users you want to mark as "untrusted."
61685 + These users will not be able to execute any files that are not in
61686 + root-owned directories writable only by root. If the sysctl option
61687 + is enabled, a sysctl option with name "tpe" is created.
61688 +
61689 +config GRKERNSEC_TPE_ALL
61690 + bool "Partially restrict all non-root users"
61691 + depends on GRKERNSEC_TPE
61692 + help
61693 + If you say Y here, all non-root users will be covered under
61694 + a weaker TPE restriction. This is separate from, and in addition to,
61695 + the main TPE options that you have selected elsewhere. Thus, if a
61696 + "trusted" GID is chosen, this restriction applies to even that GID.
61697 + Under this restriction, all non-root users will only be allowed to
61698 + execute files in directories they own that are not group or
61699 + world-writable, or in directories owned by root and writable only by
61700 + root. If the sysctl option is enabled, a sysctl option with name
61701 + "tpe_restrict_all" is created.
61702 +
61703 +config GRKERNSEC_TPE_INVERT
61704 + bool "Invert GID option"
61705 + depends on GRKERNSEC_TPE
61706 + help
61707 + If you say Y here, the group you specify in the TPE configuration will
61708 + decide what group TPE restrictions will be *disabled* for. This
61709 + option is useful if you want TPE restrictions to be applied to most
61710 + users on the system. If the sysctl option is enabled, a sysctl option
61711 + with name "tpe_invert" is created. Unlike other sysctl options, this
61712 + entry will default to on for backward-compatibility.
61713 +
61714 +config GRKERNSEC_TPE_GID
61715 + int
61716 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61717 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61718 +
61719 +config GRKERNSEC_TPE_UNTRUSTED_GID
61720 + int "GID for TPE-untrusted users"
61721 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61722 + default 1005
61723 + help
61724 + Setting this GID determines what group TPE restrictions will be
61725 + *enabled* for. If the sysctl option is enabled, a sysctl option
61726 + with name "tpe_gid" is created.
61727 +
61728 +config GRKERNSEC_TPE_TRUSTED_GID
61729 + int "GID for TPE-trusted users"
61730 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61731 + default 1005
61732 + help
61733 + Setting this GID determines what group TPE restrictions will be
61734 + *disabled* for. If the sysctl option is enabled, a sysctl option
61735 + with name "tpe_gid" is created.
61736 +
61737 +endmenu
61738 +menu "Network Protections"
61739 +depends on GRKERNSEC
61740 +
61741 +config GRKERNSEC_RANDNET
61742 + bool "Larger entropy pools"
61743 + default y if GRKERNSEC_CONFIG_AUTO
61744 + help
61745 + If you say Y here, the entropy pools used for many features of Linux
61746 + and grsecurity will be doubled in size. Since several grsecurity
61747 + features use additional randomness, it is recommended that you say Y
61748 + here. Saying Y here has a similar effect as modifying
61749 + /proc/sys/kernel/random/poolsize.
61750 +
61751 +config GRKERNSEC_BLACKHOLE
61752 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61753 + default y if GRKERNSEC_CONFIG_AUTO
61754 + depends on NET
61755 + help
61756 + If you say Y here, neither TCP resets nor ICMP
61757 + destination-unreachable packets will be sent in response to packets
61758 + sent to ports for which no associated listening process exists.
61759 + This feature supports both IPV4 and IPV6 and exempts the
61760 + loopback interface from blackholing. Enabling this feature
61761 + makes a host more resilient to DoS attacks and reduces network
61762 + visibility against scanners.
61763 +
61764 + The blackhole feature as-implemented is equivalent to the FreeBSD
61765 + blackhole feature, as it prevents RST responses to all packets, not
61766 + just SYNs. Under most application behavior this causes no
61767 + problems, but applications (like haproxy) may not close certain
61768 + connections in a way that cleanly terminates them on the remote
61769 + end, leaving the remote host in LAST_ACK state. Because of this
61770 + side-effect and to prevent intentional LAST_ACK DoSes, this
61771 + feature also adds automatic mitigation against such attacks.
61772 + The mitigation drastically reduces the amount of time a socket
61773 + can spend in LAST_ACK state. If you're using haproxy and not
61774 + all servers it connects to have this option enabled, consider
61775 + disabling this feature on the haproxy host.
61776 +
61777 + If the sysctl option is enabled, two sysctl options with names
61778 + "ip_blackhole" and "lastack_retries" will be created.
61779 + While "ip_blackhole" takes the standard zero/non-zero on/off
61780 + toggle, "lastack_retries" uses the same kinds of values as
61781 + "tcp_retries1" and "tcp_retries2". The default value of 4
61782 + prevents a socket from lasting more than 45 seconds in LAST_ACK
61783 + state.
61784 +
61785 +config GRKERNSEC_NO_SIMULT_CONNECT
61786 + bool "Disable TCP Simultaneous Connect"
61787 + default y if GRKERNSEC_CONFIG_AUTO
61788 + depends on NET
61789 + help
61790 + If you say Y here, a feature by Willy Tarreau will be enabled that
61791 + removes a weakness in Linux's strict implementation of TCP that
61792 + allows two clients to connect to each other without either entering
61793 + a listening state. The weakness allows an attacker to easily prevent
61794 + a client from connecting to a known server provided the source port
61795 + for the connection is guessed correctly.
61796 +
61797 + As the weakness could be used to prevent an antivirus or IPS from
61798 + fetching updates, or prevent an SSL gateway from fetching a CRL,
61799 + it should be eliminated by enabling this option. Though Linux is
61800 + one of few operating systems supporting simultaneous connect, it
61801 + has no legitimate use in practice and is rarely supported by firewalls.
61802 +
61803 +config GRKERNSEC_SOCKET
61804 + bool "Socket restrictions"
61805 + depends on NET
61806 + help
61807 + If you say Y here, you will be able to choose from several options.
61808 + If you assign a GID on your system and add it to the supplementary
61809 + groups of users you want to restrict socket access to, this patch
61810 + will perform up to three things, based on the option(s) you choose.
61811 +
61812 +config GRKERNSEC_SOCKET_ALL
61813 + bool "Deny any sockets to group"
61814 + depends on GRKERNSEC_SOCKET
61815 + help
61816 + If you say Y here, you will be able to choose a GID of whose users will
61817 + be unable to connect to other hosts from your machine or run server
61818 + applications from your machine. If the sysctl option is enabled, a
61819 + sysctl option with name "socket_all" is created.
61820 +
61821 +config GRKERNSEC_SOCKET_ALL_GID
61822 + int "GID to deny all sockets for"
61823 + depends on GRKERNSEC_SOCKET_ALL
61824 + default 1004
61825 + help
61826 + Here you can choose the GID to disable socket access for. Remember to
61827 + add the users you want socket access disabled for to the GID
61828 + specified here. If the sysctl option is enabled, a sysctl option
61829 + with name "socket_all_gid" is created.
61830 +
61831 +config GRKERNSEC_SOCKET_CLIENT
61832 + bool "Deny client sockets to group"
61833 + depends on GRKERNSEC_SOCKET
61834 + help
61835 + If you say Y here, you will be able to choose a GID of whose users will
61836 + be unable to connect to other hosts from your machine, but will be
61837 + able to run servers. If this option is enabled, all users in the group
61838 + you specify will have to use passive mode when initiating ftp transfers
61839 + from the shell on your machine. If the sysctl option is enabled, a
61840 + sysctl option with name "socket_client" is created.
61841 +
61842 +config GRKERNSEC_SOCKET_CLIENT_GID
61843 + int "GID to deny client sockets for"
61844 + depends on GRKERNSEC_SOCKET_CLIENT
61845 + default 1003
61846 + help
61847 + Here you can choose the GID to disable client socket access for.
61848 + Remember to add the users you want client socket access disabled for to
61849 + the GID specified here. If the sysctl option is enabled, a sysctl
61850 + option with name "socket_client_gid" is created.
61851 +
61852 +config GRKERNSEC_SOCKET_SERVER
61853 + bool "Deny server sockets to group"
61854 + depends on GRKERNSEC_SOCKET
61855 + help
61856 + If you say Y here, you will be able to choose a GID of whose users will
61857 + be unable to run server applications from your machine. If the sysctl
61858 + option is enabled, a sysctl option with name "socket_server" is created.
61859 +
61860 +config GRKERNSEC_SOCKET_SERVER_GID
61861 + int "GID to deny server sockets for"
61862 + depends on GRKERNSEC_SOCKET_SERVER
61863 + default 1002
61864 + help
61865 + Here you can choose the GID to disable server socket access for.
61866 + Remember to add the users you want server socket access disabled for to
61867 + the GID specified here. If the sysctl option is enabled, a sysctl
61868 + option with name "socket_server_gid" is created.
61869 +
61870 +endmenu
61871 +
61872 +menu "Physical Protections"
61873 +depends on GRKERNSEC
61874 +
61875 +config GRKERNSEC_DENYUSB
61876 + bool "Deny new USB connections after toggle"
61877 + default y if GRKERNSEC_CONFIG_AUTO
61878 + depends on SYSCTL && USB_SUPPORT
61879 + help
61880 + If you say Y here, a new sysctl option with name "deny_new_usb"
61881 + will be created. Setting its value to 1 will prevent any new
61882 + USB devices from being recognized by the OS. Any attempted USB
61883 + device insertion will be logged. This option is intended to be
61884 + used against custom USB devices designed to exploit vulnerabilities
61885 + in various USB device drivers.
61886 +
61887 + For greatest effectiveness, this sysctl should be set after any
61888 + relevant init scripts. This option is safe to enable in distros
61889 + as each user can choose whether or not to toggle the sysctl.
61890 +
61891 +config GRKERNSEC_DENYUSB_FORCE
61892 + bool "Reject all USB devices not connected at boot"
61893 + select USB
61894 + depends on GRKERNSEC_DENYUSB
61895 + help
61896 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
61897 + that doesn't involve a sysctl entry. This option should only be
61898 + enabled if you're sure you want to deny all new USB connections
61899 + at runtime and don't want to modify init scripts. This should not
61900 + be enabled by distros. It forces the core USB code to be built
61901 + into the kernel image so that all devices connected at boot time
61902 + can be recognized and new USB device connections can be prevented
61903 + prior to init running.
61904 +
61905 +endmenu
61906 +
61907 +menu "Sysctl Support"
61908 +depends on GRKERNSEC && SYSCTL
61909 +
61910 +config GRKERNSEC_SYSCTL
61911 + bool "Sysctl support"
61912 + default y if GRKERNSEC_CONFIG_AUTO
61913 + help
61914 + If you say Y here, you will be able to change the options that
61915 + grsecurity runs with at bootup, without having to recompile your
61916 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
61917 + to enable (1) or disable (0) various features. All the sysctl entries
61918 + are mutable until the "grsec_lock" entry is set to a non-zero value.
61919 + All features enabled in the kernel configuration are disabled at boot
61920 + if you do not say Y to the "Turn on features by default" option.
61921 + All options should be set at startup, and the grsec_lock entry should
61922 + be set to a non-zero value after all the options are set.
61923 + *THIS IS EXTREMELY IMPORTANT*
61924 +
61925 +config GRKERNSEC_SYSCTL_DISTRO
61926 + bool "Extra sysctl support for distro makers (READ HELP)"
61927 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
61928 + help
61929 + If you say Y here, additional sysctl options will be created
61930 + for features that affect processes running as root. Therefore,
61931 + it is critical when using this option that the grsec_lock entry be
61932 + enabled after boot. Only distros with prebuilt kernel packages
61933 + with this option enabled that can ensure grsec_lock is enabled
61934 + after boot should use this option.
61935 + *Failure to set grsec_lock after boot makes all grsec features
61936 + this option covers useless*
61937 +
61938 + Currently this option creates the following sysctl entries:
61939 + "Disable Privileged I/O": "disable_priv_io"
61940 +
61941 +config GRKERNSEC_SYSCTL_ON
61942 + bool "Turn on features by default"
61943 + default y if GRKERNSEC_CONFIG_AUTO
61944 + depends on GRKERNSEC_SYSCTL
61945 + help
61946 + If you say Y here, instead of having all features enabled in the
61947 + kernel configuration disabled at boot time, the features will be
61948 + enabled at boot time. It is recommended you say Y here unless
61949 + there is some reason you would want all sysctl-tunable features to
61950 + be disabled by default. As mentioned elsewhere, it is important
61951 + to enable the grsec_lock entry once you have finished modifying
61952 + the sysctl entries.
61953 +
61954 +endmenu
61955 +menu "Logging Options"
61956 +depends on GRKERNSEC
61957 +
61958 +config GRKERNSEC_FLOODTIME
61959 + int "Seconds in between log messages (minimum)"
61960 + default 10
61961 + help
61962 + This option allows you to enforce the number of seconds between
61963 + grsecurity log messages. The default should be suitable for most
61964 + people, however, if you choose to change it, choose a value small enough
61965 + to allow informative logs to be produced, but large enough to
61966 + prevent flooding.
61967 +
61968 +config GRKERNSEC_FLOODBURST
61969 + int "Number of messages in a burst (maximum)"
61970 + default 6
61971 + help
61972 + This option allows you to choose the maximum number of messages allowed
61973 + within the flood time interval you chose in a separate option. The
61974 + default should be suitable for most people, however if you find that
61975 + many of your logs are being interpreted as flooding, you may want to
61976 + raise this value.
61977 +
61978 +endmenu
61979 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
61980 new file mode 100644
61981 index 0000000..b0b77d5
61982 --- /dev/null
61983 +++ b/grsecurity/Makefile
61984 @@ -0,0 +1,43 @@
61985 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
61986 +# during 2001-2009 it has been completely redesigned by Brad Spengler
61987 +# into an RBAC system
61988 +#
61989 +# All code in this directory and various hooks inserted throughout the kernel
61990 +# are copyright Brad Spengler - Open Source Security, Inc., and released
61991 +# under the GPL v2 or higher
61992 +
61993 +KBUILD_CFLAGS += -Werror
61994 +
61995 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
61996 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
61997 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
61998 + grsec_usb.o
61999 +
62000 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62001 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62002 + gracl_learn.o grsec_log.o
62003 +ifdef CONFIG_COMPAT
62004 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62005 +endif
62006 +
62007 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62008 +
62009 +ifdef CONFIG_NET
62010 +obj-y += grsec_sock.o
62011 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62012 +endif
62013 +
62014 +ifndef CONFIG_GRKERNSEC
62015 +obj-y += grsec_disabled.o
62016 +endif
62017 +
62018 +ifdef CONFIG_GRKERNSEC_HIDESYM
62019 +extra-y := grsec_hidesym.o
62020 +$(obj)/grsec_hidesym.o:
62021 + @-chmod -f 500 /boot
62022 + @-chmod -f 500 /lib/modules
62023 + @-chmod -f 500 /lib64/modules
62024 + @-chmod -f 500 /lib32/modules
62025 + @-chmod -f 700 .
62026 + @echo ' grsec: protected kernel image paths'
62027 +endif
62028 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62029 new file mode 100644
62030 index 0000000..c0793fd
62031 --- /dev/null
62032 +++ b/grsecurity/gracl.c
62033 @@ -0,0 +1,4178 @@
62034 +#include <linux/kernel.h>
62035 +#include <linux/module.h>
62036 +#include <linux/sched.h>
62037 +#include <linux/mm.h>
62038 +#include <linux/file.h>
62039 +#include <linux/fs.h>
62040 +#include <linux/namei.h>
62041 +#include <linux/mount.h>
62042 +#include <linux/tty.h>
62043 +#include <linux/proc_fs.h>
62044 +#include <linux/lglock.h>
62045 +#include <linux/slab.h>
62046 +#include <linux/vmalloc.h>
62047 +#include <linux/types.h>
62048 +#include <linux/sysctl.h>
62049 +#include <linux/netdevice.h>
62050 +#include <linux/ptrace.h>
62051 +#include <linux/gracl.h>
62052 +#include <linux/gralloc.h>
62053 +#include <linux/security.h>
62054 +#include <linux/grinternal.h>
62055 +#include <linux/pid_namespace.h>
62056 +#include <linux/stop_machine.h>
62057 +#include <linux/fdtable.h>
62058 +#include <linux/percpu.h>
62059 +#include <linux/lglock.h>
62060 +#include <linux/hugetlb.h>
62061 +#include <linux/posix-timers.h>
62062 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62063 +#include <linux/magic.h>
62064 +#include <linux/pagemap.h>
62065 +#include "../fs/btrfs/async-thread.h"
62066 +#include "../fs/btrfs/ctree.h"
62067 +#include "../fs/btrfs/btrfs_inode.h"
62068 +#endif
62069 +#include "../fs/mount.h"
62070 +
62071 +#include <asm/uaccess.h>
62072 +#include <asm/errno.h>
62073 +#include <asm/mman.h>
62074 +
62075 +extern struct lglock vfsmount_lock;
62076 +
62077 +static struct acl_role_db acl_role_set;
62078 +static struct name_db name_set;
62079 +static struct inodev_db inodev_set;
62080 +
62081 +/* for keeping track of userspace pointers used for subjects, so we
62082 + can share references in the kernel as well
62083 +*/
62084 +
62085 +static struct path real_root;
62086 +
62087 +static struct acl_subj_map_db subj_map_set;
62088 +
62089 +static struct acl_role_label *default_role;
62090 +
62091 +static struct acl_role_label *role_list;
62092 +
62093 +static u16 acl_sp_role_value;
62094 +
62095 +extern char *gr_shared_page[4];
62096 +static DEFINE_MUTEX(gr_dev_mutex);
62097 +DEFINE_RWLOCK(gr_inode_lock);
62098 +
62099 +struct gr_arg *gr_usermode;
62100 +
62101 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62102 +
62103 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
62104 +extern void gr_clear_learn_entries(void);
62105 +
62106 +unsigned char *gr_system_salt;
62107 +unsigned char *gr_system_sum;
62108 +
62109 +static struct sprole_pw **acl_special_roles = NULL;
62110 +static __u16 num_sprole_pws = 0;
62111 +
62112 +static struct acl_role_label *kernel_role = NULL;
62113 +
62114 +static unsigned int gr_auth_attempts = 0;
62115 +static unsigned long gr_auth_expires = 0UL;
62116 +
62117 +#ifdef CONFIG_NET
62118 +extern struct vfsmount *sock_mnt;
62119 +#endif
62120 +
62121 +extern struct vfsmount *pipe_mnt;
62122 +extern struct vfsmount *shm_mnt;
62123 +
62124 +#ifdef CONFIG_HUGETLBFS
62125 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62126 +#endif
62127 +
62128 +static struct acl_object_label *fakefs_obj_rw;
62129 +static struct acl_object_label *fakefs_obj_rwx;
62130 +
62131 +extern int gr_init_uidset(void);
62132 +extern void gr_free_uidset(void);
62133 +extern void gr_remove_uid(uid_t uid);
62134 +extern int gr_find_uid(uid_t uid);
62135 +
62136 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
62137 +{
62138 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
62139 + return -EFAULT;
62140 +
62141 + return 0;
62142 +}
62143 +
62144 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
62145 +{
62146 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
62147 + return -EFAULT;
62148 +
62149 + return 0;
62150 +}
62151 +
62152 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62153 +{
62154 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
62155 + return -EFAULT;
62156 +
62157 + return 0;
62158 +}
62159 +
62160 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
62161 +{
62162 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
62163 + return -EFAULT;
62164 +
62165 + return 0;
62166 +}
62167 +
62168 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
62169 +{
62170 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
62171 + return -EFAULT;
62172 +
62173 + return 0;
62174 +}
62175 +
62176 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
62177 +{
62178 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
62179 + return -EFAULT;
62180 +
62181 + return 0;
62182 +}
62183 +
62184 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
62185 +{
62186 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
62187 + return -EFAULT;
62188 +
62189 + return 0;
62190 +}
62191 +
62192 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
62193 +{
62194 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
62195 + return -EFAULT;
62196 +
62197 + return 0;
62198 +}
62199 +
62200 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
62201 +{
62202 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
62203 + return -EFAULT;
62204 +
62205 + return 0;
62206 +}
62207 +
62208 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62209 +{
62210 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62211 + return -EFAULT;
62212 +
62213 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62214 + return -EINVAL;
62215 +
62216 + return 0;
62217 +}
62218 +
62219 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62220 +{
62221 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62222 + return -EFAULT;
62223 +
62224 + return 0;
62225 +}
62226 +
62227 +static size_t get_gr_arg_wrapper_size_normal(void)
62228 +{
62229 + return sizeof(struct gr_arg_wrapper);
62230 +}
62231 +
62232 +#ifdef CONFIG_COMPAT
62233 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62234 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62235 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62236 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62237 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62238 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62239 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62240 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62241 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62242 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62243 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62244 +extern size_t get_gr_arg_wrapper_size_compat(void);
62245 +
62246 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62247 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62248 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62249 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62250 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62251 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62252 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62253 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62254 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62255 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62256 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62257 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62258 +
62259 +#else
62260 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62261 +#define copy_gr_arg copy_gr_arg_normal
62262 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62263 +#define copy_acl_object_label copy_acl_object_label_normal
62264 +#define copy_acl_subject_label copy_acl_subject_label_normal
62265 +#define copy_acl_role_label copy_acl_role_label_normal
62266 +#define copy_acl_ip_label copy_acl_ip_label_normal
62267 +#define copy_pointer_from_array copy_pointer_from_array_normal
62268 +#define copy_sprole_pw copy_sprole_pw_normal
62269 +#define copy_role_transition copy_role_transition_normal
62270 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62271 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62272 +#endif
62273 +
62274 +__inline__ int
62275 +gr_acl_is_enabled(void)
62276 +{
62277 + return (gr_status & GR_READY);
62278 +}
62279 +
62280 +static inline dev_t __get_dev(const struct dentry *dentry)
62281 +{
62282 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62283 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62284 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62285 + else
62286 +#endif
62287 + return dentry->d_sb->s_dev;
62288 +}
62289 +
62290 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62291 +{
62292 + return __get_dev(dentry);
62293 +}
62294 +
62295 +static char gr_task_roletype_to_char(struct task_struct *task)
62296 +{
62297 + switch (task->role->roletype &
62298 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62299 + GR_ROLE_SPECIAL)) {
62300 + case GR_ROLE_DEFAULT:
62301 + return 'D';
62302 + case GR_ROLE_USER:
62303 + return 'U';
62304 + case GR_ROLE_GROUP:
62305 + return 'G';
62306 + case GR_ROLE_SPECIAL:
62307 + return 'S';
62308 + }
62309 +
62310 + return 'X';
62311 +}
62312 +
62313 +char gr_roletype_to_char(void)
62314 +{
62315 + return gr_task_roletype_to_char(current);
62316 +}
62317 +
62318 +__inline__ int
62319 +gr_acl_tpe_check(void)
62320 +{
62321 + if (unlikely(!(gr_status & GR_READY)))
62322 + return 0;
62323 + if (current->role->roletype & GR_ROLE_TPE)
62324 + return 1;
62325 + else
62326 + return 0;
62327 +}
62328 +
62329 +int
62330 +gr_handle_rawio(const struct inode *inode)
62331 +{
62332 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62333 + if (inode && S_ISBLK(inode->i_mode) &&
62334 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62335 + !capable(CAP_SYS_RAWIO))
62336 + return 1;
62337 +#endif
62338 + return 0;
62339 +}
62340 +
62341 +static int
62342 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62343 +{
62344 + if (likely(lena != lenb))
62345 + return 0;
62346 +
62347 + return !memcmp(a, b, lena);
62348 +}
62349 +
62350 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62351 +{
62352 + *buflen -= namelen;
62353 + if (*buflen < 0)
62354 + return -ENAMETOOLONG;
62355 + *buffer -= namelen;
62356 + memcpy(*buffer, str, namelen);
62357 + return 0;
62358 +}
62359 +
62360 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62361 +{
62362 + return prepend(buffer, buflen, name->name, name->len);
62363 +}
62364 +
62365 +static int prepend_path(const struct path *path, struct path *root,
62366 + char **buffer, int *buflen)
62367 +{
62368 + struct dentry *dentry = path->dentry;
62369 + struct vfsmount *vfsmnt = path->mnt;
62370 + struct mount *mnt = real_mount(vfsmnt);
62371 + bool slash = false;
62372 + int error = 0;
62373 +
62374 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62375 + struct dentry * parent;
62376 +
62377 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62378 + /* Global root? */
62379 + if (!mnt_has_parent(mnt)) {
62380 + goto out;
62381 + }
62382 + dentry = mnt->mnt_mountpoint;
62383 + mnt = mnt->mnt_parent;
62384 + vfsmnt = &mnt->mnt;
62385 + continue;
62386 + }
62387 + parent = dentry->d_parent;
62388 + prefetch(parent);
62389 + spin_lock(&dentry->d_lock);
62390 + error = prepend_name(buffer, buflen, &dentry->d_name);
62391 + spin_unlock(&dentry->d_lock);
62392 + if (!error)
62393 + error = prepend(buffer, buflen, "/", 1);
62394 + if (error)
62395 + break;
62396 +
62397 + slash = true;
62398 + dentry = parent;
62399 + }
62400 +
62401 +out:
62402 + if (!error && !slash)
62403 + error = prepend(buffer, buflen, "/", 1);
62404 +
62405 + return error;
62406 +}
62407 +
62408 +/* this must be called with vfsmount_lock and rename_lock held */
62409 +
62410 +static char *__our_d_path(const struct path *path, struct path *root,
62411 + char *buf, int buflen)
62412 +{
62413 + char *res = buf + buflen;
62414 + int error;
62415 +
62416 + prepend(&res, &buflen, "\0", 1);
62417 + error = prepend_path(path, root, &res, &buflen);
62418 + if (error)
62419 + return ERR_PTR(error);
62420 +
62421 + return res;
62422 +}
62423 +
62424 +static char *
62425 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62426 +{
62427 + char *retval;
62428 +
62429 + retval = __our_d_path(path, root, buf, buflen);
62430 + if (unlikely(IS_ERR(retval)))
62431 + retval = strcpy(buf, "<path too long>");
62432 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62433 + retval[1] = '\0';
62434 +
62435 + return retval;
62436 +}
62437 +
62438 +static char *
62439 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62440 + char *buf, int buflen)
62441 +{
62442 + struct path path;
62443 + char *res;
62444 +
62445 + path.dentry = (struct dentry *)dentry;
62446 + path.mnt = (struct vfsmount *)vfsmnt;
62447 +
62448 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62449 + by the RBAC system */
62450 + res = gen_full_path(&path, &real_root, buf, buflen);
62451 +
62452 + return res;
62453 +}
62454 +
62455 +static char *
62456 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62457 + char *buf, int buflen)
62458 +{
62459 + char *res;
62460 + struct path path;
62461 + struct path root;
62462 + struct task_struct *reaper = init_pid_ns.child_reaper;
62463 +
62464 + path.dentry = (struct dentry *)dentry;
62465 + path.mnt = (struct vfsmount *)vfsmnt;
62466 +
62467 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62468 + get_fs_root(reaper->fs, &root);
62469 +
62470 + br_read_lock(&vfsmount_lock);
62471 + write_seqlock(&rename_lock);
62472 + res = gen_full_path(&path, &root, buf, buflen);
62473 + write_sequnlock(&rename_lock);
62474 + br_read_unlock(&vfsmount_lock);
62475 +
62476 + path_put(&root);
62477 + return res;
62478 +}
62479 +
62480 +static char *
62481 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62482 +{
62483 + char *ret;
62484 + br_read_lock(&vfsmount_lock);
62485 + write_seqlock(&rename_lock);
62486 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62487 + PAGE_SIZE);
62488 + write_sequnlock(&rename_lock);
62489 + br_read_unlock(&vfsmount_lock);
62490 + return ret;
62491 +}
62492 +
62493 +static char *
62494 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62495 +{
62496 + char *ret;
62497 + char *buf;
62498 + int buflen;
62499 +
62500 + br_read_lock(&vfsmount_lock);
62501 + write_seqlock(&rename_lock);
62502 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62503 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62504 + buflen = (int)(ret - buf);
62505 + if (buflen >= 5)
62506 + prepend(&ret, &buflen, "/proc", 5);
62507 + else
62508 + ret = strcpy(buf, "<path too long>");
62509 + write_sequnlock(&rename_lock);
62510 + br_read_unlock(&vfsmount_lock);
62511 + return ret;
62512 +}
62513 +
62514 +char *
62515 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62516 +{
62517 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62518 + PAGE_SIZE);
62519 +}
62520 +
62521 +char *
62522 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62523 +{
62524 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62525 + PAGE_SIZE);
62526 +}
62527 +
62528 +char *
62529 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62530 +{
62531 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62532 + PAGE_SIZE);
62533 +}
62534 +
62535 +char *
62536 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62537 +{
62538 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62539 + PAGE_SIZE);
62540 +}
62541 +
62542 +char *
62543 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62544 +{
62545 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62546 + PAGE_SIZE);
62547 +}
62548 +
62549 +__inline__ __u32
62550 +to_gr_audit(const __u32 reqmode)
62551 +{
62552 + /* masks off auditable permission flags, then shifts them to create
62553 + auditing flags, and adds the special case of append auditing if
62554 + we're requesting write */
62555 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62556 +}
62557 +
62558 +struct acl_subject_label *
62559 +lookup_subject_map(const struct acl_subject_label *userp)
62560 +{
62561 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62562 + struct subject_map *match;
62563 +
62564 + match = subj_map_set.s_hash[index];
62565 +
62566 + while (match && match->user != userp)
62567 + match = match->next;
62568 +
62569 + if (match != NULL)
62570 + return match->kernel;
62571 + else
62572 + return NULL;
62573 +}
62574 +
62575 +static void
62576 +insert_subj_map_entry(struct subject_map *subjmap)
62577 +{
62578 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62579 + struct subject_map **curr;
62580 +
62581 + subjmap->prev = NULL;
62582 +
62583 + curr = &subj_map_set.s_hash[index];
62584 + if (*curr != NULL)
62585 + (*curr)->prev = subjmap;
62586 +
62587 + subjmap->next = *curr;
62588 + *curr = subjmap;
62589 +
62590 + return;
62591 +}
62592 +
62593 +static struct acl_role_label *
62594 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62595 + const gid_t gid)
62596 +{
62597 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62598 + struct acl_role_label *match;
62599 + struct role_allowed_ip *ipp;
62600 + unsigned int x;
62601 + u32 curr_ip = task->signal->curr_ip;
62602 +
62603 + task->signal->saved_ip = curr_ip;
62604 +
62605 + match = acl_role_set.r_hash[index];
62606 +
62607 + while (match) {
62608 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62609 + for (x = 0; x < match->domain_child_num; x++) {
62610 + if (match->domain_children[x] == uid)
62611 + goto found;
62612 + }
62613 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62614 + break;
62615 + match = match->next;
62616 + }
62617 +found:
62618 + if (match == NULL) {
62619 + try_group:
62620 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62621 + match = acl_role_set.r_hash[index];
62622 +
62623 + while (match) {
62624 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62625 + for (x = 0; x < match->domain_child_num; x++) {
62626 + if (match->domain_children[x] == gid)
62627 + goto found2;
62628 + }
62629 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62630 + break;
62631 + match = match->next;
62632 + }
62633 +found2:
62634 + if (match == NULL)
62635 + match = default_role;
62636 + if (match->allowed_ips == NULL)
62637 + return match;
62638 + else {
62639 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62640 + if (likely
62641 + ((ntohl(curr_ip) & ipp->netmask) ==
62642 + (ntohl(ipp->addr) & ipp->netmask)))
62643 + return match;
62644 + }
62645 + match = default_role;
62646 + }
62647 + } else if (match->allowed_ips == NULL) {
62648 + return match;
62649 + } else {
62650 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62651 + if (likely
62652 + ((ntohl(curr_ip) & ipp->netmask) ==
62653 + (ntohl(ipp->addr) & ipp->netmask)))
62654 + return match;
62655 + }
62656 + goto try_group;
62657 + }
62658 +
62659 + return match;
62660 +}
62661 +
62662 +struct acl_subject_label *
62663 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62664 + const struct acl_role_label *role)
62665 +{
62666 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62667 + struct acl_subject_label *match;
62668 +
62669 + match = role->subj_hash[index];
62670 +
62671 + while (match && (match->inode != ino || match->device != dev ||
62672 + (match->mode & GR_DELETED))) {
62673 + match = match->next;
62674 + }
62675 +
62676 + if (match && !(match->mode & GR_DELETED))
62677 + return match;
62678 + else
62679 + return NULL;
62680 +}
62681 +
62682 +struct acl_subject_label *
62683 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62684 + const struct acl_role_label *role)
62685 +{
62686 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62687 + struct acl_subject_label *match;
62688 +
62689 + match = role->subj_hash[index];
62690 +
62691 + while (match && (match->inode != ino || match->device != dev ||
62692 + !(match->mode & GR_DELETED))) {
62693 + match = match->next;
62694 + }
62695 +
62696 + if (match && (match->mode & GR_DELETED))
62697 + return match;
62698 + else
62699 + return NULL;
62700 +}
62701 +
62702 +static struct acl_object_label *
62703 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62704 + const struct acl_subject_label *subj)
62705 +{
62706 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62707 + struct acl_object_label *match;
62708 +
62709 + match = subj->obj_hash[index];
62710 +
62711 + while (match && (match->inode != ino || match->device != dev ||
62712 + (match->mode & GR_DELETED))) {
62713 + match = match->next;
62714 + }
62715 +
62716 + if (match && !(match->mode & GR_DELETED))
62717 + return match;
62718 + else
62719 + return NULL;
62720 +}
62721 +
62722 +static struct acl_object_label *
62723 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62724 + const struct acl_subject_label *subj)
62725 +{
62726 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62727 + struct acl_object_label *match;
62728 +
62729 + match = subj->obj_hash[index];
62730 +
62731 + while (match && (match->inode != ino || match->device != dev ||
62732 + !(match->mode & GR_DELETED))) {
62733 + match = match->next;
62734 + }
62735 +
62736 + if (match && (match->mode & GR_DELETED))
62737 + return match;
62738 +
62739 + match = subj->obj_hash[index];
62740 +
62741 + while (match && (match->inode != ino || match->device != dev ||
62742 + (match->mode & GR_DELETED))) {
62743 + match = match->next;
62744 + }
62745 +
62746 + if (match && !(match->mode & GR_DELETED))
62747 + return match;
62748 + else
62749 + return NULL;
62750 +}
62751 +
62752 +static struct name_entry *
62753 +lookup_name_entry(const char *name)
62754 +{
62755 + unsigned int len = strlen(name);
62756 + unsigned int key = full_name_hash(name, len);
62757 + unsigned int index = key % name_set.n_size;
62758 + struct name_entry *match;
62759 +
62760 + match = name_set.n_hash[index];
62761 +
62762 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
62763 + match = match->next;
62764 +
62765 + return match;
62766 +}
62767 +
62768 +static struct name_entry *
62769 +lookup_name_entry_create(const char *name)
62770 +{
62771 + unsigned int len = strlen(name);
62772 + unsigned int key = full_name_hash(name, len);
62773 + unsigned int index = key % name_set.n_size;
62774 + struct name_entry *match;
62775 +
62776 + match = name_set.n_hash[index];
62777 +
62778 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62779 + !match->deleted))
62780 + match = match->next;
62781 +
62782 + if (match && match->deleted)
62783 + return match;
62784 +
62785 + match = name_set.n_hash[index];
62786 +
62787 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62788 + match->deleted))
62789 + match = match->next;
62790 +
62791 + if (match && !match->deleted)
62792 + return match;
62793 + else
62794 + return NULL;
62795 +}
62796 +
62797 +static struct inodev_entry *
62798 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
62799 +{
62800 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
62801 + struct inodev_entry *match;
62802 +
62803 + match = inodev_set.i_hash[index];
62804 +
62805 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
62806 + match = match->next;
62807 +
62808 + return match;
62809 +}
62810 +
62811 +static void
62812 +insert_inodev_entry(struct inodev_entry *entry)
62813 +{
62814 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
62815 + inodev_set.i_size);
62816 + struct inodev_entry **curr;
62817 +
62818 + entry->prev = NULL;
62819 +
62820 + curr = &inodev_set.i_hash[index];
62821 + if (*curr != NULL)
62822 + (*curr)->prev = entry;
62823 +
62824 + entry->next = *curr;
62825 + *curr = entry;
62826 +
62827 + return;
62828 +}
62829 +
62830 +static void
62831 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
62832 +{
62833 + unsigned int index =
62834 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
62835 + struct acl_role_label **curr;
62836 + struct acl_role_label *tmp, *tmp2;
62837 +
62838 + curr = &acl_role_set.r_hash[index];
62839 +
62840 + /* simple case, slot is empty, just set it to our role */
62841 + if (*curr == NULL) {
62842 + *curr = role;
62843 + } else {
62844 + /* example:
62845 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
62846 + 2 -> 3
62847 + */
62848 + /* first check to see if we can already be reached via this slot */
62849 + tmp = *curr;
62850 + while (tmp && tmp != role)
62851 + tmp = tmp->next;
62852 + if (tmp == role) {
62853 + /* we don't need to add ourselves to this slot's chain */
62854 + return;
62855 + }
62856 + /* we need to add ourselves to this chain, two cases */
62857 + if (role->next == NULL) {
62858 + /* simple case, append the current chain to our role */
62859 + role->next = *curr;
62860 + *curr = role;
62861 + } else {
62862 + /* 1 -> 2 -> 3 -> 4
62863 + 2 -> 3 -> 4
62864 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
62865 + */
62866 + /* trickier case: walk our role's chain until we find
62867 + the role for the start of the current slot's chain */
62868 + tmp = role;
62869 + tmp2 = *curr;
62870 + while (tmp->next && tmp->next != tmp2)
62871 + tmp = tmp->next;
62872 + if (tmp->next == tmp2) {
62873 + /* from example above, we found 3, so just
62874 + replace this slot's chain with ours */
62875 + *curr = role;
62876 + } else {
62877 + /* we didn't find a subset of our role's chain
62878 + in the current slot's chain, so append their
62879 + chain to ours, and set us as the first role in
62880 + the slot's chain
62881 +
62882 + we could fold this case with the case above,
62883 + but making it explicit for clarity
62884 + */
62885 + tmp->next = tmp2;
62886 + *curr = role;
62887 + }
62888 + }
62889 + }
62890 +
62891 + return;
62892 +}
62893 +
62894 +static void
62895 +insert_acl_role_label(struct acl_role_label *role)
62896 +{
62897 + int i;
62898 +
62899 + if (role_list == NULL) {
62900 + role_list = role;
62901 + role->prev = NULL;
62902 + } else {
62903 + role->prev = role_list;
62904 + role_list = role;
62905 + }
62906 +
62907 + /* used for hash chains */
62908 + role->next = NULL;
62909 +
62910 + if (role->roletype & GR_ROLE_DOMAIN) {
62911 + for (i = 0; i < role->domain_child_num; i++)
62912 + __insert_acl_role_label(role, role->domain_children[i]);
62913 + } else
62914 + __insert_acl_role_label(role, role->uidgid);
62915 +}
62916 +
62917 +static int
62918 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
62919 +{
62920 + struct name_entry **curr, *nentry;
62921 + struct inodev_entry *ientry;
62922 + unsigned int len = strlen(name);
62923 + unsigned int key = full_name_hash(name, len);
62924 + unsigned int index = key % name_set.n_size;
62925 +
62926 + curr = &name_set.n_hash[index];
62927 +
62928 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
62929 + curr = &((*curr)->next);
62930 +
62931 + if (*curr != NULL)
62932 + return 1;
62933 +
62934 + nentry = acl_alloc(sizeof (struct name_entry));
62935 + if (nentry == NULL)
62936 + return 0;
62937 + ientry = acl_alloc(sizeof (struct inodev_entry));
62938 + if (ientry == NULL)
62939 + return 0;
62940 + ientry->nentry = nentry;
62941 +
62942 + nentry->key = key;
62943 + nentry->name = name;
62944 + nentry->inode = inode;
62945 + nentry->device = device;
62946 + nentry->len = len;
62947 + nentry->deleted = deleted;
62948 +
62949 + nentry->prev = NULL;
62950 + curr = &name_set.n_hash[index];
62951 + if (*curr != NULL)
62952 + (*curr)->prev = nentry;
62953 + nentry->next = *curr;
62954 + *curr = nentry;
62955 +
62956 + /* insert us into the table searchable by inode/dev */
62957 + insert_inodev_entry(ientry);
62958 +
62959 + return 1;
62960 +}
62961 +
62962 +static void
62963 +insert_acl_obj_label(struct acl_object_label *obj,
62964 + struct acl_subject_label *subj)
62965 +{
62966 + unsigned int index =
62967 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
62968 + struct acl_object_label **curr;
62969 +
62970 +
62971 + obj->prev = NULL;
62972 +
62973 + curr = &subj->obj_hash[index];
62974 + if (*curr != NULL)
62975 + (*curr)->prev = obj;
62976 +
62977 + obj->next = *curr;
62978 + *curr = obj;
62979 +
62980 + return;
62981 +}
62982 +
62983 +static void
62984 +insert_acl_subj_label(struct acl_subject_label *obj,
62985 + struct acl_role_label *role)
62986 +{
62987 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
62988 + struct acl_subject_label **curr;
62989 +
62990 + obj->prev = NULL;
62991 +
62992 + curr = &role->subj_hash[index];
62993 + if (*curr != NULL)
62994 + (*curr)->prev = obj;
62995 +
62996 + obj->next = *curr;
62997 + *curr = obj;
62998 +
62999 + return;
63000 +}
63001 +
63002 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
63003 +
63004 +static void *
63005 +create_table(__u32 * len, int elementsize)
63006 +{
63007 + unsigned int table_sizes[] = {
63008 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
63009 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
63010 + 4194301, 8388593, 16777213, 33554393, 67108859
63011 + };
63012 + void *newtable = NULL;
63013 + unsigned int pwr = 0;
63014 +
63015 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
63016 + table_sizes[pwr] <= *len)
63017 + pwr++;
63018 +
63019 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
63020 + return newtable;
63021 +
63022 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
63023 + newtable =
63024 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
63025 + else
63026 + newtable = vmalloc(table_sizes[pwr] * elementsize);
63027 +
63028 + *len = table_sizes[pwr];
63029 +
63030 + return newtable;
63031 +}
63032 +
63033 +static int
63034 +init_variables(const struct gr_arg *arg)
63035 +{
63036 + struct task_struct *reaper = init_pid_ns.child_reaper;
63037 + unsigned int stacksize;
63038 +
63039 + subj_map_set.s_size = arg->role_db.num_subjects;
63040 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
63041 + name_set.n_size = arg->role_db.num_objects;
63042 + inodev_set.i_size = arg->role_db.num_objects;
63043 +
63044 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
63045 + !name_set.n_size || !inodev_set.i_size)
63046 + return 1;
63047 +
63048 + if (!gr_init_uidset())
63049 + return 1;
63050 +
63051 + /* set up the stack that holds allocation info */
63052 +
63053 + stacksize = arg->role_db.num_pointers + 5;
63054 +
63055 + if (!acl_alloc_stack_init(stacksize))
63056 + return 1;
63057 +
63058 + /* grab reference for the real root dentry and vfsmount */
63059 + get_fs_root(reaper->fs, &real_root);
63060 +
63061 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63062 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
63063 +#endif
63064 +
63065 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
63066 + if (fakefs_obj_rw == NULL)
63067 + return 1;
63068 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
63069 +
63070 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
63071 + if (fakefs_obj_rwx == NULL)
63072 + return 1;
63073 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
63074 +
63075 + subj_map_set.s_hash =
63076 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
63077 + acl_role_set.r_hash =
63078 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
63079 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
63080 + inodev_set.i_hash =
63081 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
63082 +
63083 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
63084 + !name_set.n_hash || !inodev_set.i_hash)
63085 + return 1;
63086 +
63087 + memset(subj_map_set.s_hash, 0,
63088 + sizeof(struct subject_map *) * subj_map_set.s_size);
63089 + memset(acl_role_set.r_hash, 0,
63090 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
63091 + memset(name_set.n_hash, 0,
63092 + sizeof (struct name_entry *) * name_set.n_size);
63093 + memset(inodev_set.i_hash, 0,
63094 + sizeof (struct inodev_entry *) * inodev_set.i_size);
63095 +
63096 + return 0;
63097 +}
63098 +
63099 +/* free information not needed after startup
63100 + currently contains user->kernel pointer mappings for subjects
63101 +*/
63102 +
63103 +static void
63104 +free_init_variables(void)
63105 +{
63106 + __u32 i;
63107 +
63108 + if (subj_map_set.s_hash) {
63109 + for (i = 0; i < subj_map_set.s_size; i++) {
63110 + if (subj_map_set.s_hash[i]) {
63111 + kfree(subj_map_set.s_hash[i]);
63112 + subj_map_set.s_hash[i] = NULL;
63113 + }
63114 + }
63115 +
63116 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
63117 + PAGE_SIZE)
63118 + kfree(subj_map_set.s_hash);
63119 + else
63120 + vfree(subj_map_set.s_hash);
63121 + }
63122 +
63123 + return;
63124 +}
63125 +
63126 +static void
63127 +free_variables(void)
63128 +{
63129 + struct acl_subject_label *s;
63130 + struct acl_role_label *r;
63131 + struct task_struct *task, *task2;
63132 + unsigned int x;
63133 +
63134 + gr_clear_learn_entries();
63135 +
63136 + read_lock(&tasklist_lock);
63137 + do_each_thread(task2, task) {
63138 + task->acl_sp_role = 0;
63139 + task->acl_role_id = 0;
63140 + task->acl = NULL;
63141 + task->role = NULL;
63142 + } while_each_thread(task2, task);
63143 + read_unlock(&tasklist_lock);
63144 +
63145 + /* release the reference to the real root dentry and vfsmount */
63146 + path_put(&real_root);
63147 + memset(&real_root, 0, sizeof(real_root));
63148 +
63149 + /* free all object hash tables */
63150 +
63151 + FOR_EACH_ROLE_START(r)
63152 + if (r->subj_hash == NULL)
63153 + goto next_role;
63154 + FOR_EACH_SUBJECT_START(r, s, x)
63155 + if (s->obj_hash == NULL)
63156 + break;
63157 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63158 + kfree(s->obj_hash);
63159 + else
63160 + vfree(s->obj_hash);
63161 + FOR_EACH_SUBJECT_END(s, x)
63162 + FOR_EACH_NESTED_SUBJECT_START(r, s)
63163 + if (s->obj_hash == NULL)
63164 + break;
63165 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63166 + kfree(s->obj_hash);
63167 + else
63168 + vfree(s->obj_hash);
63169 + FOR_EACH_NESTED_SUBJECT_END(s)
63170 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
63171 + kfree(r->subj_hash);
63172 + else
63173 + vfree(r->subj_hash);
63174 + r->subj_hash = NULL;
63175 +next_role:
63176 + FOR_EACH_ROLE_END(r)
63177 +
63178 + acl_free_all();
63179 +
63180 + if (acl_role_set.r_hash) {
63181 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
63182 + PAGE_SIZE)
63183 + kfree(acl_role_set.r_hash);
63184 + else
63185 + vfree(acl_role_set.r_hash);
63186 + }
63187 + if (name_set.n_hash) {
63188 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
63189 + PAGE_SIZE)
63190 + kfree(name_set.n_hash);
63191 + else
63192 + vfree(name_set.n_hash);
63193 + }
63194 +
63195 + if (inodev_set.i_hash) {
63196 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
63197 + PAGE_SIZE)
63198 + kfree(inodev_set.i_hash);
63199 + else
63200 + vfree(inodev_set.i_hash);
63201 + }
63202 +
63203 + gr_free_uidset();
63204 +
63205 + memset(&name_set, 0, sizeof (struct name_db));
63206 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63207 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63208 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63209 +
63210 + default_role = NULL;
63211 + kernel_role = NULL;
63212 + role_list = NULL;
63213 +
63214 + return;
63215 +}
63216 +
63217 +static struct acl_subject_label *
63218 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63219 +
63220 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63221 +{
63222 + unsigned int len = strnlen_user(*name, maxlen);
63223 + char *tmp;
63224 +
63225 + if (!len || len >= maxlen)
63226 + return -EINVAL;
63227 +
63228 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63229 + return -ENOMEM;
63230 +
63231 + if (copy_from_user(tmp, *name, len))
63232 + return -EFAULT;
63233 +
63234 + tmp[len-1] = '\0';
63235 + *name = tmp;
63236 +
63237 + return 0;
63238 +}
63239 +
63240 +static int
63241 +copy_user_glob(struct acl_object_label *obj)
63242 +{
63243 + struct acl_object_label *g_tmp, **guser;
63244 + int error;
63245 +
63246 + if (obj->globbed == NULL)
63247 + return 0;
63248 +
63249 + guser = &obj->globbed;
63250 + while (*guser) {
63251 + g_tmp = (struct acl_object_label *)
63252 + acl_alloc(sizeof (struct acl_object_label));
63253 + if (g_tmp == NULL)
63254 + return -ENOMEM;
63255 +
63256 + if (copy_acl_object_label(g_tmp, *guser))
63257 + return -EFAULT;
63258 +
63259 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63260 + if (error)
63261 + return error;
63262 +
63263 + *guser = g_tmp;
63264 + guser = &(g_tmp->next);
63265 + }
63266 +
63267 + return 0;
63268 +}
63269 +
63270 +static int
63271 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63272 + struct acl_role_label *role)
63273 +{
63274 + struct acl_object_label *o_tmp;
63275 + int ret;
63276 +
63277 + while (userp) {
63278 + if ((o_tmp = (struct acl_object_label *)
63279 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63280 + return -ENOMEM;
63281 +
63282 + if (copy_acl_object_label(o_tmp, userp))
63283 + return -EFAULT;
63284 +
63285 + userp = o_tmp->prev;
63286 +
63287 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63288 + if (ret)
63289 + return ret;
63290 +
63291 + insert_acl_obj_label(o_tmp, subj);
63292 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63293 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63294 + return -ENOMEM;
63295 +
63296 + ret = copy_user_glob(o_tmp);
63297 + if (ret)
63298 + return ret;
63299 +
63300 + if (o_tmp->nested) {
63301 + int already_copied;
63302 +
63303 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63304 + if (IS_ERR(o_tmp->nested))
63305 + return PTR_ERR(o_tmp->nested);
63306 +
63307 + /* insert into nested subject list if we haven't copied this one yet
63308 + to prevent duplicate entries */
63309 + if (!already_copied) {
63310 + o_tmp->nested->next = role->hash->first;
63311 + role->hash->first = o_tmp->nested;
63312 + }
63313 + }
63314 + }
63315 +
63316 + return 0;
63317 +}
63318 +
63319 +static __u32
63320 +count_user_subjs(struct acl_subject_label *userp)
63321 +{
63322 + struct acl_subject_label s_tmp;
63323 + __u32 num = 0;
63324 +
63325 + while (userp) {
63326 + if (copy_acl_subject_label(&s_tmp, userp))
63327 + break;
63328 +
63329 + userp = s_tmp.prev;
63330 + }
63331 +
63332 + return num;
63333 +}
63334 +
63335 +static int
63336 +copy_user_allowedips(struct acl_role_label *rolep)
63337 +{
63338 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63339 +
63340 + ruserip = rolep->allowed_ips;
63341 +
63342 + while (ruserip) {
63343 + rlast = rtmp;
63344 +
63345 + if ((rtmp = (struct role_allowed_ip *)
63346 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63347 + return -ENOMEM;
63348 +
63349 + if (copy_role_allowed_ip(rtmp, ruserip))
63350 + return -EFAULT;
63351 +
63352 + ruserip = rtmp->prev;
63353 +
63354 + if (!rlast) {
63355 + rtmp->prev = NULL;
63356 + rolep->allowed_ips = rtmp;
63357 + } else {
63358 + rlast->next = rtmp;
63359 + rtmp->prev = rlast;
63360 + }
63361 +
63362 + if (!ruserip)
63363 + rtmp->next = NULL;
63364 + }
63365 +
63366 + return 0;
63367 +}
63368 +
63369 +static int
63370 +copy_user_transitions(struct acl_role_label *rolep)
63371 +{
63372 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63373 + int error;
63374 +
63375 + rusertp = rolep->transitions;
63376 +
63377 + while (rusertp) {
63378 + rlast = rtmp;
63379 +
63380 + if ((rtmp = (struct role_transition *)
63381 + acl_alloc(sizeof (struct role_transition))) == NULL)
63382 + return -ENOMEM;
63383 +
63384 + if (copy_role_transition(rtmp, rusertp))
63385 + return -EFAULT;
63386 +
63387 + rusertp = rtmp->prev;
63388 +
63389 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63390 + if (error)
63391 + return error;
63392 +
63393 + if (!rlast) {
63394 + rtmp->prev = NULL;
63395 + rolep->transitions = rtmp;
63396 + } else {
63397 + rlast->next = rtmp;
63398 + rtmp->prev = rlast;
63399 + }
63400 +
63401 + if (!rusertp)
63402 + rtmp->next = NULL;
63403 + }
63404 +
63405 + return 0;
63406 +}
63407 +
63408 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63409 +{
63410 + struct acl_object_label o_tmp;
63411 + __u32 num = 0;
63412 +
63413 + while (userp) {
63414 + if (copy_acl_object_label(&o_tmp, userp))
63415 + break;
63416 +
63417 + userp = o_tmp.prev;
63418 + num++;
63419 + }
63420 +
63421 + return num;
63422 +}
63423 +
63424 +static struct acl_subject_label *
63425 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63426 +{
63427 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63428 + __u32 num_objs;
63429 + struct acl_ip_label **i_tmp, *i_utmp2;
63430 + struct gr_hash_struct ghash;
63431 + struct subject_map *subjmap;
63432 + unsigned int i_num;
63433 + int err;
63434 +
63435 + if (already_copied != NULL)
63436 + *already_copied = 0;
63437 +
63438 + s_tmp = lookup_subject_map(userp);
63439 +
63440 + /* we've already copied this subject into the kernel, just return
63441 + the reference to it, and don't copy it over again
63442 + */
63443 + if (s_tmp) {
63444 + if (already_copied != NULL)
63445 + *already_copied = 1;
63446 + return(s_tmp);
63447 + }
63448 +
63449 + if ((s_tmp = (struct acl_subject_label *)
63450 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63451 + return ERR_PTR(-ENOMEM);
63452 +
63453 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63454 + if (subjmap == NULL)
63455 + return ERR_PTR(-ENOMEM);
63456 +
63457 + subjmap->user = userp;
63458 + subjmap->kernel = s_tmp;
63459 + insert_subj_map_entry(subjmap);
63460 +
63461 + if (copy_acl_subject_label(s_tmp, userp))
63462 + return ERR_PTR(-EFAULT);
63463 +
63464 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63465 + if (err)
63466 + return ERR_PTR(err);
63467 +
63468 + if (!strcmp(s_tmp->filename, "/"))
63469 + role->root_label = s_tmp;
63470 +
63471 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63472 + return ERR_PTR(-EFAULT);
63473 +
63474 + /* copy user and group transition tables */
63475 +
63476 + if (s_tmp->user_trans_num) {
63477 + uid_t *uidlist;
63478 +
63479 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63480 + if (uidlist == NULL)
63481 + return ERR_PTR(-ENOMEM);
63482 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63483 + return ERR_PTR(-EFAULT);
63484 +
63485 + s_tmp->user_transitions = uidlist;
63486 + }
63487 +
63488 + if (s_tmp->group_trans_num) {
63489 + gid_t *gidlist;
63490 +
63491 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63492 + if (gidlist == NULL)
63493 + return ERR_PTR(-ENOMEM);
63494 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63495 + return ERR_PTR(-EFAULT);
63496 +
63497 + s_tmp->group_transitions = gidlist;
63498 + }
63499 +
63500 + /* set up object hash table */
63501 + num_objs = count_user_objs(ghash.first);
63502 +
63503 + s_tmp->obj_hash_size = num_objs;
63504 + s_tmp->obj_hash =
63505 + (struct acl_object_label **)
63506 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63507 +
63508 + if (!s_tmp->obj_hash)
63509 + return ERR_PTR(-ENOMEM);
63510 +
63511 + memset(s_tmp->obj_hash, 0,
63512 + s_tmp->obj_hash_size *
63513 + sizeof (struct acl_object_label *));
63514 +
63515 + /* add in objects */
63516 + err = copy_user_objs(ghash.first, s_tmp, role);
63517 +
63518 + if (err)
63519 + return ERR_PTR(err);
63520 +
63521 + /* set pointer for parent subject */
63522 + if (s_tmp->parent_subject) {
63523 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63524 +
63525 + if (IS_ERR(s_tmp2))
63526 + return s_tmp2;
63527 +
63528 + s_tmp->parent_subject = s_tmp2;
63529 + }
63530 +
63531 + /* add in ip acls */
63532 +
63533 + if (!s_tmp->ip_num) {
63534 + s_tmp->ips = NULL;
63535 + goto insert;
63536 + }
63537 +
63538 + i_tmp =
63539 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63540 + sizeof (struct acl_ip_label *));
63541 +
63542 + if (!i_tmp)
63543 + return ERR_PTR(-ENOMEM);
63544 +
63545 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63546 + *(i_tmp + i_num) =
63547 + (struct acl_ip_label *)
63548 + acl_alloc(sizeof (struct acl_ip_label));
63549 + if (!*(i_tmp + i_num))
63550 + return ERR_PTR(-ENOMEM);
63551 +
63552 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63553 + return ERR_PTR(-EFAULT);
63554 +
63555 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63556 + return ERR_PTR(-EFAULT);
63557 +
63558 + if ((*(i_tmp + i_num))->iface == NULL)
63559 + continue;
63560 +
63561 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63562 + if (err)
63563 + return ERR_PTR(err);
63564 + }
63565 +
63566 + s_tmp->ips = i_tmp;
63567 +
63568 +insert:
63569 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63570 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63571 + return ERR_PTR(-ENOMEM);
63572 +
63573 + return s_tmp;
63574 +}
63575 +
63576 +static int
63577 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63578 +{
63579 + struct acl_subject_label s_pre;
63580 + struct acl_subject_label * ret;
63581 + int err;
63582 +
63583 + while (userp) {
63584 + if (copy_acl_subject_label(&s_pre, userp))
63585 + return -EFAULT;
63586 +
63587 + ret = do_copy_user_subj(userp, role, NULL);
63588 +
63589 + err = PTR_ERR(ret);
63590 + if (IS_ERR(ret))
63591 + return err;
63592 +
63593 + insert_acl_subj_label(ret, role);
63594 +
63595 + userp = s_pre.prev;
63596 + }
63597 +
63598 + return 0;
63599 +}
63600 +
63601 +static int
63602 +copy_user_acl(struct gr_arg *arg)
63603 +{
63604 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63605 + struct acl_subject_label *subj_list;
63606 + struct sprole_pw *sptmp;
63607 + struct gr_hash_struct *ghash;
63608 + uid_t *domainlist;
63609 + unsigned int r_num;
63610 + int err = 0;
63611 + __u16 i;
63612 + __u32 num_subjs;
63613 +
63614 + /* we need a default and kernel role */
63615 + if (arg->role_db.num_roles < 2)
63616 + return -EINVAL;
63617 +
63618 + /* copy special role authentication info from userspace */
63619 +
63620 + num_sprole_pws = arg->num_sprole_pws;
63621 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63622 +
63623 + if (!acl_special_roles && num_sprole_pws)
63624 + return -ENOMEM;
63625 +
63626 + for (i = 0; i < num_sprole_pws; i++) {
63627 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63628 + if (!sptmp)
63629 + return -ENOMEM;
63630 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63631 + return -EFAULT;
63632 +
63633 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63634 + if (err)
63635 + return err;
63636 +
63637 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63638 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63639 +#endif
63640 +
63641 + acl_special_roles[i] = sptmp;
63642 + }
63643 +
63644 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63645 +
63646 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63647 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63648 +
63649 + if (!r_tmp)
63650 + return -ENOMEM;
63651 +
63652 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63653 + return -EFAULT;
63654 +
63655 + if (copy_acl_role_label(r_tmp, r_utmp2))
63656 + return -EFAULT;
63657 +
63658 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63659 + if (err)
63660 + return err;
63661 +
63662 + if (!strcmp(r_tmp->rolename, "default")
63663 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63664 + default_role = r_tmp;
63665 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63666 + kernel_role = r_tmp;
63667 + }
63668 +
63669 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63670 + return -ENOMEM;
63671 +
63672 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63673 + return -EFAULT;
63674 +
63675 + r_tmp->hash = ghash;
63676 +
63677 + num_subjs = count_user_subjs(r_tmp->hash->first);
63678 +
63679 + r_tmp->subj_hash_size = num_subjs;
63680 + r_tmp->subj_hash =
63681 + (struct acl_subject_label **)
63682 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
63683 +
63684 + if (!r_tmp->subj_hash)
63685 + return -ENOMEM;
63686 +
63687 + err = copy_user_allowedips(r_tmp);
63688 + if (err)
63689 + return err;
63690 +
63691 + /* copy domain info */
63692 + if (r_tmp->domain_children != NULL) {
63693 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
63694 + if (domainlist == NULL)
63695 + return -ENOMEM;
63696 +
63697 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
63698 + return -EFAULT;
63699 +
63700 + r_tmp->domain_children = domainlist;
63701 + }
63702 +
63703 + err = copy_user_transitions(r_tmp);
63704 + if (err)
63705 + return err;
63706 +
63707 + memset(r_tmp->subj_hash, 0,
63708 + r_tmp->subj_hash_size *
63709 + sizeof (struct acl_subject_label *));
63710 +
63711 + /* acquire the list of subjects, then NULL out
63712 + the list prior to parsing the subjects for this role,
63713 + as during this parsing the list is replaced with a list
63714 + of *nested* subjects for the role
63715 + */
63716 + subj_list = r_tmp->hash->first;
63717 +
63718 + /* set nested subject list to null */
63719 + r_tmp->hash->first = NULL;
63720 +
63721 + err = copy_user_subjs(subj_list, r_tmp);
63722 +
63723 + if (err)
63724 + return err;
63725 +
63726 + insert_acl_role_label(r_tmp);
63727 + }
63728 +
63729 + if (default_role == NULL || kernel_role == NULL)
63730 + return -EINVAL;
63731 +
63732 + return err;
63733 +}
63734 +
63735 +static int
63736 +gracl_init(struct gr_arg *args)
63737 +{
63738 + int error = 0;
63739 +
63740 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
63741 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
63742 +
63743 + if (init_variables(args)) {
63744 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
63745 + error = -ENOMEM;
63746 + free_variables();
63747 + goto out;
63748 + }
63749 +
63750 + error = copy_user_acl(args);
63751 + free_init_variables();
63752 + if (error) {
63753 + free_variables();
63754 + goto out;
63755 + }
63756 +
63757 + if ((error = gr_set_acls(0))) {
63758 + free_variables();
63759 + goto out;
63760 + }
63761 +
63762 + pax_open_kernel();
63763 + gr_status |= GR_READY;
63764 + pax_close_kernel();
63765 +
63766 + out:
63767 + return error;
63768 +}
63769 +
63770 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63771 +
63772 +static int
63773 +glob_match(const char *p, const char *n)
63774 +{
63775 + char c;
63776 +
63777 + while ((c = *p++) != '\0') {
63778 + switch (c) {
63779 + case '?':
63780 + if (*n == '\0')
63781 + return 1;
63782 + else if (*n == '/')
63783 + return 1;
63784 + break;
63785 + case '\\':
63786 + if (*n != c)
63787 + return 1;
63788 + break;
63789 + case '*':
63790 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63791 + if (*n == '/')
63792 + return 1;
63793 + else if (c == '?') {
63794 + if (*n == '\0')
63795 + return 1;
63796 + else
63797 + ++n;
63798 + }
63799 + }
63800 + if (c == '\0') {
63801 + return 0;
63802 + } else {
63803 + const char *endp;
63804 +
63805 + if ((endp = strchr(n, '/')) == NULL)
63806 + endp = n + strlen(n);
63807 +
63808 + if (c == '[') {
63809 + for (--p; n < endp; ++n)
63810 + if (!glob_match(p, n))
63811 + return 0;
63812 + } else if (c == '/') {
63813 + while (*n != '\0' && *n != '/')
63814 + ++n;
63815 + if (*n == '/' && !glob_match(p, n + 1))
63816 + return 0;
63817 + } else {
63818 + for (--p; n < endp; ++n)
63819 + if (*n == c && !glob_match(p, n))
63820 + return 0;
63821 + }
63822 +
63823 + return 1;
63824 + }
63825 + case '[':
63826 + {
63827 + int not;
63828 + char cold;
63829 +
63830 + if (*n == '\0' || *n == '/')
63831 + return 1;
63832 +
63833 + not = (*p == '!' || *p == '^');
63834 + if (not)
63835 + ++p;
63836 +
63837 + c = *p++;
63838 + for (;;) {
63839 + unsigned char fn = (unsigned char)*n;
63840 +
63841 + if (c == '\0')
63842 + return 1;
63843 + else {
63844 + if (c == fn)
63845 + goto matched;
63846 + cold = c;
63847 + c = *p++;
63848 +
63849 + if (c == '-' && *p != ']') {
63850 + unsigned char cend = *p++;
63851 +
63852 + if (cend == '\0')
63853 + return 1;
63854 +
63855 + if (cold <= fn && fn <= cend)
63856 + goto matched;
63857 +
63858 + c = *p++;
63859 + }
63860 + }
63861 +
63862 + if (c == ']')
63863 + break;
63864 + }
63865 + if (!not)
63866 + return 1;
63867 + break;
63868 + matched:
63869 + while (c != ']') {
63870 + if (c == '\0')
63871 + return 1;
63872 +
63873 + c = *p++;
63874 + }
63875 + if (not)
63876 + return 1;
63877 + }
63878 + break;
63879 + default:
63880 + if (c != *n)
63881 + return 1;
63882 + }
63883 +
63884 + ++n;
63885 + }
63886 +
63887 + if (*n == '\0')
63888 + return 0;
63889 +
63890 + if (*n == '/')
63891 + return 0;
63892 +
63893 + return 1;
63894 +}
63895 +
63896 +static struct acl_object_label *
63897 +chk_glob_label(struct acl_object_label *globbed,
63898 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
63899 +{
63900 + struct acl_object_label *tmp;
63901 +
63902 + if (*path == NULL)
63903 + *path = gr_to_filename_nolock(dentry, mnt);
63904 +
63905 + tmp = globbed;
63906 +
63907 + while (tmp) {
63908 + if (!glob_match(tmp->filename, *path))
63909 + return tmp;
63910 + tmp = tmp->next;
63911 + }
63912 +
63913 + return NULL;
63914 +}
63915 +
63916 +static struct acl_object_label *
63917 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63918 + const ino_t curr_ino, const dev_t curr_dev,
63919 + const struct acl_subject_label *subj, char **path, const int checkglob)
63920 +{
63921 + struct acl_subject_label *tmpsubj;
63922 + struct acl_object_label *retval;
63923 + struct acl_object_label *retval2;
63924 +
63925 + tmpsubj = (struct acl_subject_label *) subj;
63926 + read_lock(&gr_inode_lock);
63927 + do {
63928 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
63929 + if (retval) {
63930 + if (checkglob && retval->globbed) {
63931 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
63932 + if (retval2)
63933 + retval = retval2;
63934 + }
63935 + break;
63936 + }
63937 + } while ((tmpsubj = tmpsubj->parent_subject));
63938 + read_unlock(&gr_inode_lock);
63939 +
63940 + return retval;
63941 +}
63942 +
63943 +static __inline__ struct acl_object_label *
63944 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63945 + struct dentry *curr_dentry,
63946 + const struct acl_subject_label *subj, char **path, const int checkglob)
63947 +{
63948 + int newglob = checkglob;
63949 + ino_t inode;
63950 + dev_t device;
63951 +
63952 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
63953 + as we don't want a / * rule to match instead of the / object
63954 + don't do this for create lookups that call this function though, since they're looking up
63955 + on the parent and thus need globbing checks on all paths
63956 + */
63957 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
63958 + newglob = GR_NO_GLOB;
63959 +
63960 + spin_lock(&curr_dentry->d_lock);
63961 + inode = curr_dentry->d_inode->i_ino;
63962 + device = __get_dev(curr_dentry);
63963 + spin_unlock(&curr_dentry->d_lock);
63964 +
63965 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
63966 +}
63967 +
63968 +#ifdef CONFIG_HUGETLBFS
63969 +static inline bool
63970 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
63971 +{
63972 + int i;
63973 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
63974 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
63975 + return true;
63976 + }
63977 +
63978 + return false;
63979 +}
63980 +#endif
63981 +
63982 +static struct acl_object_label *
63983 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63984 + const struct acl_subject_label *subj, char *path, const int checkglob)
63985 +{
63986 + struct dentry *dentry = (struct dentry *) l_dentry;
63987 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63988 + struct mount *real_mnt = real_mount(mnt);
63989 + struct acl_object_label *retval;
63990 + struct dentry *parent;
63991 +
63992 + br_read_lock(&vfsmount_lock);
63993 + write_seqlock(&rename_lock);
63994 +
63995 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
63996 +#ifdef CONFIG_NET
63997 + mnt == sock_mnt ||
63998 +#endif
63999 +#ifdef CONFIG_HUGETLBFS
64000 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64001 +#endif
64002 + /* ignore Eric Biederman */
64003 + IS_PRIVATE(l_dentry->d_inode))) {
64004 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64005 + goto out;
64006 + }
64007 +
64008 + for (;;) {
64009 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64010 + break;
64011 +
64012 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64013 + if (!mnt_has_parent(real_mnt))
64014 + break;
64015 +
64016 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64017 + if (retval != NULL)
64018 + goto out;
64019 +
64020 + dentry = real_mnt->mnt_mountpoint;
64021 + real_mnt = real_mnt->mnt_parent;
64022 + mnt = &real_mnt->mnt;
64023 + continue;
64024 + }
64025 +
64026 + parent = dentry->d_parent;
64027 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64028 + if (retval != NULL)
64029 + goto out;
64030 +
64031 + dentry = parent;
64032 + }
64033 +
64034 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64035 +
64036 + /* real_root is pinned so we don't have to hold a reference */
64037 + if (retval == NULL)
64038 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
64039 +out:
64040 + write_sequnlock(&rename_lock);
64041 + br_read_unlock(&vfsmount_lock);
64042 +
64043 + BUG_ON(retval == NULL);
64044 +
64045 + return retval;
64046 +}
64047 +
64048 +static __inline__ struct acl_object_label *
64049 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64050 + const struct acl_subject_label *subj)
64051 +{
64052 + char *path = NULL;
64053 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64054 +}
64055 +
64056 +static __inline__ struct acl_object_label *
64057 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64058 + const struct acl_subject_label *subj)
64059 +{
64060 + char *path = NULL;
64061 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64062 +}
64063 +
64064 +static __inline__ struct acl_object_label *
64065 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64066 + const struct acl_subject_label *subj, char *path)
64067 +{
64068 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64069 +}
64070 +
64071 +static struct acl_subject_label *
64072 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64073 + const struct acl_role_label *role)
64074 +{
64075 + struct dentry *dentry = (struct dentry *) l_dentry;
64076 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64077 + struct mount *real_mnt = real_mount(mnt);
64078 + struct acl_subject_label *retval;
64079 + struct dentry *parent;
64080 +
64081 + br_read_lock(&vfsmount_lock);
64082 + write_seqlock(&rename_lock);
64083 +
64084 + for (;;) {
64085 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64086 + break;
64087 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64088 + if (!mnt_has_parent(real_mnt))
64089 + break;
64090 +
64091 + spin_lock(&dentry->d_lock);
64092 + read_lock(&gr_inode_lock);
64093 + retval =
64094 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64095 + __get_dev(dentry), role);
64096 + read_unlock(&gr_inode_lock);
64097 + spin_unlock(&dentry->d_lock);
64098 + if (retval != NULL)
64099 + goto out;
64100 +
64101 + dentry = real_mnt->mnt_mountpoint;
64102 + real_mnt = real_mnt->mnt_parent;
64103 + mnt = &real_mnt->mnt;
64104 + continue;
64105 + }
64106 +
64107 + spin_lock(&dentry->d_lock);
64108 + read_lock(&gr_inode_lock);
64109 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64110 + __get_dev(dentry), role);
64111 + read_unlock(&gr_inode_lock);
64112 + parent = dentry->d_parent;
64113 + spin_unlock(&dentry->d_lock);
64114 +
64115 + if (retval != NULL)
64116 + goto out;
64117 +
64118 + dentry = parent;
64119 + }
64120 +
64121 + spin_lock(&dentry->d_lock);
64122 + read_lock(&gr_inode_lock);
64123 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64124 + __get_dev(dentry), role);
64125 + read_unlock(&gr_inode_lock);
64126 + spin_unlock(&dentry->d_lock);
64127 +
64128 + if (unlikely(retval == NULL)) {
64129 + /* real_root is pinned, we don't need to hold a reference */
64130 + read_lock(&gr_inode_lock);
64131 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
64132 + __get_dev(real_root.dentry), role);
64133 + read_unlock(&gr_inode_lock);
64134 + }
64135 +out:
64136 + write_sequnlock(&rename_lock);
64137 + br_read_unlock(&vfsmount_lock);
64138 +
64139 + BUG_ON(retval == NULL);
64140 +
64141 + return retval;
64142 +}
64143 +
64144 +static void
64145 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64146 +{
64147 + struct task_struct *task = current;
64148 + const struct cred *cred = current_cred();
64149 +
64150 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64151 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64152 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64153 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64154 +
64155 + return;
64156 +}
64157 +
64158 +static void
64159 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64160 +{
64161 + struct task_struct *task = current;
64162 + const struct cred *cred = current_cred();
64163 +
64164 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64165 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64166 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64167 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64168 +
64169 + return;
64170 +}
64171 +
64172 +static void
64173 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64174 +{
64175 + struct task_struct *task = current;
64176 + const struct cred *cred = current_cred();
64177 +
64178 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64179 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64180 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64181 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64182 +
64183 + return;
64184 +}
64185 +
64186 +__u32
64187 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64188 + const struct vfsmount * mnt)
64189 +{
64190 + __u32 retval = mode;
64191 + struct acl_subject_label *curracl;
64192 + struct acl_object_label *currobj;
64193 +
64194 + if (unlikely(!(gr_status & GR_READY)))
64195 + return (mode & ~GR_AUDITS);
64196 +
64197 + curracl = current->acl;
64198 +
64199 + currobj = chk_obj_label(dentry, mnt, curracl);
64200 + retval = currobj->mode & mode;
64201 +
64202 + /* if we're opening a specified transfer file for writing
64203 + (e.g. /dev/initctl), then transfer our role to init
64204 + */
64205 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64206 + current->role->roletype & GR_ROLE_PERSIST)) {
64207 + struct task_struct *task = init_pid_ns.child_reaper;
64208 +
64209 + if (task->role != current->role) {
64210 + task->acl_sp_role = 0;
64211 + task->acl_role_id = current->acl_role_id;
64212 + task->role = current->role;
64213 + rcu_read_lock();
64214 + read_lock(&grsec_exec_file_lock);
64215 + gr_apply_subject_to_task(task);
64216 + read_unlock(&grsec_exec_file_lock);
64217 + rcu_read_unlock();
64218 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64219 + }
64220 + }
64221 +
64222 + if (unlikely
64223 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64224 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64225 + __u32 new_mode = mode;
64226 +
64227 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64228 +
64229 + retval = new_mode;
64230 +
64231 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64232 + new_mode |= GR_INHERIT;
64233 +
64234 + if (!(mode & GR_NOLEARN))
64235 + gr_log_learn(dentry, mnt, new_mode);
64236 + }
64237 +
64238 + return retval;
64239 +}
64240 +
64241 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64242 + const struct dentry *parent,
64243 + const struct vfsmount *mnt)
64244 +{
64245 + struct name_entry *match;
64246 + struct acl_object_label *matchpo;
64247 + struct acl_subject_label *curracl;
64248 + char *path;
64249 +
64250 + if (unlikely(!(gr_status & GR_READY)))
64251 + return NULL;
64252 +
64253 + preempt_disable();
64254 + path = gr_to_filename_rbac(new_dentry, mnt);
64255 + match = lookup_name_entry_create(path);
64256 +
64257 + curracl = current->acl;
64258 +
64259 + if (match) {
64260 + read_lock(&gr_inode_lock);
64261 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64262 + read_unlock(&gr_inode_lock);
64263 +
64264 + if (matchpo) {
64265 + preempt_enable();
64266 + return matchpo;
64267 + }
64268 + }
64269 +
64270 + // lookup parent
64271 +
64272 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64273 +
64274 + preempt_enable();
64275 + return matchpo;
64276 +}
64277 +
64278 +__u32
64279 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64280 + const struct vfsmount * mnt, const __u32 mode)
64281 +{
64282 + struct acl_object_label *matchpo;
64283 + __u32 retval;
64284 +
64285 + if (unlikely(!(gr_status & GR_READY)))
64286 + return (mode & ~GR_AUDITS);
64287 +
64288 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64289 +
64290 + retval = matchpo->mode & mode;
64291 +
64292 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64293 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64294 + __u32 new_mode = mode;
64295 +
64296 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64297 +
64298 + gr_log_learn(new_dentry, mnt, new_mode);
64299 + return new_mode;
64300 + }
64301 +
64302 + return retval;
64303 +}
64304 +
64305 +__u32
64306 +gr_check_link(const struct dentry * new_dentry,
64307 + const struct dentry * parent_dentry,
64308 + const struct vfsmount * parent_mnt,
64309 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64310 +{
64311 + struct acl_object_label *obj;
64312 + __u32 oldmode, newmode;
64313 + __u32 needmode;
64314 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64315 + GR_DELETE | GR_INHERIT;
64316 +
64317 + if (unlikely(!(gr_status & GR_READY)))
64318 + return (GR_CREATE | GR_LINK);
64319 +
64320 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64321 + oldmode = obj->mode;
64322 +
64323 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64324 + newmode = obj->mode;
64325 +
64326 + needmode = newmode & checkmodes;
64327 +
64328 + // old name for hardlink must have at least the permissions of the new name
64329 + if ((oldmode & needmode) != needmode)
64330 + goto bad;
64331 +
64332 + // if old name had restrictions/auditing, make sure the new name does as well
64333 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64334 +
64335 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64336 + if (is_privileged_binary(old_dentry))
64337 + needmode |= GR_SETID;
64338 +
64339 + if ((newmode & needmode) != needmode)
64340 + goto bad;
64341 +
64342 + // enforce minimum permissions
64343 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64344 + return newmode;
64345 +bad:
64346 + needmode = oldmode;
64347 + if (is_privileged_binary(old_dentry))
64348 + needmode |= GR_SETID;
64349 +
64350 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64351 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64352 + return (GR_CREATE | GR_LINK);
64353 + } else if (newmode & GR_SUPPRESS)
64354 + return GR_SUPPRESS;
64355 + else
64356 + return 0;
64357 +}
64358 +
64359 +int
64360 +gr_check_hidden_task(const struct task_struct *task)
64361 +{
64362 + if (unlikely(!(gr_status & GR_READY)))
64363 + return 0;
64364 +
64365 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64366 + return 1;
64367 +
64368 + return 0;
64369 +}
64370 +
64371 +int
64372 +gr_check_protected_task(const struct task_struct *task)
64373 +{
64374 + if (unlikely(!(gr_status & GR_READY) || !task))
64375 + return 0;
64376 +
64377 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64378 + task->acl != current->acl)
64379 + return 1;
64380 +
64381 + return 0;
64382 +}
64383 +
64384 +int
64385 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64386 +{
64387 + struct task_struct *p;
64388 + int ret = 0;
64389 +
64390 + if (unlikely(!(gr_status & GR_READY) || !pid))
64391 + return ret;
64392 +
64393 + read_lock(&tasklist_lock);
64394 + do_each_pid_task(pid, type, p) {
64395 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64396 + p->acl != current->acl) {
64397 + ret = 1;
64398 + goto out;
64399 + }
64400 + } while_each_pid_task(pid, type, p);
64401 +out:
64402 + read_unlock(&tasklist_lock);
64403 +
64404 + return ret;
64405 +}
64406 +
64407 +void
64408 +gr_copy_label(struct task_struct *tsk)
64409 +{
64410 + tsk->signal->used_accept = 0;
64411 + tsk->acl_sp_role = 0;
64412 + tsk->acl_role_id = current->acl_role_id;
64413 + tsk->acl = current->acl;
64414 + tsk->role = current->role;
64415 + tsk->signal->curr_ip = current->signal->curr_ip;
64416 + tsk->signal->saved_ip = current->signal->saved_ip;
64417 + if (current->exec_file)
64418 + get_file(current->exec_file);
64419 + tsk->exec_file = current->exec_file;
64420 + tsk->is_writable = current->is_writable;
64421 + if (unlikely(current->signal->used_accept)) {
64422 + current->signal->curr_ip = 0;
64423 + current->signal->saved_ip = 0;
64424 + }
64425 +
64426 + return;
64427 +}
64428 +
64429 +static void
64430 +gr_set_proc_res(struct task_struct *task)
64431 +{
64432 + struct acl_subject_label *proc;
64433 + unsigned short i;
64434 +
64435 + proc = task->acl;
64436 +
64437 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64438 + return;
64439 +
64440 + for (i = 0; i < RLIM_NLIMITS; i++) {
64441 + if (!(proc->resmask & (1U << i)))
64442 + continue;
64443 +
64444 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64445 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64446 +
64447 + if (i == RLIMIT_CPU)
64448 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64449 + }
64450 +
64451 + return;
64452 +}
64453 +
64454 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64455 +
64456 +int
64457 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64458 +{
64459 + unsigned int i;
64460 + __u16 num;
64461 + uid_t *uidlist;
64462 + uid_t curuid;
64463 + int realok = 0;
64464 + int effectiveok = 0;
64465 + int fsok = 0;
64466 + uid_t globalreal, globaleffective, globalfs;
64467 +
64468 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64469 + struct user_struct *user;
64470 +
64471 + if (!uid_valid(real))
64472 + goto skipit;
64473 +
64474 + /* find user based on global namespace */
64475 +
64476 + globalreal = GR_GLOBAL_UID(real);
64477 +
64478 + user = find_user(make_kuid(&init_user_ns, globalreal));
64479 + if (user == NULL)
64480 + goto skipit;
64481 +
64482 + if (gr_process_kernel_setuid_ban(user)) {
64483 + /* for find_user */
64484 + free_uid(user);
64485 + return 1;
64486 + }
64487 +
64488 + /* for find_user */
64489 + free_uid(user);
64490 +
64491 +skipit:
64492 +#endif
64493 +
64494 + if (unlikely(!(gr_status & GR_READY)))
64495 + return 0;
64496 +
64497 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64498 + gr_log_learn_uid_change(real, effective, fs);
64499 +
64500 + num = current->acl->user_trans_num;
64501 + uidlist = current->acl->user_transitions;
64502 +
64503 + if (uidlist == NULL)
64504 + return 0;
64505 +
64506 + if (!uid_valid(real)) {
64507 + realok = 1;
64508 + globalreal = (uid_t)-1;
64509 + } else {
64510 + globalreal = GR_GLOBAL_UID(real);
64511 + }
64512 + if (!uid_valid(effective)) {
64513 + effectiveok = 1;
64514 + globaleffective = (uid_t)-1;
64515 + } else {
64516 + globaleffective = GR_GLOBAL_UID(effective);
64517 + }
64518 + if (!uid_valid(fs)) {
64519 + fsok = 1;
64520 + globalfs = (uid_t)-1;
64521 + } else {
64522 + globalfs = GR_GLOBAL_UID(fs);
64523 + }
64524 +
64525 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64526 + for (i = 0; i < num; i++) {
64527 + curuid = uidlist[i];
64528 + if (globalreal == curuid)
64529 + realok = 1;
64530 + if (globaleffective == curuid)
64531 + effectiveok = 1;
64532 + if (globalfs == curuid)
64533 + fsok = 1;
64534 + }
64535 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64536 + for (i = 0; i < num; i++) {
64537 + curuid = uidlist[i];
64538 + if (globalreal == curuid)
64539 + break;
64540 + if (globaleffective == curuid)
64541 + break;
64542 + if (globalfs == curuid)
64543 + break;
64544 + }
64545 + /* not in deny list */
64546 + if (i == num) {
64547 + realok = 1;
64548 + effectiveok = 1;
64549 + fsok = 1;
64550 + }
64551 + }
64552 +
64553 + if (realok && effectiveok && fsok)
64554 + return 0;
64555 + else {
64556 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64557 + return 1;
64558 + }
64559 +}
64560 +
64561 +int
64562 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64563 +{
64564 + unsigned int i;
64565 + __u16 num;
64566 + gid_t *gidlist;
64567 + gid_t curgid;
64568 + int realok = 0;
64569 + int effectiveok = 0;
64570 + int fsok = 0;
64571 + gid_t globalreal, globaleffective, globalfs;
64572 +
64573 + if (unlikely(!(gr_status & GR_READY)))
64574 + return 0;
64575 +
64576 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64577 + gr_log_learn_gid_change(real, effective, fs);
64578 +
64579 + num = current->acl->group_trans_num;
64580 + gidlist = current->acl->group_transitions;
64581 +
64582 + if (gidlist == NULL)
64583 + return 0;
64584 +
64585 + if (!gid_valid(real)) {
64586 + realok = 1;
64587 + globalreal = (gid_t)-1;
64588 + } else {
64589 + globalreal = GR_GLOBAL_GID(real);
64590 + }
64591 + if (!gid_valid(effective)) {
64592 + effectiveok = 1;
64593 + globaleffective = (gid_t)-1;
64594 + } else {
64595 + globaleffective = GR_GLOBAL_GID(effective);
64596 + }
64597 + if (!gid_valid(fs)) {
64598 + fsok = 1;
64599 + globalfs = (gid_t)-1;
64600 + } else {
64601 + globalfs = GR_GLOBAL_GID(fs);
64602 + }
64603 +
64604 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64605 + for (i = 0; i < num; i++) {
64606 + curgid = gidlist[i];
64607 + if (globalreal == curgid)
64608 + realok = 1;
64609 + if (globaleffective == curgid)
64610 + effectiveok = 1;
64611 + if (globalfs == curgid)
64612 + fsok = 1;
64613 + }
64614 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64615 + for (i = 0; i < num; i++) {
64616 + curgid = gidlist[i];
64617 + if (globalreal == curgid)
64618 + break;
64619 + if (globaleffective == curgid)
64620 + break;
64621 + if (globalfs == curgid)
64622 + break;
64623 + }
64624 + /* not in deny list */
64625 + if (i == num) {
64626 + realok = 1;
64627 + effectiveok = 1;
64628 + fsok = 1;
64629 + }
64630 + }
64631 +
64632 + if (realok && effectiveok && fsok)
64633 + return 0;
64634 + else {
64635 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64636 + return 1;
64637 + }
64638 +}
64639 +
64640 +extern int gr_acl_is_capable(const int cap);
64641 +
64642 +void
64643 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64644 +{
64645 + struct acl_role_label *role = task->role;
64646 + struct acl_subject_label *subj = NULL;
64647 + struct acl_object_label *obj;
64648 + struct file *filp;
64649 + uid_t uid;
64650 + gid_t gid;
64651 +
64652 + if (unlikely(!(gr_status & GR_READY)))
64653 + return;
64654 +
64655 + uid = GR_GLOBAL_UID(kuid);
64656 + gid = GR_GLOBAL_GID(kgid);
64657 +
64658 + filp = task->exec_file;
64659 +
64660 + /* kernel process, we'll give them the kernel role */
64661 + if (unlikely(!filp)) {
64662 + task->role = kernel_role;
64663 + task->acl = kernel_role->root_label;
64664 + return;
64665 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64666 + role = lookup_acl_role_label(task, uid, gid);
64667 +
64668 + /* don't change the role if we're not a privileged process */
64669 + if (role && task->role != role &&
64670 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64671 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64672 + return;
64673 +
64674 + /* perform subject lookup in possibly new role
64675 + we can use this result below in the case where role == task->role
64676 + */
64677 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64678 +
64679 + /* if we changed uid/gid, but result in the same role
64680 + and are using inheritance, don't lose the inherited subject
64681 + if current subject is other than what normal lookup
64682 + would result in, we arrived via inheritance, don't
64683 + lose subject
64684 + */
64685 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64686 + (subj == task->acl)))
64687 + task->acl = subj;
64688 +
64689 + task->role = role;
64690 +
64691 + task->is_writable = 0;
64692 +
64693 + /* ignore additional mmap checks for processes that are writable
64694 + by the default ACL */
64695 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64696 + if (unlikely(obj->mode & GR_WRITE))
64697 + task->is_writable = 1;
64698 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64699 + if (unlikely(obj->mode & GR_WRITE))
64700 + task->is_writable = 1;
64701 +
64702 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64703 + 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);
64704 +#endif
64705 +
64706 + gr_set_proc_res(task);
64707 +
64708 + return;
64709 +}
64710 +
64711 +int
64712 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64713 + const int unsafe_flags)
64714 +{
64715 + struct task_struct *task = current;
64716 + struct acl_subject_label *newacl;
64717 + struct acl_object_label *obj;
64718 + __u32 retmode;
64719 +
64720 + if (unlikely(!(gr_status & GR_READY)))
64721 + return 0;
64722 +
64723 + newacl = chk_subj_label(dentry, mnt, task->role);
64724 +
64725 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64726 + did an exec
64727 + */
64728 + rcu_read_lock();
64729 + read_lock(&tasklist_lock);
64730 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64731 + (task->parent->acl->mode & GR_POVERRIDE))) {
64732 + read_unlock(&tasklist_lock);
64733 + rcu_read_unlock();
64734 + goto skip_check;
64735 + }
64736 + read_unlock(&tasklist_lock);
64737 + rcu_read_unlock();
64738 +
64739 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64740 + !(task->role->roletype & GR_ROLE_GOD) &&
64741 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64742 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64743 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64744 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64745 + else
64746 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64747 + return -EACCES;
64748 + }
64749 +
64750 +skip_check:
64751 +
64752 + obj = chk_obj_label(dentry, mnt, task->acl);
64753 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64754 +
64755 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64756 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64757 + if (obj->nested)
64758 + task->acl = obj->nested;
64759 + else
64760 + task->acl = newacl;
64761 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64762 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64763 +
64764 + task->is_writable = 0;
64765 +
64766 + /* ignore additional mmap checks for processes that are writable
64767 + by the default ACL */
64768 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
64769 + if (unlikely(obj->mode & GR_WRITE))
64770 + task->is_writable = 1;
64771 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64772 + if (unlikely(obj->mode & GR_WRITE))
64773 + task->is_writable = 1;
64774 +
64775 + gr_set_proc_res(task);
64776 +
64777 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64778 + 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);
64779 +#endif
64780 + return 0;
64781 +}
64782 +
64783 +/* always called with valid inodev ptr */
64784 +static void
64785 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64786 +{
64787 + struct acl_object_label *matchpo;
64788 + struct acl_subject_label *matchps;
64789 + struct acl_subject_label *subj;
64790 + struct acl_role_label *role;
64791 + unsigned int x;
64792 +
64793 + FOR_EACH_ROLE_START(role)
64794 + FOR_EACH_SUBJECT_START(role, subj, x)
64795 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64796 + matchpo->mode |= GR_DELETED;
64797 + FOR_EACH_SUBJECT_END(subj,x)
64798 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64799 + /* nested subjects aren't in the role's subj_hash table */
64800 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64801 + matchpo->mode |= GR_DELETED;
64802 + FOR_EACH_NESTED_SUBJECT_END(subj)
64803 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64804 + matchps->mode |= GR_DELETED;
64805 + FOR_EACH_ROLE_END(role)
64806 +
64807 + inodev->nentry->deleted = 1;
64808 +
64809 + return;
64810 +}
64811 +
64812 +void
64813 +gr_handle_delete(const ino_t ino, const dev_t dev)
64814 +{
64815 + struct inodev_entry *inodev;
64816 +
64817 + if (unlikely(!(gr_status & GR_READY)))
64818 + return;
64819 +
64820 + write_lock(&gr_inode_lock);
64821 + inodev = lookup_inodev_entry(ino, dev);
64822 + if (inodev != NULL)
64823 + do_handle_delete(inodev, ino, dev);
64824 + write_unlock(&gr_inode_lock);
64825 +
64826 + return;
64827 +}
64828 +
64829 +static void
64830 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64831 + const ino_t newinode, const dev_t newdevice,
64832 + struct acl_subject_label *subj)
64833 +{
64834 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64835 + struct acl_object_label *match;
64836 +
64837 + match = subj->obj_hash[index];
64838 +
64839 + while (match && (match->inode != oldinode ||
64840 + match->device != olddevice ||
64841 + !(match->mode & GR_DELETED)))
64842 + match = match->next;
64843 +
64844 + if (match && (match->inode == oldinode)
64845 + && (match->device == olddevice)
64846 + && (match->mode & GR_DELETED)) {
64847 + if (match->prev == NULL) {
64848 + subj->obj_hash[index] = match->next;
64849 + if (match->next != NULL)
64850 + match->next->prev = NULL;
64851 + } else {
64852 + match->prev->next = match->next;
64853 + if (match->next != NULL)
64854 + match->next->prev = match->prev;
64855 + }
64856 + match->prev = NULL;
64857 + match->next = NULL;
64858 + match->inode = newinode;
64859 + match->device = newdevice;
64860 + match->mode &= ~GR_DELETED;
64861 +
64862 + insert_acl_obj_label(match, subj);
64863 + }
64864 +
64865 + return;
64866 +}
64867 +
64868 +static void
64869 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
64870 + const ino_t newinode, const dev_t newdevice,
64871 + struct acl_role_label *role)
64872 +{
64873 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
64874 + struct acl_subject_label *match;
64875 +
64876 + match = role->subj_hash[index];
64877 +
64878 + while (match && (match->inode != oldinode ||
64879 + match->device != olddevice ||
64880 + !(match->mode & GR_DELETED)))
64881 + match = match->next;
64882 +
64883 + if (match && (match->inode == oldinode)
64884 + && (match->device == olddevice)
64885 + && (match->mode & GR_DELETED)) {
64886 + if (match->prev == NULL) {
64887 + role->subj_hash[index] = match->next;
64888 + if (match->next != NULL)
64889 + match->next->prev = NULL;
64890 + } else {
64891 + match->prev->next = match->next;
64892 + if (match->next != NULL)
64893 + match->next->prev = match->prev;
64894 + }
64895 + match->prev = NULL;
64896 + match->next = NULL;
64897 + match->inode = newinode;
64898 + match->device = newdevice;
64899 + match->mode &= ~GR_DELETED;
64900 +
64901 + insert_acl_subj_label(match, role);
64902 + }
64903 +
64904 + return;
64905 +}
64906 +
64907 +static void
64908 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
64909 + const ino_t newinode, const dev_t newdevice)
64910 +{
64911 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
64912 + struct inodev_entry *match;
64913 +
64914 + match = inodev_set.i_hash[index];
64915 +
64916 + while (match && (match->nentry->inode != oldinode ||
64917 + match->nentry->device != olddevice || !match->nentry->deleted))
64918 + match = match->next;
64919 +
64920 + if (match && (match->nentry->inode == oldinode)
64921 + && (match->nentry->device == olddevice) &&
64922 + match->nentry->deleted) {
64923 + if (match->prev == NULL) {
64924 + inodev_set.i_hash[index] = match->next;
64925 + if (match->next != NULL)
64926 + match->next->prev = NULL;
64927 + } else {
64928 + match->prev->next = match->next;
64929 + if (match->next != NULL)
64930 + match->next->prev = match->prev;
64931 + }
64932 + match->prev = NULL;
64933 + match->next = NULL;
64934 + match->nentry->inode = newinode;
64935 + match->nentry->device = newdevice;
64936 + match->nentry->deleted = 0;
64937 +
64938 + insert_inodev_entry(match);
64939 + }
64940 +
64941 + return;
64942 +}
64943 +
64944 +static void
64945 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
64946 +{
64947 + struct acl_subject_label *subj;
64948 + struct acl_role_label *role;
64949 + unsigned int x;
64950 +
64951 + FOR_EACH_ROLE_START(role)
64952 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
64953 +
64954 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64955 + if ((subj->inode == ino) && (subj->device == dev)) {
64956 + subj->inode = ino;
64957 + subj->device = dev;
64958 + }
64959 + /* nested subjects aren't in the role's subj_hash table */
64960 + update_acl_obj_label(matchn->inode, matchn->device,
64961 + ino, dev, subj);
64962 + FOR_EACH_NESTED_SUBJECT_END(subj)
64963 + FOR_EACH_SUBJECT_START(role, subj, x)
64964 + update_acl_obj_label(matchn->inode, matchn->device,
64965 + ino, dev, subj);
64966 + FOR_EACH_SUBJECT_END(subj,x)
64967 + FOR_EACH_ROLE_END(role)
64968 +
64969 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
64970 +
64971 + return;
64972 +}
64973 +
64974 +static void
64975 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
64976 + const struct vfsmount *mnt)
64977 +{
64978 + ino_t ino = dentry->d_inode->i_ino;
64979 + dev_t dev = __get_dev(dentry);
64980 +
64981 + __do_handle_create(matchn, ino, dev);
64982 +
64983 + return;
64984 +}
64985 +
64986 +void
64987 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64988 +{
64989 + struct name_entry *matchn;
64990 +
64991 + if (unlikely(!(gr_status & GR_READY)))
64992 + return;
64993 +
64994 + preempt_disable();
64995 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
64996 +
64997 + if (unlikely((unsigned long)matchn)) {
64998 + write_lock(&gr_inode_lock);
64999 + do_handle_create(matchn, dentry, mnt);
65000 + write_unlock(&gr_inode_lock);
65001 + }
65002 + preempt_enable();
65003 +
65004 + return;
65005 +}
65006 +
65007 +void
65008 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65009 +{
65010 + struct name_entry *matchn;
65011 +
65012 + if (unlikely(!(gr_status & GR_READY)))
65013 + return;
65014 +
65015 + preempt_disable();
65016 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65017 +
65018 + if (unlikely((unsigned long)matchn)) {
65019 + write_lock(&gr_inode_lock);
65020 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65021 + write_unlock(&gr_inode_lock);
65022 + }
65023 + preempt_enable();
65024 +
65025 + return;
65026 +}
65027 +
65028 +void
65029 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65030 + struct dentry *old_dentry,
65031 + struct dentry *new_dentry,
65032 + struct vfsmount *mnt, const __u8 replace)
65033 +{
65034 + struct name_entry *matchn;
65035 + struct inodev_entry *inodev;
65036 + struct inode *inode = new_dentry->d_inode;
65037 + ino_t old_ino = old_dentry->d_inode->i_ino;
65038 + dev_t old_dev = __get_dev(old_dentry);
65039 +
65040 + /* vfs_rename swaps the name and parent link for old_dentry and
65041 + new_dentry
65042 + at this point, old_dentry has the new name, parent link, and inode
65043 + for the renamed file
65044 + if a file is being replaced by a rename, new_dentry has the inode
65045 + and name for the replaced file
65046 + */
65047 +
65048 + if (unlikely(!(gr_status & GR_READY)))
65049 + return;
65050 +
65051 + preempt_disable();
65052 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65053 +
65054 + /* we wouldn't have to check d_inode if it weren't for
65055 + NFS silly-renaming
65056 + */
65057 +
65058 + write_lock(&gr_inode_lock);
65059 + if (unlikely(replace && inode)) {
65060 + ino_t new_ino = inode->i_ino;
65061 + dev_t new_dev = __get_dev(new_dentry);
65062 +
65063 + inodev = lookup_inodev_entry(new_ino, new_dev);
65064 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65065 + do_handle_delete(inodev, new_ino, new_dev);
65066 + }
65067 +
65068 + inodev = lookup_inodev_entry(old_ino, old_dev);
65069 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65070 + do_handle_delete(inodev, old_ino, old_dev);
65071 +
65072 + if (unlikely((unsigned long)matchn))
65073 + do_handle_create(matchn, old_dentry, mnt);
65074 +
65075 + write_unlock(&gr_inode_lock);
65076 + preempt_enable();
65077 +
65078 + return;
65079 +}
65080 +
65081 +static int
65082 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
65083 + unsigned char **sum)
65084 +{
65085 + struct acl_role_label *r;
65086 + struct role_allowed_ip *ipp;
65087 + struct role_transition *trans;
65088 + unsigned int i;
65089 + int found = 0;
65090 + u32 curr_ip = current->signal->curr_ip;
65091 +
65092 + current->signal->saved_ip = curr_ip;
65093 +
65094 + /* check transition table */
65095 +
65096 + for (trans = current->role->transitions; trans; trans = trans->next) {
65097 + if (!strcmp(rolename, trans->rolename)) {
65098 + found = 1;
65099 + break;
65100 + }
65101 + }
65102 +
65103 + if (!found)
65104 + return 0;
65105 +
65106 + /* handle special roles that do not require authentication
65107 + and check ip */
65108 +
65109 + FOR_EACH_ROLE_START(r)
65110 + if (!strcmp(rolename, r->rolename) &&
65111 + (r->roletype & GR_ROLE_SPECIAL)) {
65112 + found = 0;
65113 + if (r->allowed_ips != NULL) {
65114 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
65115 + if ((ntohl(curr_ip) & ipp->netmask) ==
65116 + (ntohl(ipp->addr) & ipp->netmask))
65117 + found = 1;
65118 + }
65119 + } else
65120 + found = 2;
65121 + if (!found)
65122 + return 0;
65123 +
65124 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
65125 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
65126 + *salt = NULL;
65127 + *sum = NULL;
65128 + return 1;
65129 + }
65130 + }
65131 + FOR_EACH_ROLE_END(r)
65132 +
65133 + for (i = 0; i < num_sprole_pws; i++) {
65134 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
65135 + *salt = acl_special_roles[i]->salt;
65136 + *sum = acl_special_roles[i]->sum;
65137 + return 1;
65138 + }
65139 + }
65140 +
65141 + return 0;
65142 +}
65143 +
65144 +static void
65145 +assign_special_role(char *rolename)
65146 +{
65147 + struct acl_object_label *obj;
65148 + struct acl_role_label *r;
65149 + struct acl_role_label *assigned = NULL;
65150 + struct task_struct *tsk;
65151 + struct file *filp;
65152 +
65153 + FOR_EACH_ROLE_START(r)
65154 + if (!strcmp(rolename, r->rolename) &&
65155 + (r->roletype & GR_ROLE_SPECIAL)) {
65156 + assigned = r;
65157 + break;
65158 + }
65159 + FOR_EACH_ROLE_END(r)
65160 +
65161 + if (!assigned)
65162 + return;
65163 +
65164 + read_lock(&tasklist_lock);
65165 + read_lock(&grsec_exec_file_lock);
65166 +
65167 + tsk = current->real_parent;
65168 + if (tsk == NULL)
65169 + goto out_unlock;
65170 +
65171 + filp = tsk->exec_file;
65172 + if (filp == NULL)
65173 + goto out_unlock;
65174 +
65175 + tsk->is_writable = 0;
65176 +
65177 + tsk->acl_sp_role = 1;
65178 + tsk->acl_role_id = ++acl_sp_role_value;
65179 + tsk->role = assigned;
65180 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65181 +
65182 + /* ignore additional mmap checks for processes that are writable
65183 + by the default ACL */
65184 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65185 + if (unlikely(obj->mode & GR_WRITE))
65186 + tsk->is_writable = 1;
65187 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65188 + if (unlikely(obj->mode & GR_WRITE))
65189 + tsk->is_writable = 1;
65190 +
65191 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65192 + 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));
65193 +#endif
65194 +
65195 +out_unlock:
65196 + read_unlock(&grsec_exec_file_lock);
65197 + read_unlock(&tasklist_lock);
65198 + return;
65199 +}
65200 +
65201 +int gr_check_secure_terminal(struct task_struct *task)
65202 +{
65203 + struct task_struct *p, *p2, *p3;
65204 + struct files_struct *files;
65205 + struct fdtable *fdt;
65206 + struct file *our_file = NULL, *file;
65207 + int i;
65208 +
65209 + if (task->signal->tty == NULL)
65210 + return 1;
65211 +
65212 + files = get_files_struct(task);
65213 + if (files != NULL) {
65214 + rcu_read_lock();
65215 + fdt = files_fdtable(files);
65216 + for (i=0; i < fdt->max_fds; i++) {
65217 + file = fcheck_files(files, i);
65218 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65219 + get_file(file);
65220 + our_file = file;
65221 + }
65222 + }
65223 + rcu_read_unlock();
65224 + put_files_struct(files);
65225 + }
65226 +
65227 + if (our_file == NULL)
65228 + return 1;
65229 +
65230 + read_lock(&tasklist_lock);
65231 + do_each_thread(p2, p) {
65232 + files = get_files_struct(p);
65233 + if (files == NULL ||
65234 + (p->signal && p->signal->tty == task->signal->tty)) {
65235 + if (files != NULL)
65236 + put_files_struct(files);
65237 + continue;
65238 + }
65239 + rcu_read_lock();
65240 + fdt = files_fdtable(files);
65241 + for (i=0; i < fdt->max_fds; i++) {
65242 + file = fcheck_files(files, i);
65243 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65244 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65245 + p3 = task;
65246 + while (task_pid_nr(p3) > 0) {
65247 + if (p3 == p)
65248 + break;
65249 + p3 = p3->real_parent;
65250 + }
65251 + if (p3 == p)
65252 + break;
65253 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65254 + gr_handle_alertkill(p);
65255 + rcu_read_unlock();
65256 + put_files_struct(files);
65257 + read_unlock(&tasklist_lock);
65258 + fput(our_file);
65259 + return 0;
65260 + }
65261 + }
65262 + rcu_read_unlock();
65263 + put_files_struct(files);
65264 + } while_each_thread(p2, p);
65265 + read_unlock(&tasklist_lock);
65266 +
65267 + fput(our_file);
65268 + return 1;
65269 +}
65270 +
65271 +static int gr_rbac_disable(void *unused)
65272 +{
65273 + pax_open_kernel();
65274 + gr_status &= ~GR_READY;
65275 + pax_close_kernel();
65276 +
65277 + return 0;
65278 +}
65279 +
65280 +ssize_t
65281 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65282 +{
65283 + struct gr_arg_wrapper uwrap;
65284 + unsigned char *sprole_salt = NULL;
65285 + unsigned char *sprole_sum = NULL;
65286 + int error = 0;
65287 + int error2 = 0;
65288 + size_t req_count = 0;
65289 +
65290 + mutex_lock(&gr_dev_mutex);
65291 +
65292 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65293 + error = -EPERM;
65294 + goto out;
65295 + }
65296 +
65297 +#ifdef CONFIG_COMPAT
65298 + pax_open_kernel();
65299 + if (is_compat_task()) {
65300 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65301 + copy_gr_arg = &copy_gr_arg_compat;
65302 + copy_acl_object_label = &copy_acl_object_label_compat;
65303 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65304 + copy_acl_role_label = &copy_acl_role_label_compat;
65305 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65306 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65307 + copy_role_transition = &copy_role_transition_compat;
65308 + copy_sprole_pw = &copy_sprole_pw_compat;
65309 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65310 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65311 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65312 + } else {
65313 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65314 + copy_gr_arg = &copy_gr_arg_normal;
65315 + copy_acl_object_label = &copy_acl_object_label_normal;
65316 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65317 + copy_acl_role_label = &copy_acl_role_label_normal;
65318 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65319 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65320 + copy_role_transition = &copy_role_transition_normal;
65321 + copy_sprole_pw = &copy_sprole_pw_normal;
65322 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65323 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65324 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65325 + }
65326 + pax_close_kernel();
65327 +#endif
65328 +
65329 + req_count = get_gr_arg_wrapper_size();
65330 +
65331 + if (count != req_count) {
65332 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65333 + error = -EINVAL;
65334 + goto out;
65335 + }
65336 +
65337 +
65338 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65339 + gr_auth_expires = 0;
65340 + gr_auth_attempts = 0;
65341 + }
65342 +
65343 + error = copy_gr_arg_wrapper(buf, &uwrap);
65344 + if (error)
65345 + goto out;
65346 +
65347 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65348 + if (error)
65349 + goto out;
65350 +
65351 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65352 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65353 + time_after(gr_auth_expires, get_seconds())) {
65354 + error = -EBUSY;
65355 + goto out;
65356 + }
65357 +
65358 + /* if non-root trying to do anything other than use a special role,
65359 + do not attempt authentication, do not count towards authentication
65360 + locking
65361 + */
65362 +
65363 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65364 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65365 + gr_is_global_nonroot(current_uid())) {
65366 + error = -EPERM;
65367 + goto out;
65368 + }
65369 +
65370 + /* ensure pw and special role name are null terminated */
65371 +
65372 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65373 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65374 +
65375 + /* Okay.
65376 + * We have our enough of the argument structure..(we have yet
65377 + * to copy_from_user the tables themselves) . Copy the tables
65378 + * only if we need them, i.e. for loading operations. */
65379 +
65380 + switch (gr_usermode->mode) {
65381 + case GR_STATUS:
65382 + if (gr_status & GR_READY) {
65383 + error = 1;
65384 + if (!gr_check_secure_terminal(current))
65385 + error = 3;
65386 + } else
65387 + error = 2;
65388 + goto out;
65389 + case GR_SHUTDOWN:
65390 + if ((gr_status & GR_READY)
65391 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65392 + stop_machine(gr_rbac_disable, NULL, NULL);
65393 + free_variables();
65394 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65395 + memset(gr_system_salt, 0, GR_SALT_LEN);
65396 + memset(gr_system_sum, 0, GR_SHA_LEN);
65397 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65398 + } else if (gr_status & GR_READY) {
65399 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65400 + error = -EPERM;
65401 + } else {
65402 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65403 + error = -EAGAIN;
65404 + }
65405 + break;
65406 + case GR_ENABLE:
65407 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65408 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65409 + else {
65410 + if (gr_status & GR_READY)
65411 + error = -EAGAIN;
65412 + else
65413 + error = error2;
65414 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65415 + }
65416 + break;
65417 + case GR_RELOAD:
65418 + if (!(gr_status & GR_READY)) {
65419 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65420 + error = -EAGAIN;
65421 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65422 + stop_machine(gr_rbac_disable, NULL, NULL);
65423 + free_variables();
65424 + error2 = gracl_init(gr_usermode);
65425 + if (!error2)
65426 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65427 + else {
65428 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65429 + error = error2;
65430 + }
65431 + } else {
65432 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65433 + error = -EPERM;
65434 + }
65435 + break;
65436 + case GR_SEGVMOD:
65437 + if (unlikely(!(gr_status & GR_READY))) {
65438 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65439 + error = -EAGAIN;
65440 + break;
65441 + }
65442 +
65443 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65444 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65445 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65446 + struct acl_subject_label *segvacl;
65447 + segvacl =
65448 + lookup_acl_subj_label(gr_usermode->segv_inode,
65449 + gr_usermode->segv_device,
65450 + current->role);
65451 + if (segvacl) {
65452 + segvacl->crashes = 0;
65453 + segvacl->expires = 0;
65454 + }
65455 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65456 + gr_remove_uid(gr_usermode->segv_uid);
65457 + }
65458 + } else {
65459 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65460 + error = -EPERM;
65461 + }
65462 + break;
65463 + case GR_SPROLE:
65464 + case GR_SPROLEPAM:
65465 + if (unlikely(!(gr_status & GR_READY))) {
65466 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65467 + error = -EAGAIN;
65468 + break;
65469 + }
65470 +
65471 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65472 + current->role->expires = 0;
65473 + current->role->auth_attempts = 0;
65474 + }
65475 +
65476 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65477 + time_after(current->role->expires, get_seconds())) {
65478 + error = -EBUSY;
65479 + goto out;
65480 + }
65481 +
65482 + if (lookup_special_role_auth
65483 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65484 + && ((!sprole_salt && !sprole_sum)
65485 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65486 + char *p = "";
65487 + assign_special_role(gr_usermode->sp_role);
65488 + read_lock(&tasklist_lock);
65489 + if (current->real_parent)
65490 + p = current->real_parent->role->rolename;
65491 + read_unlock(&tasklist_lock);
65492 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65493 + p, acl_sp_role_value);
65494 + } else {
65495 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65496 + error = -EPERM;
65497 + if(!(current->role->auth_attempts++))
65498 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65499 +
65500 + goto out;
65501 + }
65502 + break;
65503 + case GR_UNSPROLE:
65504 + if (unlikely(!(gr_status & GR_READY))) {
65505 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65506 + error = -EAGAIN;
65507 + break;
65508 + }
65509 +
65510 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65511 + char *p = "";
65512 + int i = 0;
65513 +
65514 + read_lock(&tasklist_lock);
65515 + if (current->real_parent) {
65516 + p = current->real_parent->role->rolename;
65517 + i = current->real_parent->acl_role_id;
65518 + }
65519 + read_unlock(&tasklist_lock);
65520 +
65521 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65522 + gr_set_acls(1);
65523 + } else {
65524 + error = -EPERM;
65525 + goto out;
65526 + }
65527 + break;
65528 + default:
65529 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65530 + error = -EINVAL;
65531 + break;
65532 + }
65533 +
65534 + if (error != -EPERM)
65535 + goto out;
65536 +
65537 + if(!(gr_auth_attempts++))
65538 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65539 +
65540 + out:
65541 + mutex_unlock(&gr_dev_mutex);
65542 +
65543 + if (!error)
65544 + error = req_count;
65545 +
65546 + return error;
65547 +}
65548 +
65549 +/* must be called with
65550 + rcu_read_lock();
65551 + read_lock(&tasklist_lock);
65552 + read_lock(&grsec_exec_file_lock);
65553 +*/
65554 +int gr_apply_subject_to_task(struct task_struct *task)
65555 +{
65556 + struct acl_object_label *obj;
65557 + char *tmpname;
65558 + struct acl_subject_label *tmpsubj;
65559 + struct file *filp;
65560 + struct name_entry *nmatch;
65561 +
65562 + filp = task->exec_file;
65563 + if (filp == NULL)
65564 + return 0;
65565 +
65566 + /* the following is to apply the correct subject
65567 + on binaries running when the RBAC system
65568 + is enabled, when the binaries have been
65569 + replaced or deleted since their execution
65570 + -----
65571 + when the RBAC system starts, the inode/dev
65572 + from exec_file will be one the RBAC system
65573 + is unaware of. It only knows the inode/dev
65574 + of the present file on disk, or the absence
65575 + of it.
65576 + */
65577 + preempt_disable();
65578 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65579 +
65580 + nmatch = lookup_name_entry(tmpname);
65581 + preempt_enable();
65582 + tmpsubj = NULL;
65583 + if (nmatch) {
65584 + if (nmatch->deleted)
65585 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65586 + else
65587 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65588 + if (tmpsubj != NULL)
65589 + task->acl = tmpsubj;
65590 + }
65591 + if (tmpsubj == NULL)
65592 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65593 + task->role);
65594 + if (task->acl) {
65595 + task->is_writable = 0;
65596 + /* ignore additional mmap checks for processes that are writable
65597 + by the default ACL */
65598 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65599 + if (unlikely(obj->mode & GR_WRITE))
65600 + task->is_writable = 1;
65601 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65602 + if (unlikely(obj->mode & GR_WRITE))
65603 + task->is_writable = 1;
65604 +
65605 + gr_set_proc_res(task);
65606 +
65607 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65608 + 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);
65609 +#endif
65610 + } else {
65611 + return 1;
65612 + }
65613 +
65614 + return 0;
65615 +}
65616 +
65617 +int
65618 +gr_set_acls(const int type)
65619 +{
65620 + struct task_struct *task, *task2;
65621 + struct acl_role_label *role = current->role;
65622 + __u16 acl_role_id = current->acl_role_id;
65623 + const struct cred *cred;
65624 + int ret;
65625 +
65626 + rcu_read_lock();
65627 + read_lock(&tasklist_lock);
65628 + read_lock(&grsec_exec_file_lock);
65629 + do_each_thread(task2, task) {
65630 + /* check to see if we're called from the exit handler,
65631 + if so, only replace ACLs that have inherited the admin
65632 + ACL */
65633 +
65634 + if (type && (task->role != role ||
65635 + task->acl_role_id != acl_role_id))
65636 + continue;
65637 +
65638 + task->acl_role_id = 0;
65639 + task->acl_sp_role = 0;
65640 +
65641 + if (task->exec_file) {
65642 + cred = __task_cred(task);
65643 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65644 + ret = gr_apply_subject_to_task(task);
65645 + if (ret) {
65646 + read_unlock(&grsec_exec_file_lock);
65647 + read_unlock(&tasklist_lock);
65648 + rcu_read_unlock();
65649 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65650 + return ret;
65651 + }
65652 + } else {
65653 + // it's a kernel process
65654 + task->role = kernel_role;
65655 + task->acl = kernel_role->root_label;
65656 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65657 + task->acl->mode &= ~GR_PROCFIND;
65658 +#endif
65659 + }
65660 + } while_each_thread(task2, task);
65661 + read_unlock(&grsec_exec_file_lock);
65662 + read_unlock(&tasklist_lock);
65663 + rcu_read_unlock();
65664 +
65665 + return 0;
65666 +}
65667 +
65668 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65669 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65670 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65671 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65672 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65673 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65674 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65675 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65676 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65677 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65678 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65679 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65680 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65681 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65682 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65683 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65684 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65685 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65686 +};
65687 +
65688 +void
65689 +gr_learn_resource(const struct task_struct *task,
65690 + const int res, const unsigned long wanted, const int gt)
65691 +{
65692 + struct acl_subject_label *acl;
65693 + const struct cred *cred;
65694 +
65695 + if (unlikely((gr_status & GR_READY) &&
65696 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65697 + goto skip_reslog;
65698 +
65699 + gr_log_resource(task, res, wanted, gt);
65700 +skip_reslog:
65701 +
65702 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65703 + return;
65704 +
65705 + acl = task->acl;
65706 +
65707 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65708 + !(acl->resmask & (1U << (unsigned short) res))))
65709 + return;
65710 +
65711 + if (wanted >= acl->res[res].rlim_cur) {
65712 + unsigned long res_add;
65713 +
65714 + res_add = wanted + res_learn_bumps[res];
65715 +
65716 + acl->res[res].rlim_cur = res_add;
65717 +
65718 + if (wanted > acl->res[res].rlim_max)
65719 + acl->res[res].rlim_max = res_add;
65720 +
65721 + /* only log the subject filename, since resource logging is supported for
65722 + single-subject learning only */
65723 + rcu_read_lock();
65724 + cred = __task_cred(task);
65725 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65726 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65727 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65728 + "", (unsigned long) res, &task->signal->saved_ip);
65729 + rcu_read_unlock();
65730 + }
65731 +
65732 + return;
65733 +}
65734 +EXPORT_SYMBOL(gr_learn_resource);
65735 +#endif
65736 +
65737 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65738 +void
65739 +pax_set_initial_flags(struct linux_binprm *bprm)
65740 +{
65741 + struct task_struct *task = current;
65742 + struct acl_subject_label *proc;
65743 + unsigned long flags;
65744 +
65745 + if (unlikely(!(gr_status & GR_READY)))
65746 + return;
65747 +
65748 + flags = pax_get_flags(task);
65749 +
65750 + proc = task->acl;
65751 +
65752 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65753 + flags &= ~MF_PAX_PAGEEXEC;
65754 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65755 + flags &= ~MF_PAX_SEGMEXEC;
65756 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65757 + flags &= ~MF_PAX_RANDMMAP;
65758 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65759 + flags &= ~MF_PAX_EMUTRAMP;
65760 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65761 + flags &= ~MF_PAX_MPROTECT;
65762 +
65763 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65764 + flags |= MF_PAX_PAGEEXEC;
65765 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65766 + flags |= MF_PAX_SEGMEXEC;
65767 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65768 + flags |= MF_PAX_RANDMMAP;
65769 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65770 + flags |= MF_PAX_EMUTRAMP;
65771 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65772 + flags |= MF_PAX_MPROTECT;
65773 +
65774 + pax_set_flags(task, flags);
65775 +
65776 + return;
65777 +}
65778 +#endif
65779 +
65780 +int
65781 +gr_handle_proc_ptrace(struct task_struct *task)
65782 +{
65783 + struct file *filp;
65784 + struct task_struct *tmp = task;
65785 + struct task_struct *curtemp = current;
65786 + __u32 retmode;
65787 +
65788 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65789 + if (unlikely(!(gr_status & GR_READY)))
65790 + return 0;
65791 +#endif
65792 +
65793 + read_lock(&tasklist_lock);
65794 + read_lock(&grsec_exec_file_lock);
65795 + filp = task->exec_file;
65796 +
65797 + while (task_pid_nr(tmp) > 0) {
65798 + if (tmp == curtemp)
65799 + break;
65800 + tmp = tmp->real_parent;
65801 + }
65802 +
65803 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65804 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65805 + read_unlock(&grsec_exec_file_lock);
65806 + read_unlock(&tasklist_lock);
65807 + return 1;
65808 + }
65809 +
65810 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65811 + if (!(gr_status & GR_READY)) {
65812 + read_unlock(&grsec_exec_file_lock);
65813 + read_unlock(&tasklist_lock);
65814 + return 0;
65815 + }
65816 +#endif
65817 +
65818 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65819 + read_unlock(&grsec_exec_file_lock);
65820 + read_unlock(&tasklist_lock);
65821 +
65822 + if (retmode & GR_NOPTRACE)
65823 + return 1;
65824 +
65825 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
65826 + && (current->acl != task->acl || (current->acl != current->role->root_label
65827 + && task_pid_nr(current) != task_pid_nr(task))))
65828 + return 1;
65829 +
65830 + return 0;
65831 +}
65832 +
65833 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
65834 +{
65835 + if (unlikely(!(gr_status & GR_READY)))
65836 + return;
65837 +
65838 + if (!(current->role->roletype & GR_ROLE_GOD))
65839 + return;
65840 +
65841 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65842 + p->role->rolename, gr_task_roletype_to_char(p),
65843 + p->acl->filename);
65844 +}
65845 +
65846 +int
65847 +gr_handle_ptrace(struct task_struct *task, const long request)
65848 +{
65849 + struct task_struct *tmp = task;
65850 + struct task_struct *curtemp = current;
65851 + __u32 retmode;
65852 +
65853 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65854 + if (unlikely(!(gr_status & GR_READY)))
65855 + return 0;
65856 +#endif
65857 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
65858 + read_lock(&tasklist_lock);
65859 + while (task_pid_nr(tmp) > 0) {
65860 + if (tmp == curtemp)
65861 + break;
65862 + tmp = tmp->real_parent;
65863 + }
65864 +
65865 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65866 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
65867 + read_unlock(&tasklist_lock);
65868 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65869 + return 1;
65870 + }
65871 + read_unlock(&tasklist_lock);
65872 + }
65873 +
65874 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65875 + if (!(gr_status & GR_READY))
65876 + return 0;
65877 +#endif
65878 +
65879 + read_lock(&grsec_exec_file_lock);
65880 + if (unlikely(!task->exec_file)) {
65881 + read_unlock(&grsec_exec_file_lock);
65882 + return 0;
65883 + }
65884 +
65885 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
65886 + read_unlock(&grsec_exec_file_lock);
65887 +
65888 + if (retmode & GR_NOPTRACE) {
65889 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65890 + return 1;
65891 + }
65892 +
65893 + if (retmode & GR_PTRACERD) {
65894 + switch (request) {
65895 + case PTRACE_SEIZE:
65896 + case PTRACE_POKETEXT:
65897 + case PTRACE_POKEDATA:
65898 + case PTRACE_POKEUSR:
65899 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
65900 + case PTRACE_SETREGS:
65901 + case PTRACE_SETFPREGS:
65902 +#endif
65903 +#ifdef CONFIG_X86
65904 + case PTRACE_SETFPXREGS:
65905 +#endif
65906 +#ifdef CONFIG_ALTIVEC
65907 + case PTRACE_SETVRREGS:
65908 +#endif
65909 + return 1;
65910 + default:
65911 + return 0;
65912 + }
65913 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
65914 + !(current->role->roletype & GR_ROLE_GOD) &&
65915 + (current->acl != task->acl)) {
65916 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65917 + return 1;
65918 + }
65919 +
65920 + return 0;
65921 +}
65922 +
65923 +static int is_writable_mmap(const struct file *filp)
65924 +{
65925 + struct task_struct *task = current;
65926 + struct acl_object_label *obj, *obj2;
65927 +
65928 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
65929 + !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))) {
65930 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65931 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
65932 + task->role->root_label);
65933 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
65934 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
65935 + return 1;
65936 + }
65937 + }
65938 + return 0;
65939 +}
65940 +
65941 +int
65942 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
65943 +{
65944 + __u32 mode;
65945 +
65946 + if (unlikely(!file || !(prot & PROT_EXEC)))
65947 + return 1;
65948 +
65949 + if (is_writable_mmap(file))
65950 + return 0;
65951 +
65952 + mode =
65953 + gr_search_file(file->f_path.dentry,
65954 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65955 + file->f_path.mnt);
65956 +
65957 + if (!gr_tpe_allow(file))
65958 + return 0;
65959 +
65960 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65961 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65962 + return 0;
65963 + } else if (unlikely(!(mode & GR_EXEC))) {
65964 + return 0;
65965 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65966 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65967 + return 1;
65968 + }
65969 +
65970 + return 1;
65971 +}
65972 +
65973 +int
65974 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65975 +{
65976 + __u32 mode;
65977 +
65978 + if (unlikely(!file || !(prot & PROT_EXEC)))
65979 + return 1;
65980 +
65981 + if (is_writable_mmap(file))
65982 + return 0;
65983 +
65984 + mode =
65985 + gr_search_file(file->f_path.dentry,
65986 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65987 + file->f_path.mnt);
65988 +
65989 + if (!gr_tpe_allow(file))
65990 + return 0;
65991 +
65992 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65993 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65994 + return 0;
65995 + } else if (unlikely(!(mode & GR_EXEC))) {
65996 + return 0;
65997 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65998 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65999 + return 1;
66000 + }
66001 +
66002 + return 1;
66003 +}
66004 +
66005 +void
66006 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66007 +{
66008 + unsigned long runtime;
66009 + unsigned long cputime;
66010 + unsigned int wday, cday;
66011 + __u8 whr, chr;
66012 + __u8 wmin, cmin;
66013 + __u8 wsec, csec;
66014 + struct timespec timeval;
66015 +
66016 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66017 + !(task->acl->mode & GR_PROCACCT)))
66018 + return;
66019 +
66020 + do_posix_clock_monotonic_gettime(&timeval);
66021 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66022 + wday = runtime / (3600 * 24);
66023 + runtime -= wday * (3600 * 24);
66024 + whr = runtime / 3600;
66025 + runtime -= whr * 3600;
66026 + wmin = runtime / 60;
66027 + runtime -= wmin * 60;
66028 + wsec = runtime;
66029 +
66030 + cputime = (task->utime + task->stime) / HZ;
66031 + cday = cputime / (3600 * 24);
66032 + cputime -= cday * (3600 * 24);
66033 + chr = cputime / 3600;
66034 + cputime -= chr * 3600;
66035 + cmin = cputime / 60;
66036 + cputime -= cmin * 60;
66037 + csec = cputime;
66038 +
66039 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66040 +
66041 + return;
66042 +}
66043 +
66044 +void gr_set_kernel_label(struct task_struct *task)
66045 +{
66046 + if (gr_status & GR_READY) {
66047 + task->role = kernel_role;
66048 + task->acl = kernel_role->root_label;
66049 + }
66050 + return;
66051 +}
66052 +
66053 +#ifdef CONFIG_TASKSTATS
66054 +int gr_is_taskstats_denied(int pid)
66055 +{
66056 + struct task_struct *task;
66057 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66058 + const struct cred *cred;
66059 +#endif
66060 + int ret = 0;
66061 +
66062 + /* restrict taskstats viewing to un-chrooted root users
66063 + who have the 'view' subject flag if the RBAC system is enabled
66064 + */
66065 +
66066 + rcu_read_lock();
66067 + read_lock(&tasklist_lock);
66068 + task = find_task_by_vpid(pid);
66069 + if (task) {
66070 +#ifdef CONFIG_GRKERNSEC_CHROOT
66071 + if (proc_is_chrooted(task))
66072 + ret = -EACCES;
66073 +#endif
66074 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66075 + cred = __task_cred(task);
66076 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66077 + if (gr_is_global_nonroot(cred->uid))
66078 + ret = -EACCES;
66079 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66080 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66081 + ret = -EACCES;
66082 +#endif
66083 +#endif
66084 + if (gr_status & GR_READY) {
66085 + if (!(task->acl->mode & GR_VIEW))
66086 + ret = -EACCES;
66087 + }
66088 + } else
66089 + ret = -ENOENT;
66090 +
66091 + read_unlock(&tasklist_lock);
66092 + rcu_read_unlock();
66093 +
66094 + return ret;
66095 +}
66096 +#endif
66097 +
66098 +/* AUXV entries are filled via a descendant of search_binary_handler
66099 + after we've already applied the subject for the target
66100 +*/
66101 +int gr_acl_enable_at_secure(void)
66102 +{
66103 + if (unlikely(!(gr_status & GR_READY)))
66104 + return 0;
66105 +
66106 + if (current->acl->mode & GR_ATSECURE)
66107 + return 1;
66108 +
66109 + return 0;
66110 +}
66111 +
66112 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66113 +{
66114 + struct task_struct *task = current;
66115 + struct dentry *dentry = file->f_path.dentry;
66116 + struct vfsmount *mnt = file->f_path.mnt;
66117 + struct acl_object_label *obj, *tmp;
66118 + struct acl_subject_label *subj;
66119 + unsigned int bufsize;
66120 + int is_not_root;
66121 + char *path;
66122 + dev_t dev = __get_dev(dentry);
66123 +
66124 + if (unlikely(!(gr_status & GR_READY)))
66125 + return 1;
66126 +
66127 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66128 + return 1;
66129 +
66130 + /* ignore Eric Biederman */
66131 + if (IS_PRIVATE(dentry->d_inode))
66132 + return 1;
66133 +
66134 + subj = task->acl;
66135 + read_lock(&gr_inode_lock);
66136 + do {
66137 + obj = lookup_acl_obj_label(ino, dev, subj);
66138 + if (obj != NULL) {
66139 + read_unlock(&gr_inode_lock);
66140 + return (obj->mode & GR_FIND) ? 1 : 0;
66141 + }
66142 + } while ((subj = subj->parent_subject));
66143 + read_unlock(&gr_inode_lock);
66144 +
66145 + /* this is purely an optimization since we're looking for an object
66146 + for the directory we're doing a readdir on
66147 + if it's possible for any globbed object to match the entry we're
66148 + filling into the directory, then the object we find here will be
66149 + an anchor point with attached globbed objects
66150 + */
66151 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66152 + if (obj->globbed == NULL)
66153 + return (obj->mode & GR_FIND) ? 1 : 0;
66154 +
66155 + is_not_root = ((obj->filename[0] == '/') &&
66156 + (obj->filename[1] == '\0')) ? 0 : 1;
66157 + bufsize = PAGE_SIZE - namelen - is_not_root;
66158 +
66159 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66160 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66161 + return 1;
66162 +
66163 + preempt_disable();
66164 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66165 + bufsize);
66166 +
66167 + bufsize = strlen(path);
66168 +
66169 + /* if base is "/", don't append an additional slash */
66170 + if (is_not_root)
66171 + *(path + bufsize) = '/';
66172 + memcpy(path + bufsize + is_not_root, name, namelen);
66173 + *(path + bufsize + namelen + is_not_root) = '\0';
66174 +
66175 + tmp = obj->globbed;
66176 + while (tmp) {
66177 + if (!glob_match(tmp->filename, path)) {
66178 + preempt_enable();
66179 + return (tmp->mode & GR_FIND) ? 1 : 0;
66180 + }
66181 + tmp = tmp->next;
66182 + }
66183 + preempt_enable();
66184 + return (obj->mode & GR_FIND) ? 1 : 0;
66185 +}
66186 +
66187 +void gr_put_exec_file(struct task_struct *task)
66188 +{
66189 + struct file *filp;
66190 +
66191 + write_lock(&grsec_exec_file_lock);
66192 + filp = task->exec_file;
66193 + task->exec_file = NULL;
66194 + write_unlock(&grsec_exec_file_lock);
66195 +
66196 + if (filp)
66197 + fput(filp);
66198 +
66199 + return;
66200 +}
66201 +
66202 +
66203 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66204 +EXPORT_SYMBOL(gr_acl_is_enabled);
66205 +#endif
66206 +EXPORT_SYMBOL(gr_set_kernel_label);
66207 +#ifdef CONFIG_SECURITY
66208 +EXPORT_SYMBOL(gr_check_user_change);
66209 +EXPORT_SYMBOL(gr_check_group_change);
66210 +#endif
66211 +
66212 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66213 new file mode 100644
66214 index 0000000..34fefda
66215 --- /dev/null
66216 +++ b/grsecurity/gracl_alloc.c
66217 @@ -0,0 +1,105 @@
66218 +#include <linux/kernel.h>
66219 +#include <linux/mm.h>
66220 +#include <linux/slab.h>
66221 +#include <linux/vmalloc.h>
66222 +#include <linux/gracl.h>
66223 +#include <linux/grsecurity.h>
66224 +
66225 +static unsigned long alloc_stack_next = 1;
66226 +static unsigned long alloc_stack_size = 1;
66227 +static void **alloc_stack;
66228 +
66229 +static __inline__ int
66230 +alloc_pop(void)
66231 +{
66232 + if (alloc_stack_next == 1)
66233 + return 0;
66234 +
66235 + kfree(alloc_stack[alloc_stack_next - 2]);
66236 +
66237 + alloc_stack_next--;
66238 +
66239 + return 1;
66240 +}
66241 +
66242 +static __inline__ int
66243 +alloc_push(void *buf)
66244 +{
66245 + if (alloc_stack_next >= alloc_stack_size)
66246 + return 1;
66247 +
66248 + alloc_stack[alloc_stack_next - 1] = buf;
66249 +
66250 + alloc_stack_next++;
66251 +
66252 + return 0;
66253 +}
66254 +
66255 +void *
66256 +acl_alloc(unsigned long len)
66257 +{
66258 + void *ret = NULL;
66259 +
66260 + if (!len || len > PAGE_SIZE)
66261 + goto out;
66262 +
66263 + ret = kmalloc(len, GFP_KERNEL);
66264 +
66265 + if (ret) {
66266 + if (alloc_push(ret)) {
66267 + kfree(ret);
66268 + ret = NULL;
66269 + }
66270 + }
66271 +
66272 +out:
66273 + return ret;
66274 +}
66275 +
66276 +void *
66277 +acl_alloc_num(unsigned long num, unsigned long len)
66278 +{
66279 + if (!len || (num > (PAGE_SIZE / len)))
66280 + return NULL;
66281 +
66282 + return acl_alloc(num * len);
66283 +}
66284 +
66285 +void
66286 +acl_free_all(void)
66287 +{
66288 + if (gr_acl_is_enabled() || !alloc_stack)
66289 + return;
66290 +
66291 + while (alloc_pop()) ;
66292 +
66293 + if (alloc_stack) {
66294 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66295 + kfree(alloc_stack);
66296 + else
66297 + vfree(alloc_stack);
66298 + }
66299 +
66300 + alloc_stack = NULL;
66301 + alloc_stack_size = 1;
66302 + alloc_stack_next = 1;
66303 +
66304 + return;
66305 +}
66306 +
66307 +int
66308 +acl_alloc_stack_init(unsigned long size)
66309 +{
66310 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66311 + alloc_stack =
66312 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66313 + else
66314 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66315 +
66316 + alloc_stack_size = size;
66317 +
66318 + if (!alloc_stack)
66319 + return 0;
66320 + else
66321 + return 1;
66322 +}
66323 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66324 new file mode 100644
66325 index 0000000..bdd51ea
66326 --- /dev/null
66327 +++ b/grsecurity/gracl_cap.c
66328 @@ -0,0 +1,110 @@
66329 +#include <linux/kernel.h>
66330 +#include <linux/module.h>
66331 +#include <linux/sched.h>
66332 +#include <linux/gracl.h>
66333 +#include <linux/grsecurity.h>
66334 +#include <linux/grinternal.h>
66335 +
66336 +extern const char *captab_log[];
66337 +extern int captab_log_entries;
66338 +
66339 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66340 +{
66341 + struct acl_subject_label *curracl;
66342 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66343 + kernel_cap_t cap_audit = __cap_empty_set;
66344 +
66345 + if (!gr_acl_is_enabled())
66346 + return 1;
66347 +
66348 + curracl = task->acl;
66349 +
66350 + cap_drop = curracl->cap_lower;
66351 + cap_mask = curracl->cap_mask;
66352 + cap_audit = curracl->cap_invert_audit;
66353 +
66354 + while ((curracl = curracl->parent_subject)) {
66355 + /* if the cap isn't specified in the current computed mask but is specified in the
66356 + current level subject, and is lowered in the current level subject, then add
66357 + it to the set of dropped capabilities
66358 + otherwise, add the current level subject's mask to the current computed mask
66359 + */
66360 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66361 + cap_raise(cap_mask, cap);
66362 + if (cap_raised(curracl->cap_lower, cap))
66363 + cap_raise(cap_drop, cap);
66364 + if (cap_raised(curracl->cap_invert_audit, cap))
66365 + cap_raise(cap_audit, cap);
66366 + }
66367 + }
66368 +
66369 + if (!cap_raised(cap_drop, cap)) {
66370 + if (cap_raised(cap_audit, cap))
66371 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66372 + return 1;
66373 + }
66374 +
66375 + curracl = task->acl;
66376 +
66377 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66378 + && cap_raised(cred->cap_effective, cap)) {
66379 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66380 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66381 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66382 + gr_to_filename(task->exec_file->f_path.dentry,
66383 + task->exec_file->f_path.mnt) : curracl->filename,
66384 + curracl->filename, 0UL,
66385 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66386 + return 1;
66387 + }
66388 +
66389 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66390 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66391 +
66392 + return 0;
66393 +}
66394 +
66395 +int
66396 +gr_acl_is_capable(const int cap)
66397 +{
66398 + return gr_task_acl_is_capable(current, current_cred(), cap);
66399 +}
66400 +
66401 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66402 +{
66403 + struct acl_subject_label *curracl;
66404 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66405 +
66406 + if (!gr_acl_is_enabled())
66407 + return 1;
66408 +
66409 + curracl = task->acl;
66410 +
66411 + cap_drop = curracl->cap_lower;
66412 + cap_mask = curracl->cap_mask;
66413 +
66414 + while ((curracl = curracl->parent_subject)) {
66415 + /* if the cap isn't specified in the current computed mask but is specified in the
66416 + current level subject, and is lowered in the current level subject, then add
66417 + it to the set of dropped capabilities
66418 + otherwise, add the current level subject's mask to the current computed mask
66419 + */
66420 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66421 + cap_raise(cap_mask, cap);
66422 + if (cap_raised(curracl->cap_lower, cap))
66423 + cap_raise(cap_drop, cap);
66424 + }
66425 + }
66426 +
66427 + if (!cap_raised(cap_drop, cap))
66428 + return 1;
66429 +
66430 + return 0;
66431 +}
66432 +
66433 +int
66434 +gr_acl_is_capable_nolog(const int cap)
66435 +{
66436 + return gr_task_acl_is_capable_nolog(current, cap);
66437 +}
66438 +
66439 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66440 new file mode 100644
66441 index 0000000..a43dd06
66442 --- /dev/null
66443 +++ b/grsecurity/gracl_compat.c
66444 @@ -0,0 +1,269 @@
66445 +#include <linux/kernel.h>
66446 +#include <linux/gracl.h>
66447 +#include <linux/compat.h>
66448 +#include <linux/gracl_compat.h>
66449 +
66450 +#include <asm/uaccess.h>
66451 +
66452 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66453 +{
66454 + struct gr_arg_wrapper_compat uwrapcompat;
66455 +
66456 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66457 + return -EFAULT;
66458 +
66459 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66460 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66461 + return -EINVAL;
66462 +
66463 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66464 + uwrap->version = uwrapcompat.version;
66465 + uwrap->size = sizeof(struct gr_arg);
66466 +
66467 + return 0;
66468 +}
66469 +
66470 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66471 +{
66472 + struct gr_arg_compat argcompat;
66473 +
66474 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66475 + return -EFAULT;
66476 +
66477 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66478 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66479 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66480 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66481 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66482 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66483 +
66484 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66485 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66486 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66487 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66488 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66489 + arg->segv_device = argcompat.segv_device;
66490 + arg->segv_inode = argcompat.segv_inode;
66491 + arg->segv_uid = argcompat.segv_uid;
66492 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66493 + arg->mode = argcompat.mode;
66494 +
66495 + return 0;
66496 +}
66497 +
66498 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66499 +{
66500 + struct acl_object_label_compat objcompat;
66501 +
66502 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66503 + return -EFAULT;
66504 +
66505 + obj->filename = compat_ptr(objcompat.filename);
66506 + obj->inode = objcompat.inode;
66507 + obj->device = objcompat.device;
66508 + obj->mode = objcompat.mode;
66509 +
66510 + obj->nested = compat_ptr(objcompat.nested);
66511 + obj->globbed = compat_ptr(objcompat.globbed);
66512 +
66513 + obj->prev = compat_ptr(objcompat.prev);
66514 + obj->next = compat_ptr(objcompat.next);
66515 +
66516 + return 0;
66517 +}
66518 +
66519 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66520 +{
66521 + unsigned int i;
66522 + struct acl_subject_label_compat subjcompat;
66523 +
66524 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66525 + return -EFAULT;
66526 +
66527 + subj->filename = compat_ptr(subjcompat.filename);
66528 + subj->inode = subjcompat.inode;
66529 + subj->device = subjcompat.device;
66530 + subj->mode = subjcompat.mode;
66531 + subj->cap_mask = subjcompat.cap_mask;
66532 + subj->cap_lower = subjcompat.cap_lower;
66533 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66534 +
66535 + for (i = 0; i < GR_NLIMITS; i++) {
66536 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66537 + subj->res[i].rlim_cur = RLIM_INFINITY;
66538 + else
66539 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66540 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66541 + subj->res[i].rlim_max = RLIM_INFINITY;
66542 + else
66543 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66544 + }
66545 + subj->resmask = subjcompat.resmask;
66546 +
66547 + subj->user_trans_type = subjcompat.user_trans_type;
66548 + subj->group_trans_type = subjcompat.group_trans_type;
66549 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66550 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66551 + subj->user_trans_num = subjcompat.user_trans_num;
66552 + subj->group_trans_num = subjcompat.group_trans_num;
66553 +
66554 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66555 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66556 + subj->ip_type = subjcompat.ip_type;
66557 + subj->ips = compat_ptr(subjcompat.ips);
66558 + subj->ip_num = subjcompat.ip_num;
66559 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66560 +
66561 + subj->crashes = subjcompat.crashes;
66562 + subj->expires = subjcompat.expires;
66563 +
66564 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66565 + subj->hash = compat_ptr(subjcompat.hash);
66566 + subj->prev = compat_ptr(subjcompat.prev);
66567 + subj->next = compat_ptr(subjcompat.next);
66568 +
66569 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66570 + subj->obj_hash_size = subjcompat.obj_hash_size;
66571 + subj->pax_flags = subjcompat.pax_flags;
66572 +
66573 + return 0;
66574 +}
66575 +
66576 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66577 +{
66578 + struct acl_role_label_compat rolecompat;
66579 +
66580 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66581 + return -EFAULT;
66582 +
66583 + role->rolename = compat_ptr(rolecompat.rolename);
66584 + role->uidgid = rolecompat.uidgid;
66585 + role->roletype = rolecompat.roletype;
66586 +
66587 + role->auth_attempts = rolecompat.auth_attempts;
66588 + role->expires = rolecompat.expires;
66589 +
66590 + role->root_label = compat_ptr(rolecompat.root_label);
66591 + role->hash = compat_ptr(rolecompat.hash);
66592 +
66593 + role->prev = compat_ptr(rolecompat.prev);
66594 + role->next = compat_ptr(rolecompat.next);
66595 +
66596 + role->transitions = compat_ptr(rolecompat.transitions);
66597 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66598 + role->domain_children = compat_ptr(rolecompat.domain_children);
66599 + role->domain_child_num = rolecompat.domain_child_num;
66600 +
66601 + role->umask = rolecompat.umask;
66602 +
66603 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66604 + role->subj_hash_size = rolecompat.subj_hash_size;
66605 +
66606 + return 0;
66607 +}
66608 +
66609 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66610 +{
66611 + struct role_allowed_ip_compat roleip_compat;
66612 +
66613 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66614 + return -EFAULT;
66615 +
66616 + roleip->addr = roleip_compat.addr;
66617 + roleip->netmask = roleip_compat.netmask;
66618 +
66619 + roleip->prev = compat_ptr(roleip_compat.prev);
66620 + roleip->next = compat_ptr(roleip_compat.next);
66621 +
66622 + return 0;
66623 +}
66624 +
66625 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66626 +{
66627 + struct role_transition_compat trans_compat;
66628 +
66629 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66630 + return -EFAULT;
66631 +
66632 + trans->rolename = compat_ptr(trans_compat.rolename);
66633 +
66634 + trans->prev = compat_ptr(trans_compat.prev);
66635 + trans->next = compat_ptr(trans_compat.next);
66636 +
66637 + return 0;
66638 +
66639 +}
66640 +
66641 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66642 +{
66643 + struct gr_hash_struct_compat hash_compat;
66644 +
66645 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66646 + return -EFAULT;
66647 +
66648 + hash->table = compat_ptr(hash_compat.table);
66649 + hash->nametable = compat_ptr(hash_compat.nametable);
66650 + hash->first = compat_ptr(hash_compat.first);
66651 +
66652 + hash->table_size = hash_compat.table_size;
66653 + hash->used_size = hash_compat.used_size;
66654 +
66655 + hash->type = hash_compat.type;
66656 +
66657 + return 0;
66658 +}
66659 +
66660 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66661 +{
66662 + compat_uptr_t ptrcompat;
66663 +
66664 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66665 + return -EFAULT;
66666 +
66667 + *(void **)ptr = compat_ptr(ptrcompat);
66668 +
66669 + return 0;
66670 +}
66671 +
66672 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66673 +{
66674 + struct acl_ip_label_compat ip_compat;
66675 +
66676 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66677 + return -EFAULT;
66678 +
66679 + ip->iface = compat_ptr(ip_compat.iface);
66680 + ip->addr = ip_compat.addr;
66681 + ip->netmask = ip_compat.netmask;
66682 + ip->low = ip_compat.low;
66683 + ip->high = ip_compat.high;
66684 + ip->mode = ip_compat.mode;
66685 + ip->type = ip_compat.type;
66686 +
66687 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66688 +
66689 + ip->prev = compat_ptr(ip_compat.prev);
66690 + ip->next = compat_ptr(ip_compat.next);
66691 +
66692 + return 0;
66693 +}
66694 +
66695 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66696 +{
66697 + struct sprole_pw_compat pw_compat;
66698 +
66699 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66700 + return -EFAULT;
66701 +
66702 + pw->rolename = compat_ptr(pw_compat.rolename);
66703 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66704 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66705 +
66706 + return 0;
66707 +}
66708 +
66709 +size_t get_gr_arg_wrapper_size_compat(void)
66710 +{
66711 + return sizeof(struct gr_arg_wrapper_compat);
66712 +}
66713 +
66714 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66715 new file mode 100644
66716 index 0000000..a340c17
66717 --- /dev/null
66718 +++ b/grsecurity/gracl_fs.c
66719 @@ -0,0 +1,431 @@
66720 +#include <linux/kernel.h>
66721 +#include <linux/sched.h>
66722 +#include <linux/types.h>
66723 +#include <linux/fs.h>
66724 +#include <linux/file.h>
66725 +#include <linux/stat.h>
66726 +#include <linux/grsecurity.h>
66727 +#include <linux/grinternal.h>
66728 +#include <linux/gracl.h>
66729 +
66730 +umode_t
66731 +gr_acl_umask(void)
66732 +{
66733 + if (unlikely(!gr_acl_is_enabled()))
66734 + return 0;
66735 +
66736 + return current->role->umask;
66737 +}
66738 +
66739 +__u32
66740 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66741 + const struct vfsmount * mnt)
66742 +{
66743 + __u32 mode;
66744 +
66745 + if (unlikely(!dentry->d_inode))
66746 + return GR_FIND;
66747 +
66748 + mode =
66749 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66750 +
66751 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66752 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66753 + return mode;
66754 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66755 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66756 + return 0;
66757 + } else if (unlikely(!(mode & GR_FIND)))
66758 + return 0;
66759 +
66760 + return GR_FIND;
66761 +}
66762 +
66763 +__u32
66764 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66765 + int acc_mode)
66766 +{
66767 + __u32 reqmode = GR_FIND;
66768 + __u32 mode;
66769 +
66770 + if (unlikely(!dentry->d_inode))
66771 + return reqmode;
66772 +
66773 + if (acc_mode & MAY_APPEND)
66774 + reqmode |= GR_APPEND;
66775 + else if (acc_mode & MAY_WRITE)
66776 + reqmode |= GR_WRITE;
66777 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66778 + reqmode |= GR_READ;
66779 +
66780 + mode =
66781 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66782 + mnt);
66783 +
66784 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66785 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66786 + reqmode & GR_READ ? " reading" : "",
66787 + reqmode & GR_WRITE ? " writing" : reqmode &
66788 + GR_APPEND ? " appending" : "");
66789 + return reqmode;
66790 + } else
66791 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66792 + {
66793 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66794 + reqmode & GR_READ ? " reading" : "",
66795 + reqmode & GR_WRITE ? " writing" : reqmode &
66796 + GR_APPEND ? " appending" : "");
66797 + return 0;
66798 + } else if (unlikely((mode & reqmode) != reqmode))
66799 + return 0;
66800 +
66801 + return reqmode;
66802 +}
66803 +
66804 +__u32
66805 +gr_acl_handle_creat(const struct dentry * dentry,
66806 + const struct dentry * p_dentry,
66807 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66808 + const int imode)
66809 +{
66810 + __u32 reqmode = GR_WRITE | GR_CREATE;
66811 + __u32 mode;
66812 +
66813 + if (acc_mode & MAY_APPEND)
66814 + reqmode |= GR_APPEND;
66815 + // if a directory was required or the directory already exists, then
66816 + // don't count this open as a read
66817 + if ((acc_mode & MAY_READ) &&
66818 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66819 + reqmode |= GR_READ;
66820 + if ((open_flags & O_CREAT) &&
66821 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66822 + reqmode |= GR_SETID;
66823 +
66824 + mode =
66825 + gr_check_create(dentry, p_dentry, p_mnt,
66826 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66827 +
66828 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66829 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66830 + reqmode & GR_READ ? " reading" : "",
66831 + reqmode & GR_WRITE ? " writing" : reqmode &
66832 + GR_APPEND ? " appending" : "");
66833 + return reqmode;
66834 + } else
66835 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66836 + {
66837 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66838 + reqmode & GR_READ ? " reading" : "",
66839 + reqmode & GR_WRITE ? " writing" : reqmode &
66840 + GR_APPEND ? " appending" : "");
66841 + return 0;
66842 + } else if (unlikely((mode & reqmode) != reqmode))
66843 + return 0;
66844 +
66845 + return reqmode;
66846 +}
66847 +
66848 +__u32
66849 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
66850 + const int fmode)
66851 +{
66852 + __u32 mode, reqmode = GR_FIND;
66853 +
66854 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
66855 + reqmode |= GR_EXEC;
66856 + if (fmode & S_IWOTH)
66857 + reqmode |= GR_WRITE;
66858 + if (fmode & S_IROTH)
66859 + reqmode |= GR_READ;
66860 +
66861 + mode =
66862 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66863 + mnt);
66864 +
66865 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66866 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66867 + reqmode & GR_READ ? " reading" : "",
66868 + reqmode & GR_WRITE ? " writing" : "",
66869 + reqmode & GR_EXEC ? " executing" : "");
66870 + return reqmode;
66871 + } else
66872 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66873 + {
66874 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66875 + reqmode & GR_READ ? " reading" : "",
66876 + reqmode & GR_WRITE ? " writing" : "",
66877 + reqmode & GR_EXEC ? " executing" : "");
66878 + return 0;
66879 + } else if (unlikely((mode & reqmode) != reqmode))
66880 + return 0;
66881 +
66882 + return reqmode;
66883 +}
66884 +
66885 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
66886 +{
66887 + __u32 mode;
66888 +
66889 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
66890 +
66891 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66892 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
66893 + return mode;
66894 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66895 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
66896 + return 0;
66897 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66898 + return 0;
66899 +
66900 + return (reqmode);
66901 +}
66902 +
66903 +__u32
66904 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
66905 +{
66906 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
66907 +}
66908 +
66909 +__u32
66910 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
66911 +{
66912 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
66913 +}
66914 +
66915 +__u32
66916 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
66917 +{
66918 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
66919 +}
66920 +
66921 +__u32
66922 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
66923 +{
66924 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
66925 +}
66926 +
66927 +__u32
66928 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
66929 + umode_t *modeptr)
66930 +{
66931 + umode_t mode;
66932 +
66933 + *modeptr &= ~gr_acl_umask();
66934 + mode = *modeptr;
66935 +
66936 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
66937 + return 1;
66938 +
66939 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
66940 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
66941 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
66942 + GR_CHMOD_ACL_MSG);
66943 + } else {
66944 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
66945 + }
66946 +}
66947 +
66948 +__u32
66949 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
66950 +{
66951 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
66952 +}
66953 +
66954 +__u32
66955 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
66956 +{
66957 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
66958 +}
66959 +
66960 +__u32
66961 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
66962 +{
66963 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
66964 +}
66965 +
66966 +__u32
66967 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
66968 +{
66969 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
66970 + GR_UNIXCONNECT_ACL_MSG);
66971 +}
66972 +
66973 +/* hardlinks require at minimum create and link permission,
66974 + any additional privilege required is based on the
66975 + privilege of the file being linked to
66976 +*/
66977 +__u32
66978 +gr_acl_handle_link(const struct dentry * new_dentry,
66979 + const struct dentry * parent_dentry,
66980 + const struct vfsmount * parent_mnt,
66981 + const struct dentry * old_dentry,
66982 + const struct vfsmount * old_mnt, const struct filename *to)
66983 +{
66984 + __u32 mode;
66985 + __u32 needmode = GR_CREATE | GR_LINK;
66986 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
66987 +
66988 + mode =
66989 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
66990 + old_mnt);
66991 +
66992 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
66993 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66994 + return mode;
66995 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66996 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66997 + return 0;
66998 + } else if (unlikely((mode & needmode) != needmode))
66999 + return 0;
67000 +
67001 + return 1;
67002 +}
67003 +
67004 +__u32
67005 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67006 + const struct dentry * parent_dentry,
67007 + const struct vfsmount * parent_mnt, const struct filename *from)
67008 +{
67009 + __u32 needmode = GR_WRITE | GR_CREATE;
67010 + __u32 mode;
67011 +
67012 + mode =
67013 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67014 + GR_CREATE | GR_AUDIT_CREATE |
67015 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67016 +
67017 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67018 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67019 + return mode;
67020 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67021 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67022 + return 0;
67023 + } else if (unlikely((mode & needmode) != needmode))
67024 + return 0;
67025 +
67026 + return (GR_WRITE | GR_CREATE);
67027 +}
67028 +
67029 +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)
67030 +{
67031 + __u32 mode;
67032 +
67033 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67034 +
67035 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67036 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67037 + return mode;
67038 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67039 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67040 + return 0;
67041 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67042 + return 0;
67043 +
67044 + return (reqmode);
67045 +}
67046 +
67047 +__u32
67048 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67049 + const struct dentry * parent_dentry,
67050 + const struct vfsmount * parent_mnt,
67051 + const int mode)
67052 +{
67053 + __u32 reqmode = GR_WRITE | GR_CREATE;
67054 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67055 + reqmode |= GR_SETID;
67056 +
67057 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67058 + reqmode, GR_MKNOD_ACL_MSG);
67059 +}
67060 +
67061 +__u32
67062 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67063 + const struct dentry *parent_dentry,
67064 + const struct vfsmount *parent_mnt)
67065 +{
67066 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67067 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67068 +}
67069 +
67070 +#define RENAME_CHECK_SUCCESS(old, new) \
67071 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67072 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67073 +
67074 +int
67075 +gr_acl_handle_rename(struct dentry *new_dentry,
67076 + struct dentry *parent_dentry,
67077 + const struct vfsmount *parent_mnt,
67078 + struct dentry *old_dentry,
67079 + struct inode *old_parent_inode,
67080 + struct vfsmount *old_mnt, const struct filename *newname)
67081 +{
67082 + __u32 comp1, comp2;
67083 + int error = 0;
67084 +
67085 + if (unlikely(!gr_acl_is_enabled()))
67086 + return 0;
67087 +
67088 + if (!new_dentry->d_inode) {
67089 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67090 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67091 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67092 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67093 + GR_DELETE | GR_AUDIT_DELETE |
67094 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67095 + GR_SUPPRESS, old_mnt);
67096 + } else {
67097 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67098 + GR_CREATE | GR_DELETE |
67099 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67100 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67101 + GR_SUPPRESS, parent_mnt);
67102 + comp2 =
67103 + gr_search_file(old_dentry,
67104 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67105 + GR_DELETE | GR_AUDIT_DELETE |
67106 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67107 + }
67108 +
67109 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67110 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67111 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67112 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67113 + && !(comp2 & GR_SUPPRESS)) {
67114 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67115 + error = -EACCES;
67116 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67117 + error = -EACCES;
67118 +
67119 + return error;
67120 +}
67121 +
67122 +void
67123 +gr_acl_handle_exit(void)
67124 +{
67125 + u16 id;
67126 + char *rolename;
67127 +
67128 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67129 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67130 + id = current->acl_role_id;
67131 + rolename = current->role->rolename;
67132 + gr_set_acls(1);
67133 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67134 + }
67135 +
67136 + gr_put_exec_file(current);
67137 + return;
67138 +}
67139 +
67140 +int
67141 +gr_acl_handle_procpidmem(const struct task_struct *task)
67142 +{
67143 + if (unlikely(!gr_acl_is_enabled()))
67144 + return 0;
67145 +
67146 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67147 + return -EACCES;
67148 +
67149 + return 0;
67150 +}
67151 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67152 new file mode 100644
67153 index 0000000..f056b81
67154 --- /dev/null
67155 +++ b/grsecurity/gracl_ip.c
67156 @@ -0,0 +1,386 @@
67157 +#include <linux/kernel.h>
67158 +#include <asm/uaccess.h>
67159 +#include <asm/errno.h>
67160 +#include <net/sock.h>
67161 +#include <linux/file.h>
67162 +#include <linux/fs.h>
67163 +#include <linux/net.h>
67164 +#include <linux/in.h>
67165 +#include <linux/skbuff.h>
67166 +#include <linux/ip.h>
67167 +#include <linux/udp.h>
67168 +#include <linux/types.h>
67169 +#include <linux/sched.h>
67170 +#include <linux/netdevice.h>
67171 +#include <linux/inetdevice.h>
67172 +#include <linux/gracl.h>
67173 +#include <linux/grsecurity.h>
67174 +#include <linux/grinternal.h>
67175 +
67176 +#define GR_BIND 0x01
67177 +#define GR_CONNECT 0x02
67178 +#define GR_INVERT 0x04
67179 +#define GR_BINDOVERRIDE 0x08
67180 +#define GR_CONNECTOVERRIDE 0x10
67181 +#define GR_SOCK_FAMILY 0x20
67182 +
67183 +static const char * gr_protocols[IPPROTO_MAX] = {
67184 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67185 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67186 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67187 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67188 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67189 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67190 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67191 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67192 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67193 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67194 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67195 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67196 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67197 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67198 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67199 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67200 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67201 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67202 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67203 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67204 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67205 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67206 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67207 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67208 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67209 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67210 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67211 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67212 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67213 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67214 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67215 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67216 + };
67217 +
67218 +static const char * gr_socktypes[SOCK_MAX] = {
67219 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67220 + "unknown:7", "unknown:8", "unknown:9", "packet"
67221 + };
67222 +
67223 +static const char * gr_sockfamilies[AF_MAX+1] = {
67224 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67225 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67226 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67227 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67228 + };
67229 +
67230 +const char *
67231 +gr_proto_to_name(unsigned char proto)
67232 +{
67233 + return gr_protocols[proto];
67234 +}
67235 +
67236 +const char *
67237 +gr_socktype_to_name(unsigned char type)
67238 +{
67239 + return gr_socktypes[type];
67240 +}
67241 +
67242 +const char *
67243 +gr_sockfamily_to_name(unsigned char family)
67244 +{
67245 + return gr_sockfamilies[family];
67246 +}
67247 +
67248 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67249 +
67250 +int
67251 +gr_search_socket(const int domain, const int type, const int protocol)
67252 +{
67253 + struct acl_subject_label *curr;
67254 + const struct cred *cred = current_cred();
67255 +
67256 + if (unlikely(!gr_acl_is_enabled()))
67257 + goto exit;
67258 +
67259 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67260 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67261 + goto exit; // let the kernel handle it
67262 +
67263 + curr = current->acl;
67264 +
67265 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67266 + /* the family is allowed, if this is PF_INET allow it only if
67267 + the extra sock type/protocol checks pass */
67268 + if (domain == PF_INET)
67269 + goto inet_check;
67270 + goto exit;
67271 + } else {
67272 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67273 + __u32 fakeip = 0;
67274 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67275 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67276 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67277 + gr_to_filename(current->exec_file->f_path.dentry,
67278 + current->exec_file->f_path.mnt) :
67279 + curr->filename, curr->filename,
67280 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67281 + &current->signal->saved_ip);
67282 + goto exit;
67283 + }
67284 + goto exit_fail;
67285 + }
67286 +
67287 +inet_check:
67288 + /* the rest of this checking is for IPv4 only */
67289 + if (!curr->ips)
67290 + goto exit;
67291 +
67292 + if ((curr->ip_type & (1U << type)) &&
67293 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67294 + goto exit;
67295 +
67296 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67297 + /* we don't place acls on raw sockets , and sometimes
67298 + dgram/ip sockets are opened for ioctl and not
67299 + bind/connect, so we'll fake a bind learn log */
67300 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67301 + __u32 fakeip = 0;
67302 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67303 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67304 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67305 + gr_to_filename(current->exec_file->f_path.dentry,
67306 + current->exec_file->f_path.mnt) :
67307 + curr->filename, curr->filename,
67308 + &fakeip, 0, type,
67309 + protocol, GR_CONNECT, &current->signal->saved_ip);
67310 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67311 + __u32 fakeip = 0;
67312 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67313 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67314 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67315 + gr_to_filename(current->exec_file->f_path.dentry,
67316 + current->exec_file->f_path.mnt) :
67317 + curr->filename, curr->filename,
67318 + &fakeip, 0, type,
67319 + protocol, GR_BIND, &current->signal->saved_ip);
67320 + }
67321 + /* we'll log when they use connect or bind */
67322 + goto exit;
67323 + }
67324 +
67325 +exit_fail:
67326 + if (domain == PF_INET)
67327 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67328 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67329 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67330 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67331 + gr_socktype_to_name(type), protocol);
67332 +
67333 + return 0;
67334 +exit:
67335 + return 1;
67336 +}
67337 +
67338 +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)
67339 +{
67340 + if ((ip->mode & mode) &&
67341 + (ip_port >= ip->low) &&
67342 + (ip_port <= ip->high) &&
67343 + ((ntohl(ip_addr) & our_netmask) ==
67344 + (ntohl(our_addr) & our_netmask))
67345 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67346 + && (ip->type & (1U << type))) {
67347 + if (ip->mode & GR_INVERT)
67348 + return 2; // specifically denied
67349 + else
67350 + return 1; // allowed
67351 + }
67352 +
67353 + return 0; // not specifically allowed, may continue parsing
67354 +}
67355 +
67356 +static int
67357 +gr_search_connectbind(const int full_mode, struct sock *sk,
67358 + struct sockaddr_in *addr, const int type)
67359 +{
67360 + char iface[IFNAMSIZ] = {0};
67361 + struct acl_subject_label *curr;
67362 + struct acl_ip_label *ip;
67363 + struct inet_sock *isk;
67364 + struct net_device *dev;
67365 + struct in_device *idev;
67366 + unsigned long i;
67367 + int ret;
67368 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67369 + __u32 ip_addr = 0;
67370 + __u32 our_addr;
67371 + __u32 our_netmask;
67372 + char *p;
67373 + __u16 ip_port = 0;
67374 + const struct cred *cred = current_cred();
67375 +
67376 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67377 + return 0;
67378 +
67379 + curr = current->acl;
67380 + isk = inet_sk(sk);
67381 +
67382 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67383 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67384 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67385 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67386 + struct sockaddr_in saddr;
67387 + int err;
67388 +
67389 + saddr.sin_family = AF_INET;
67390 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67391 + saddr.sin_port = isk->inet_sport;
67392 +
67393 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67394 + if (err)
67395 + return err;
67396 +
67397 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67398 + if (err)
67399 + return err;
67400 + }
67401 +
67402 + if (!curr->ips)
67403 + return 0;
67404 +
67405 + ip_addr = addr->sin_addr.s_addr;
67406 + ip_port = ntohs(addr->sin_port);
67407 +
67408 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67409 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67410 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67411 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67412 + gr_to_filename(current->exec_file->f_path.dentry,
67413 + current->exec_file->f_path.mnt) :
67414 + curr->filename, curr->filename,
67415 + &ip_addr, ip_port, type,
67416 + sk->sk_protocol, mode, &current->signal->saved_ip);
67417 + return 0;
67418 + }
67419 +
67420 + for (i = 0; i < curr->ip_num; i++) {
67421 + ip = *(curr->ips + i);
67422 + if (ip->iface != NULL) {
67423 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67424 + p = strchr(iface, ':');
67425 + if (p != NULL)
67426 + *p = '\0';
67427 + dev = dev_get_by_name(sock_net(sk), iface);
67428 + if (dev == NULL)
67429 + continue;
67430 + idev = in_dev_get(dev);
67431 + if (idev == NULL) {
67432 + dev_put(dev);
67433 + continue;
67434 + }
67435 + rcu_read_lock();
67436 + for_ifa(idev) {
67437 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67438 + our_addr = ifa->ifa_address;
67439 + our_netmask = 0xffffffff;
67440 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67441 + if (ret == 1) {
67442 + rcu_read_unlock();
67443 + in_dev_put(idev);
67444 + dev_put(dev);
67445 + return 0;
67446 + } else if (ret == 2) {
67447 + rcu_read_unlock();
67448 + in_dev_put(idev);
67449 + dev_put(dev);
67450 + goto denied;
67451 + }
67452 + }
67453 + } endfor_ifa(idev);
67454 + rcu_read_unlock();
67455 + in_dev_put(idev);
67456 + dev_put(dev);
67457 + } else {
67458 + our_addr = ip->addr;
67459 + our_netmask = ip->netmask;
67460 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67461 + if (ret == 1)
67462 + return 0;
67463 + else if (ret == 2)
67464 + goto denied;
67465 + }
67466 + }
67467 +
67468 +denied:
67469 + if (mode == GR_BIND)
67470 + 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));
67471 + else if (mode == GR_CONNECT)
67472 + 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));
67473 +
67474 + return -EACCES;
67475 +}
67476 +
67477 +int
67478 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67479 +{
67480 + /* always allow disconnection of dgram sockets with connect */
67481 + if (addr->sin_family == AF_UNSPEC)
67482 + return 0;
67483 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67484 +}
67485 +
67486 +int
67487 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67488 +{
67489 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67490 +}
67491 +
67492 +int gr_search_listen(struct socket *sock)
67493 +{
67494 + struct sock *sk = sock->sk;
67495 + struct sockaddr_in addr;
67496 +
67497 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67498 + addr.sin_port = inet_sk(sk)->inet_sport;
67499 +
67500 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67501 +}
67502 +
67503 +int gr_search_accept(struct socket *sock)
67504 +{
67505 + struct sock *sk = sock->sk;
67506 + struct sockaddr_in addr;
67507 +
67508 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67509 + addr.sin_port = inet_sk(sk)->inet_sport;
67510 +
67511 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67512 +}
67513 +
67514 +int
67515 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67516 +{
67517 + if (addr)
67518 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67519 + else {
67520 + struct sockaddr_in sin;
67521 + const struct inet_sock *inet = inet_sk(sk);
67522 +
67523 + sin.sin_addr.s_addr = inet->inet_daddr;
67524 + sin.sin_port = inet->inet_dport;
67525 +
67526 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67527 + }
67528 +}
67529 +
67530 +int
67531 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67532 +{
67533 + struct sockaddr_in sin;
67534 +
67535 + if (unlikely(skb->len < sizeof (struct udphdr)))
67536 + return 0; // skip this packet
67537 +
67538 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67539 + sin.sin_port = udp_hdr(skb)->source;
67540 +
67541 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67542 +}
67543 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67544 new file mode 100644
67545 index 0000000..25f54ef
67546 --- /dev/null
67547 +++ b/grsecurity/gracl_learn.c
67548 @@ -0,0 +1,207 @@
67549 +#include <linux/kernel.h>
67550 +#include <linux/mm.h>
67551 +#include <linux/sched.h>
67552 +#include <linux/poll.h>
67553 +#include <linux/string.h>
67554 +#include <linux/file.h>
67555 +#include <linux/types.h>
67556 +#include <linux/vmalloc.h>
67557 +#include <linux/grinternal.h>
67558 +
67559 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67560 + size_t count, loff_t *ppos);
67561 +extern int gr_acl_is_enabled(void);
67562 +
67563 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67564 +static int gr_learn_attached;
67565 +
67566 +/* use a 512k buffer */
67567 +#define LEARN_BUFFER_SIZE (512 * 1024)
67568 +
67569 +static DEFINE_SPINLOCK(gr_learn_lock);
67570 +static DEFINE_MUTEX(gr_learn_user_mutex);
67571 +
67572 +/* we need to maintain two buffers, so that the kernel context of grlearn
67573 + uses a semaphore around the userspace copying, and the other kernel contexts
67574 + use a spinlock when copying into the buffer, since they cannot sleep
67575 +*/
67576 +static char *learn_buffer;
67577 +static char *learn_buffer_user;
67578 +static int learn_buffer_len;
67579 +static int learn_buffer_user_len;
67580 +
67581 +static ssize_t
67582 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67583 +{
67584 + DECLARE_WAITQUEUE(wait, current);
67585 + ssize_t retval = 0;
67586 +
67587 + add_wait_queue(&learn_wait, &wait);
67588 + set_current_state(TASK_INTERRUPTIBLE);
67589 + do {
67590 + mutex_lock(&gr_learn_user_mutex);
67591 + spin_lock(&gr_learn_lock);
67592 + if (learn_buffer_len)
67593 + break;
67594 + spin_unlock(&gr_learn_lock);
67595 + mutex_unlock(&gr_learn_user_mutex);
67596 + if (file->f_flags & O_NONBLOCK) {
67597 + retval = -EAGAIN;
67598 + goto out;
67599 + }
67600 + if (signal_pending(current)) {
67601 + retval = -ERESTARTSYS;
67602 + goto out;
67603 + }
67604 +
67605 + schedule();
67606 + } while (1);
67607 +
67608 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67609 + learn_buffer_user_len = learn_buffer_len;
67610 + retval = learn_buffer_len;
67611 + learn_buffer_len = 0;
67612 +
67613 + spin_unlock(&gr_learn_lock);
67614 +
67615 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67616 + retval = -EFAULT;
67617 +
67618 + mutex_unlock(&gr_learn_user_mutex);
67619 +out:
67620 + set_current_state(TASK_RUNNING);
67621 + remove_wait_queue(&learn_wait, &wait);
67622 + return retval;
67623 +}
67624 +
67625 +static unsigned int
67626 +poll_learn(struct file * file, poll_table * wait)
67627 +{
67628 + poll_wait(file, &learn_wait, wait);
67629 +
67630 + if (learn_buffer_len)
67631 + return (POLLIN | POLLRDNORM);
67632 +
67633 + return 0;
67634 +}
67635 +
67636 +void
67637 +gr_clear_learn_entries(void)
67638 +{
67639 + char *tmp;
67640 +
67641 + mutex_lock(&gr_learn_user_mutex);
67642 + spin_lock(&gr_learn_lock);
67643 + tmp = learn_buffer;
67644 + learn_buffer = NULL;
67645 + spin_unlock(&gr_learn_lock);
67646 + if (tmp)
67647 + vfree(tmp);
67648 + if (learn_buffer_user != NULL) {
67649 + vfree(learn_buffer_user);
67650 + learn_buffer_user = NULL;
67651 + }
67652 + learn_buffer_len = 0;
67653 + mutex_unlock(&gr_learn_user_mutex);
67654 +
67655 + return;
67656 +}
67657 +
67658 +void
67659 +gr_add_learn_entry(const char *fmt, ...)
67660 +{
67661 + va_list args;
67662 + unsigned int len;
67663 +
67664 + if (!gr_learn_attached)
67665 + return;
67666 +
67667 + spin_lock(&gr_learn_lock);
67668 +
67669 + /* leave a gap at the end so we know when it's "full" but don't have to
67670 + compute the exact length of the string we're trying to append
67671 + */
67672 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67673 + spin_unlock(&gr_learn_lock);
67674 + wake_up_interruptible(&learn_wait);
67675 + return;
67676 + }
67677 + if (learn_buffer == NULL) {
67678 + spin_unlock(&gr_learn_lock);
67679 + return;
67680 + }
67681 +
67682 + va_start(args, fmt);
67683 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67684 + va_end(args);
67685 +
67686 + learn_buffer_len += len + 1;
67687 +
67688 + spin_unlock(&gr_learn_lock);
67689 + wake_up_interruptible(&learn_wait);
67690 +
67691 + return;
67692 +}
67693 +
67694 +static int
67695 +open_learn(struct inode *inode, struct file *file)
67696 +{
67697 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67698 + return -EBUSY;
67699 + if (file->f_mode & FMODE_READ) {
67700 + int retval = 0;
67701 + mutex_lock(&gr_learn_user_mutex);
67702 + if (learn_buffer == NULL)
67703 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67704 + if (learn_buffer_user == NULL)
67705 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67706 + if (learn_buffer == NULL) {
67707 + retval = -ENOMEM;
67708 + goto out_error;
67709 + }
67710 + if (learn_buffer_user == NULL) {
67711 + retval = -ENOMEM;
67712 + goto out_error;
67713 + }
67714 + learn_buffer_len = 0;
67715 + learn_buffer_user_len = 0;
67716 + gr_learn_attached = 1;
67717 +out_error:
67718 + mutex_unlock(&gr_learn_user_mutex);
67719 + return retval;
67720 + }
67721 + return 0;
67722 +}
67723 +
67724 +static int
67725 +close_learn(struct inode *inode, struct file *file)
67726 +{
67727 + if (file->f_mode & FMODE_READ) {
67728 + char *tmp = NULL;
67729 + mutex_lock(&gr_learn_user_mutex);
67730 + spin_lock(&gr_learn_lock);
67731 + tmp = learn_buffer;
67732 + learn_buffer = NULL;
67733 + spin_unlock(&gr_learn_lock);
67734 + if (tmp)
67735 + vfree(tmp);
67736 + if (learn_buffer_user != NULL) {
67737 + vfree(learn_buffer_user);
67738 + learn_buffer_user = NULL;
67739 + }
67740 + learn_buffer_len = 0;
67741 + learn_buffer_user_len = 0;
67742 + gr_learn_attached = 0;
67743 + mutex_unlock(&gr_learn_user_mutex);
67744 + }
67745 +
67746 + return 0;
67747 +}
67748 +
67749 +const struct file_operations grsec_fops = {
67750 + .read = read_learn,
67751 + .write = write_grsec_handler,
67752 + .open = open_learn,
67753 + .release = close_learn,
67754 + .poll = poll_learn,
67755 +};
67756 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
67757 new file mode 100644
67758 index 0000000..39645c9
67759 --- /dev/null
67760 +++ b/grsecurity/gracl_res.c
67761 @@ -0,0 +1,68 @@
67762 +#include <linux/kernel.h>
67763 +#include <linux/sched.h>
67764 +#include <linux/gracl.h>
67765 +#include <linux/grinternal.h>
67766 +
67767 +static const char *restab_log[] = {
67768 + [RLIMIT_CPU] = "RLIMIT_CPU",
67769 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
67770 + [RLIMIT_DATA] = "RLIMIT_DATA",
67771 + [RLIMIT_STACK] = "RLIMIT_STACK",
67772 + [RLIMIT_CORE] = "RLIMIT_CORE",
67773 + [RLIMIT_RSS] = "RLIMIT_RSS",
67774 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
67775 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
67776 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
67777 + [RLIMIT_AS] = "RLIMIT_AS",
67778 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
67779 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
67780 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
67781 + [RLIMIT_NICE] = "RLIMIT_NICE",
67782 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
67783 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
67784 + [GR_CRASH_RES] = "RLIMIT_CRASH"
67785 +};
67786 +
67787 +void
67788 +gr_log_resource(const struct task_struct *task,
67789 + const int res, const unsigned long wanted, const int gt)
67790 +{
67791 + const struct cred *cred;
67792 + unsigned long rlim;
67793 +
67794 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
67795 + return;
67796 +
67797 + // not yet supported resource
67798 + if (unlikely(!restab_log[res]))
67799 + return;
67800 +
67801 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
67802 + rlim = task_rlimit_max(task, res);
67803 + else
67804 + rlim = task_rlimit(task, res);
67805 +
67806 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
67807 + return;
67808 +
67809 + rcu_read_lock();
67810 + cred = __task_cred(task);
67811 +
67812 + if (res == RLIMIT_NPROC &&
67813 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
67814 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
67815 + goto out_rcu_unlock;
67816 + else if (res == RLIMIT_MEMLOCK &&
67817 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
67818 + goto out_rcu_unlock;
67819 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
67820 + goto out_rcu_unlock;
67821 + rcu_read_unlock();
67822 +
67823 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
67824 +
67825 + return;
67826 +out_rcu_unlock:
67827 + rcu_read_unlock();
67828 + return;
67829 +}
67830 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
67831 new file mode 100644
67832 index 0000000..3c38bfe
67833 --- /dev/null
67834 +++ b/grsecurity/gracl_segv.c
67835 @@ -0,0 +1,305 @@
67836 +#include <linux/kernel.h>
67837 +#include <linux/mm.h>
67838 +#include <asm/uaccess.h>
67839 +#include <asm/errno.h>
67840 +#include <asm/mman.h>
67841 +#include <net/sock.h>
67842 +#include <linux/file.h>
67843 +#include <linux/fs.h>
67844 +#include <linux/net.h>
67845 +#include <linux/in.h>
67846 +#include <linux/slab.h>
67847 +#include <linux/types.h>
67848 +#include <linux/sched.h>
67849 +#include <linux/timer.h>
67850 +#include <linux/gracl.h>
67851 +#include <linux/grsecurity.h>
67852 +#include <linux/grinternal.h>
67853 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
67854 +#include <linux/magic.h>
67855 +#include <linux/pagemap.h>
67856 +#include "../fs/btrfs/async-thread.h"
67857 +#include "../fs/btrfs/ctree.h"
67858 +#include "../fs/btrfs/btrfs_inode.h"
67859 +#endif
67860 +
67861 +static struct crash_uid *uid_set;
67862 +static unsigned short uid_used;
67863 +static DEFINE_SPINLOCK(gr_uid_lock);
67864 +extern rwlock_t gr_inode_lock;
67865 +extern struct acl_subject_label *
67866 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
67867 + struct acl_role_label *role);
67868 +
67869 +static inline dev_t __get_dev(const struct dentry *dentry)
67870 +{
67871 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
67872 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
67873 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
67874 + else
67875 +#endif
67876 + return dentry->d_sb->s_dev;
67877 +}
67878 +
67879 +int
67880 +gr_init_uidset(void)
67881 +{
67882 + uid_set =
67883 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
67884 + uid_used = 0;
67885 +
67886 + return uid_set ? 1 : 0;
67887 +}
67888 +
67889 +void
67890 +gr_free_uidset(void)
67891 +{
67892 + if (uid_set)
67893 + kfree(uid_set);
67894 +
67895 + return;
67896 +}
67897 +
67898 +int
67899 +gr_find_uid(const uid_t uid)
67900 +{
67901 + struct crash_uid *tmp = uid_set;
67902 + uid_t buid;
67903 + int low = 0, high = uid_used - 1, mid;
67904 +
67905 + while (high >= low) {
67906 + mid = (low + high) >> 1;
67907 + buid = tmp[mid].uid;
67908 + if (buid == uid)
67909 + return mid;
67910 + if (buid > uid)
67911 + high = mid - 1;
67912 + if (buid < uid)
67913 + low = mid + 1;
67914 + }
67915 +
67916 + return -1;
67917 +}
67918 +
67919 +static __inline__ void
67920 +gr_insertsort(void)
67921 +{
67922 + unsigned short i, j;
67923 + struct crash_uid index;
67924 +
67925 + for (i = 1; i < uid_used; i++) {
67926 + index = uid_set[i];
67927 + j = i;
67928 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
67929 + uid_set[j] = uid_set[j - 1];
67930 + j--;
67931 + }
67932 + uid_set[j] = index;
67933 + }
67934 +
67935 + return;
67936 +}
67937 +
67938 +static __inline__ void
67939 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
67940 +{
67941 + int loc;
67942 + uid_t uid = GR_GLOBAL_UID(kuid);
67943 +
67944 + if (uid_used == GR_UIDTABLE_MAX)
67945 + return;
67946 +
67947 + loc = gr_find_uid(uid);
67948 +
67949 + if (loc >= 0) {
67950 + uid_set[loc].expires = expires;
67951 + return;
67952 + }
67953 +
67954 + uid_set[uid_used].uid = uid;
67955 + uid_set[uid_used].expires = expires;
67956 + uid_used++;
67957 +
67958 + gr_insertsort();
67959 +
67960 + return;
67961 +}
67962 +
67963 +void
67964 +gr_remove_uid(const unsigned short loc)
67965 +{
67966 + unsigned short i;
67967 +
67968 + for (i = loc + 1; i < uid_used; i++)
67969 + uid_set[i - 1] = uid_set[i];
67970 +
67971 + uid_used--;
67972 +
67973 + return;
67974 +}
67975 +
67976 +int
67977 +gr_check_crash_uid(const kuid_t kuid)
67978 +{
67979 + int loc;
67980 + int ret = 0;
67981 + uid_t uid;
67982 +
67983 + if (unlikely(!gr_acl_is_enabled()))
67984 + return 0;
67985 +
67986 + uid = GR_GLOBAL_UID(kuid);
67987 +
67988 + spin_lock(&gr_uid_lock);
67989 + loc = gr_find_uid(uid);
67990 +
67991 + if (loc < 0)
67992 + goto out_unlock;
67993 +
67994 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
67995 + gr_remove_uid(loc);
67996 + else
67997 + ret = 1;
67998 +
67999 +out_unlock:
68000 + spin_unlock(&gr_uid_lock);
68001 + return ret;
68002 +}
68003 +
68004 +static __inline__ int
68005 +proc_is_setxid(const struct cred *cred)
68006 +{
68007 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68008 + !uid_eq(cred->uid, cred->fsuid))
68009 + return 1;
68010 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68011 + !gid_eq(cred->gid, cred->fsgid))
68012 + return 1;
68013 +
68014 + return 0;
68015 +}
68016 +
68017 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68018 +
68019 +void
68020 +gr_handle_crash(struct task_struct *task, const int sig)
68021 +{
68022 + struct acl_subject_label *curr;
68023 + struct task_struct *tsk, *tsk2;
68024 + const struct cred *cred;
68025 + const struct cred *cred2;
68026 +
68027 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68028 + return;
68029 +
68030 + if (unlikely(!gr_acl_is_enabled()))
68031 + return;
68032 +
68033 + curr = task->acl;
68034 +
68035 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68036 + return;
68037 +
68038 + if (time_before_eq(curr->expires, get_seconds())) {
68039 + curr->expires = 0;
68040 + curr->crashes = 0;
68041 + }
68042 +
68043 + curr->crashes++;
68044 +
68045 + if (!curr->expires)
68046 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68047 +
68048 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68049 + time_after(curr->expires, get_seconds())) {
68050 + rcu_read_lock();
68051 + cred = __task_cred(task);
68052 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68053 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68054 + spin_lock(&gr_uid_lock);
68055 + gr_insert_uid(cred->uid, curr->expires);
68056 + spin_unlock(&gr_uid_lock);
68057 + curr->expires = 0;
68058 + curr->crashes = 0;
68059 + read_lock(&tasklist_lock);
68060 + do_each_thread(tsk2, tsk) {
68061 + cred2 = __task_cred(tsk);
68062 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68063 + gr_fake_force_sig(SIGKILL, tsk);
68064 + } while_each_thread(tsk2, tsk);
68065 + read_unlock(&tasklist_lock);
68066 + } else {
68067 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68068 + read_lock(&tasklist_lock);
68069 + read_lock(&grsec_exec_file_lock);
68070 + do_each_thread(tsk2, tsk) {
68071 + if (likely(tsk != task)) {
68072 + // if this thread has the same subject as the one that triggered
68073 + // RES_CRASH and it's the same binary, kill it
68074 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68075 + gr_fake_force_sig(SIGKILL, tsk);
68076 + }
68077 + } while_each_thread(tsk2, tsk);
68078 + read_unlock(&grsec_exec_file_lock);
68079 + read_unlock(&tasklist_lock);
68080 + }
68081 + rcu_read_unlock();
68082 + }
68083 +
68084 + return;
68085 +}
68086 +
68087 +int
68088 +gr_check_crash_exec(const struct file *filp)
68089 +{
68090 + struct acl_subject_label *curr;
68091 +
68092 + if (unlikely(!gr_acl_is_enabled()))
68093 + return 0;
68094 +
68095 + read_lock(&gr_inode_lock);
68096 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68097 + __get_dev(filp->f_path.dentry),
68098 + current->role);
68099 + read_unlock(&gr_inode_lock);
68100 +
68101 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68102 + (!curr->crashes && !curr->expires))
68103 + return 0;
68104 +
68105 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68106 + time_after(curr->expires, get_seconds()))
68107 + return 1;
68108 + else if (time_before_eq(curr->expires, get_seconds())) {
68109 + curr->crashes = 0;
68110 + curr->expires = 0;
68111 + }
68112 +
68113 + return 0;
68114 +}
68115 +
68116 +void
68117 +gr_handle_alertkill(struct task_struct *task)
68118 +{
68119 + struct acl_subject_label *curracl;
68120 + __u32 curr_ip;
68121 + struct task_struct *p, *p2;
68122 +
68123 + if (unlikely(!gr_acl_is_enabled()))
68124 + return;
68125 +
68126 + curracl = task->acl;
68127 + curr_ip = task->signal->curr_ip;
68128 +
68129 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68130 + read_lock(&tasklist_lock);
68131 + do_each_thread(p2, p) {
68132 + if (p->signal->curr_ip == curr_ip)
68133 + gr_fake_force_sig(SIGKILL, p);
68134 + } while_each_thread(p2, p);
68135 + read_unlock(&tasklist_lock);
68136 + } else if (curracl->mode & GR_KILLPROC)
68137 + gr_fake_force_sig(SIGKILL, task);
68138 +
68139 + return;
68140 +}
68141 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68142 new file mode 100644
68143 index 0000000..98011b0
68144 --- /dev/null
68145 +++ b/grsecurity/gracl_shm.c
68146 @@ -0,0 +1,40 @@
68147 +#include <linux/kernel.h>
68148 +#include <linux/mm.h>
68149 +#include <linux/sched.h>
68150 +#include <linux/file.h>
68151 +#include <linux/ipc.h>
68152 +#include <linux/gracl.h>
68153 +#include <linux/grsecurity.h>
68154 +#include <linux/grinternal.h>
68155 +
68156 +int
68157 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68158 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68159 +{
68160 + struct task_struct *task;
68161 +
68162 + if (!gr_acl_is_enabled())
68163 + return 1;
68164 +
68165 + rcu_read_lock();
68166 + read_lock(&tasklist_lock);
68167 +
68168 + task = find_task_by_vpid(shm_cprid);
68169 +
68170 + if (unlikely(!task))
68171 + task = find_task_by_vpid(shm_lapid);
68172 +
68173 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68174 + (task_pid_nr(task) == shm_lapid)) &&
68175 + (task->acl->mode & GR_PROTSHM) &&
68176 + (task->acl != current->acl))) {
68177 + read_unlock(&tasklist_lock);
68178 + rcu_read_unlock();
68179 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68180 + return 0;
68181 + }
68182 + read_unlock(&tasklist_lock);
68183 + rcu_read_unlock();
68184 +
68185 + return 1;
68186 +}
68187 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68188 new file mode 100644
68189 index 0000000..bc0be01
68190 --- /dev/null
68191 +++ b/grsecurity/grsec_chdir.c
68192 @@ -0,0 +1,19 @@
68193 +#include <linux/kernel.h>
68194 +#include <linux/sched.h>
68195 +#include <linux/fs.h>
68196 +#include <linux/file.h>
68197 +#include <linux/grsecurity.h>
68198 +#include <linux/grinternal.h>
68199 +
68200 +void
68201 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68202 +{
68203 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68204 + if ((grsec_enable_chdir && grsec_enable_group &&
68205 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68206 + !grsec_enable_group)) {
68207 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68208 + }
68209 +#endif
68210 + return;
68211 +}
68212 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68213 new file mode 100644
68214 index 0000000..bd6e105
68215 --- /dev/null
68216 +++ b/grsecurity/grsec_chroot.c
68217 @@ -0,0 +1,370 @@
68218 +#include <linux/kernel.h>
68219 +#include <linux/module.h>
68220 +#include <linux/sched.h>
68221 +#include <linux/file.h>
68222 +#include <linux/fs.h>
68223 +#include <linux/mount.h>
68224 +#include <linux/types.h>
68225 +#include "../fs/mount.h"
68226 +#include <linux/grsecurity.h>
68227 +#include <linux/grinternal.h>
68228 +
68229 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68230 +static int gr_init_ran;
68231 +#endif
68232 +
68233 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68234 +{
68235 +#ifdef CONFIG_GRKERNSEC
68236 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68237 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68238 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68239 + && gr_init_ran
68240 +#endif
68241 + )
68242 + task->gr_is_chrooted = 1;
68243 + else {
68244 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68245 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68246 + gr_init_ran = 1;
68247 +#endif
68248 + task->gr_is_chrooted = 0;
68249 + }
68250 +
68251 + task->gr_chroot_dentry = path->dentry;
68252 +#endif
68253 + return;
68254 +}
68255 +
68256 +void gr_clear_chroot_entries(struct task_struct *task)
68257 +{
68258 +#ifdef CONFIG_GRKERNSEC
68259 + task->gr_is_chrooted = 0;
68260 + task->gr_chroot_dentry = NULL;
68261 +#endif
68262 + return;
68263 +}
68264 +
68265 +int
68266 +gr_handle_chroot_unix(const pid_t pid)
68267 +{
68268 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68269 + struct task_struct *p;
68270 +
68271 + if (unlikely(!grsec_enable_chroot_unix))
68272 + return 1;
68273 +
68274 + if (likely(!proc_is_chrooted(current)))
68275 + return 1;
68276 +
68277 + rcu_read_lock();
68278 + read_lock(&tasklist_lock);
68279 + p = find_task_by_vpid_unrestricted(pid);
68280 + if (unlikely(p && !have_same_root(current, p))) {
68281 + read_unlock(&tasklist_lock);
68282 + rcu_read_unlock();
68283 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68284 + return 0;
68285 + }
68286 + read_unlock(&tasklist_lock);
68287 + rcu_read_unlock();
68288 +#endif
68289 + return 1;
68290 +}
68291 +
68292 +int
68293 +gr_handle_chroot_nice(void)
68294 +{
68295 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68296 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68297 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68298 + return -EPERM;
68299 + }
68300 +#endif
68301 + return 0;
68302 +}
68303 +
68304 +int
68305 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68306 +{
68307 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68308 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68309 + && proc_is_chrooted(current)) {
68310 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68311 + return -EACCES;
68312 + }
68313 +#endif
68314 + return 0;
68315 +}
68316 +
68317 +int
68318 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68319 +{
68320 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68321 + struct task_struct *p;
68322 + int ret = 0;
68323 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68324 + return ret;
68325 +
68326 + read_lock(&tasklist_lock);
68327 + do_each_pid_task(pid, type, p) {
68328 + if (!have_same_root(current, p)) {
68329 + ret = 1;
68330 + goto out;
68331 + }
68332 + } while_each_pid_task(pid, type, p);
68333 +out:
68334 + read_unlock(&tasklist_lock);
68335 + return ret;
68336 +#endif
68337 + return 0;
68338 +}
68339 +
68340 +int
68341 +gr_pid_is_chrooted(struct task_struct *p)
68342 +{
68343 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68344 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68345 + return 0;
68346 +
68347 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68348 + !have_same_root(current, p)) {
68349 + return 1;
68350 + }
68351 +#endif
68352 + return 0;
68353 +}
68354 +
68355 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68356 +
68357 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68358 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68359 +{
68360 + struct path path, currentroot;
68361 + int ret = 0;
68362 +
68363 + path.dentry = (struct dentry *)u_dentry;
68364 + path.mnt = (struct vfsmount *)u_mnt;
68365 + get_fs_root(current->fs, &currentroot);
68366 + if (path_is_under(&path, &currentroot))
68367 + ret = 1;
68368 + path_put(&currentroot);
68369 +
68370 + return ret;
68371 +}
68372 +#endif
68373 +
68374 +int
68375 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68376 +{
68377 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68378 + if (!grsec_enable_chroot_fchdir)
68379 + return 1;
68380 +
68381 + if (!proc_is_chrooted(current))
68382 + return 1;
68383 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68384 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68385 + return 0;
68386 + }
68387 +#endif
68388 + return 1;
68389 +}
68390 +
68391 +int
68392 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68393 + const time_t shm_createtime)
68394 +{
68395 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68396 + struct task_struct *p;
68397 + time_t starttime;
68398 +
68399 + if (unlikely(!grsec_enable_chroot_shmat))
68400 + return 1;
68401 +
68402 + if (likely(!proc_is_chrooted(current)))
68403 + return 1;
68404 +
68405 + rcu_read_lock();
68406 + read_lock(&tasklist_lock);
68407 +
68408 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68409 + starttime = p->start_time.tv_sec;
68410 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68411 + if (have_same_root(current, p)) {
68412 + goto allow;
68413 + } else {
68414 + read_unlock(&tasklist_lock);
68415 + rcu_read_unlock();
68416 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68417 + return 0;
68418 + }
68419 + }
68420 + /* creator exited, pid reuse, fall through to next check */
68421 + }
68422 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68423 + if (unlikely(!have_same_root(current, p))) {
68424 + read_unlock(&tasklist_lock);
68425 + rcu_read_unlock();
68426 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68427 + return 0;
68428 + }
68429 + }
68430 +
68431 +allow:
68432 + read_unlock(&tasklist_lock);
68433 + rcu_read_unlock();
68434 +#endif
68435 + return 1;
68436 +}
68437 +
68438 +void
68439 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68440 +{
68441 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68442 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68443 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68444 +#endif
68445 + return;
68446 +}
68447 +
68448 +int
68449 +gr_handle_chroot_mknod(const struct dentry *dentry,
68450 + const struct vfsmount *mnt, const int mode)
68451 +{
68452 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68453 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68454 + proc_is_chrooted(current)) {
68455 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68456 + return -EPERM;
68457 + }
68458 +#endif
68459 + return 0;
68460 +}
68461 +
68462 +int
68463 +gr_handle_chroot_mount(const struct dentry *dentry,
68464 + const struct vfsmount *mnt, const char *dev_name)
68465 +{
68466 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68467 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68468 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68469 + return -EPERM;
68470 + }
68471 +#endif
68472 + return 0;
68473 +}
68474 +
68475 +int
68476 +gr_handle_chroot_pivot(void)
68477 +{
68478 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68479 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68480 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68481 + return -EPERM;
68482 + }
68483 +#endif
68484 + return 0;
68485 +}
68486 +
68487 +int
68488 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68489 +{
68490 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68491 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68492 + !gr_is_outside_chroot(dentry, mnt)) {
68493 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68494 + return -EPERM;
68495 + }
68496 +#endif
68497 + return 0;
68498 +}
68499 +
68500 +extern const char *captab_log[];
68501 +extern int captab_log_entries;
68502 +
68503 +int
68504 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68505 +{
68506 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68507 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68508 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68509 + if (cap_raised(chroot_caps, cap)) {
68510 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68511 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68512 + }
68513 + return 0;
68514 + }
68515 + }
68516 +#endif
68517 + return 1;
68518 +}
68519 +
68520 +int
68521 +gr_chroot_is_capable(const int cap)
68522 +{
68523 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68524 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68525 +#endif
68526 + return 1;
68527 +}
68528 +
68529 +int
68530 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68531 +{
68532 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68533 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68534 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68535 + if (cap_raised(chroot_caps, cap)) {
68536 + return 0;
68537 + }
68538 + }
68539 +#endif
68540 + return 1;
68541 +}
68542 +
68543 +int
68544 +gr_chroot_is_capable_nolog(const int cap)
68545 +{
68546 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68547 + return gr_task_chroot_is_capable_nolog(current, cap);
68548 +#endif
68549 + return 1;
68550 +}
68551 +
68552 +int
68553 +gr_handle_chroot_sysctl(const int op)
68554 +{
68555 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68556 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68557 + proc_is_chrooted(current))
68558 + return -EACCES;
68559 +#endif
68560 + return 0;
68561 +}
68562 +
68563 +void
68564 +gr_handle_chroot_chdir(const struct path *path)
68565 +{
68566 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68567 + if (grsec_enable_chroot_chdir)
68568 + set_fs_pwd(current->fs, path);
68569 +#endif
68570 + return;
68571 +}
68572 +
68573 +int
68574 +gr_handle_chroot_chmod(const struct dentry *dentry,
68575 + const struct vfsmount *mnt, const int mode)
68576 +{
68577 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68578 + /* allow chmod +s on directories, but not files */
68579 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68580 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68581 + proc_is_chrooted(current)) {
68582 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68583 + return -EPERM;
68584 + }
68585 +#endif
68586 + return 0;
68587 +}
68588 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68589 new file mode 100644
68590 index 0000000..ce65ceb
68591 --- /dev/null
68592 +++ b/grsecurity/grsec_disabled.c
68593 @@ -0,0 +1,434 @@
68594 +#include <linux/kernel.h>
68595 +#include <linux/module.h>
68596 +#include <linux/sched.h>
68597 +#include <linux/file.h>
68598 +#include <linux/fs.h>
68599 +#include <linux/kdev_t.h>
68600 +#include <linux/net.h>
68601 +#include <linux/in.h>
68602 +#include <linux/ip.h>
68603 +#include <linux/skbuff.h>
68604 +#include <linux/sysctl.h>
68605 +
68606 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68607 +void
68608 +pax_set_initial_flags(struct linux_binprm *bprm)
68609 +{
68610 + return;
68611 +}
68612 +#endif
68613 +
68614 +#ifdef CONFIG_SYSCTL
68615 +__u32
68616 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68617 +{
68618 + return 0;
68619 +}
68620 +#endif
68621 +
68622 +#ifdef CONFIG_TASKSTATS
68623 +int gr_is_taskstats_denied(int pid)
68624 +{
68625 + return 0;
68626 +}
68627 +#endif
68628 +
68629 +int
68630 +gr_acl_is_enabled(void)
68631 +{
68632 + return 0;
68633 +}
68634 +
68635 +void
68636 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68637 +{
68638 + return;
68639 +}
68640 +
68641 +int
68642 +gr_handle_rawio(const struct inode *inode)
68643 +{
68644 + return 0;
68645 +}
68646 +
68647 +void
68648 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68649 +{
68650 + return;
68651 +}
68652 +
68653 +int
68654 +gr_handle_ptrace(struct task_struct *task, const long request)
68655 +{
68656 + return 0;
68657 +}
68658 +
68659 +int
68660 +gr_handle_proc_ptrace(struct task_struct *task)
68661 +{
68662 + return 0;
68663 +}
68664 +
68665 +int
68666 +gr_set_acls(const int type)
68667 +{
68668 + return 0;
68669 +}
68670 +
68671 +int
68672 +gr_check_hidden_task(const struct task_struct *tsk)
68673 +{
68674 + return 0;
68675 +}
68676 +
68677 +int
68678 +gr_check_protected_task(const struct task_struct *task)
68679 +{
68680 + return 0;
68681 +}
68682 +
68683 +int
68684 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68685 +{
68686 + return 0;
68687 +}
68688 +
68689 +void
68690 +gr_copy_label(struct task_struct *tsk)
68691 +{
68692 + return;
68693 +}
68694 +
68695 +void
68696 +gr_set_pax_flags(struct task_struct *task)
68697 +{
68698 + return;
68699 +}
68700 +
68701 +int
68702 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68703 + const int unsafe_share)
68704 +{
68705 + return 0;
68706 +}
68707 +
68708 +void
68709 +gr_handle_delete(const ino_t ino, const dev_t dev)
68710 +{
68711 + return;
68712 +}
68713 +
68714 +void
68715 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68716 +{
68717 + return;
68718 +}
68719 +
68720 +void
68721 +gr_handle_crash(struct task_struct *task, const int sig)
68722 +{
68723 + return;
68724 +}
68725 +
68726 +int
68727 +gr_check_crash_exec(const struct file *filp)
68728 +{
68729 + return 0;
68730 +}
68731 +
68732 +int
68733 +gr_check_crash_uid(const kuid_t uid)
68734 +{
68735 + return 0;
68736 +}
68737 +
68738 +void
68739 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68740 + struct dentry *old_dentry,
68741 + struct dentry *new_dentry,
68742 + struct vfsmount *mnt, const __u8 replace)
68743 +{
68744 + return;
68745 +}
68746 +
68747 +int
68748 +gr_search_socket(const int family, const int type, const int protocol)
68749 +{
68750 + return 1;
68751 +}
68752 +
68753 +int
68754 +gr_search_connectbind(const int mode, const struct socket *sock,
68755 + const struct sockaddr_in *addr)
68756 +{
68757 + return 0;
68758 +}
68759 +
68760 +void
68761 +gr_handle_alertkill(struct task_struct *task)
68762 +{
68763 + return;
68764 +}
68765 +
68766 +__u32
68767 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
68768 +{
68769 + return 1;
68770 +}
68771 +
68772 +__u32
68773 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68774 + const struct vfsmount * mnt)
68775 +{
68776 + return 1;
68777 +}
68778 +
68779 +__u32
68780 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68781 + int acc_mode)
68782 +{
68783 + return 1;
68784 +}
68785 +
68786 +__u32
68787 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68788 +{
68789 + return 1;
68790 +}
68791 +
68792 +__u32
68793 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
68794 +{
68795 + return 1;
68796 +}
68797 +
68798 +int
68799 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
68800 + unsigned int *vm_flags)
68801 +{
68802 + return 1;
68803 +}
68804 +
68805 +__u32
68806 +gr_acl_handle_truncate(const struct dentry * dentry,
68807 + const struct vfsmount * mnt)
68808 +{
68809 + return 1;
68810 +}
68811 +
68812 +__u32
68813 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
68814 +{
68815 + return 1;
68816 +}
68817 +
68818 +__u32
68819 +gr_acl_handle_access(const struct dentry * dentry,
68820 + const struct vfsmount * mnt, const int fmode)
68821 +{
68822 + return 1;
68823 +}
68824 +
68825 +__u32
68826 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
68827 + umode_t *mode)
68828 +{
68829 + return 1;
68830 +}
68831 +
68832 +__u32
68833 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
68834 +{
68835 + return 1;
68836 +}
68837 +
68838 +__u32
68839 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
68840 +{
68841 + return 1;
68842 +}
68843 +
68844 +void
68845 +grsecurity_init(void)
68846 +{
68847 + return;
68848 +}
68849 +
68850 +umode_t gr_acl_umask(void)
68851 +{
68852 + return 0;
68853 +}
68854 +
68855 +__u32
68856 +gr_acl_handle_mknod(const struct dentry * new_dentry,
68857 + const struct dentry * parent_dentry,
68858 + const struct vfsmount * parent_mnt,
68859 + const int mode)
68860 +{
68861 + return 1;
68862 +}
68863 +
68864 +__u32
68865 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
68866 + const struct dentry * parent_dentry,
68867 + const struct vfsmount * parent_mnt)
68868 +{
68869 + return 1;
68870 +}
68871 +
68872 +__u32
68873 +gr_acl_handle_symlink(const struct dentry * new_dentry,
68874 + const struct dentry * parent_dentry,
68875 + const struct vfsmount * parent_mnt, const struct filename *from)
68876 +{
68877 + return 1;
68878 +}
68879 +
68880 +__u32
68881 +gr_acl_handle_link(const struct dentry * new_dentry,
68882 + const struct dentry * parent_dentry,
68883 + const struct vfsmount * parent_mnt,
68884 + const struct dentry * old_dentry,
68885 + const struct vfsmount * old_mnt, const struct filename *to)
68886 +{
68887 + return 1;
68888 +}
68889 +
68890 +int
68891 +gr_acl_handle_rename(const struct dentry *new_dentry,
68892 + const struct dentry *parent_dentry,
68893 + const struct vfsmount *parent_mnt,
68894 + const struct dentry *old_dentry,
68895 + const struct inode *old_parent_inode,
68896 + const struct vfsmount *old_mnt, const struct filename *newname)
68897 +{
68898 + return 0;
68899 +}
68900 +
68901 +int
68902 +gr_acl_handle_filldir(const struct file *file, const char *name,
68903 + const int namelen, const ino_t ino)
68904 +{
68905 + return 1;
68906 +}
68907 +
68908 +int
68909 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68910 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68911 +{
68912 + return 1;
68913 +}
68914 +
68915 +int
68916 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
68917 +{
68918 + return 0;
68919 +}
68920 +
68921 +int
68922 +gr_search_accept(const struct socket *sock)
68923 +{
68924 + return 0;
68925 +}
68926 +
68927 +int
68928 +gr_search_listen(const struct socket *sock)
68929 +{
68930 + return 0;
68931 +}
68932 +
68933 +int
68934 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
68935 +{
68936 + return 0;
68937 +}
68938 +
68939 +__u32
68940 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
68941 +{
68942 + return 1;
68943 +}
68944 +
68945 +__u32
68946 +gr_acl_handle_creat(const struct dentry * dentry,
68947 + const struct dentry * p_dentry,
68948 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
68949 + const int imode)
68950 +{
68951 + return 1;
68952 +}
68953 +
68954 +void
68955 +gr_acl_handle_exit(void)
68956 +{
68957 + return;
68958 +}
68959 +
68960 +int
68961 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
68962 +{
68963 + return 1;
68964 +}
68965 +
68966 +void
68967 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
68968 +{
68969 + return;
68970 +}
68971 +
68972 +int
68973 +gr_acl_handle_procpidmem(const struct task_struct *task)
68974 +{
68975 + return 0;
68976 +}
68977 +
68978 +int
68979 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
68980 +{
68981 + return 0;
68982 +}
68983 +
68984 +int
68985 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
68986 +{
68987 + return 0;
68988 +}
68989 +
68990 +void
68991 +gr_set_kernel_label(struct task_struct *task)
68992 +{
68993 + return;
68994 +}
68995 +
68996 +int
68997 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
68998 +{
68999 + return 0;
69000 +}
69001 +
69002 +int
69003 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69004 +{
69005 + return 0;
69006 +}
69007 +
69008 +int gr_acl_enable_at_secure(void)
69009 +{
69010 + return 0;
69011 +}
69012 +
69013 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69014 +{
69015 + return dentry->d_sb->s_dev;
69016 +}
69017 +
69018 +void gr_put_exec_file(struct task_struct *task)
69019 +{
69020 + return;
69021 +}
69022 +
69023 +EXPORT_SYMBOL(gr_set_kernel_label);
69024 +#ifdef CONFIG_SECURITY
69025 +EXPORT_SYMBOL(gr_check_user_change);
69026 +EXPORT_SYMBOL(gr_check_group_change);
69027 +#endif
69028 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69029 new file mode 100644
69030 index 0000000..387032b
69031 --- /dev/null
69032 +++ b/grsecurity/grsec_exec.c
69033 @@ -0,0 +1,187 @@
69034 +#include <linux/kernel.h>
69035 +#include <linux/sched.h>
69036 +#include <linux/file.h>
69037 +#include <linux/binfmts.h>
69038 +#include <linux/fs.h>
69039 +#include <linux/types.h>
69040 +#include <linux/grdefs.h>
69041 +#include <linux/grsecurity.h>
69042 +#include <linux/grinternal.h>
69043 +#include <linux/capability.h>
69044 +#include <linux/module.h>
69045 +#include <linux/compat.h>
69046 +
69047 +#include <asm/uaccess.h>
69048 +
69049 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69050 +static char gr_exec_arg_buf[132];
69051 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69052 +#endif
69053 +
69054 +struct user_arg_ptr {
69055 +#ifdef CONFIG_COMPAT
69056 + bool is_compat;
69057 +#endif
69058 + union {
69059 + const char __user *const __user *native;
69060 +#ifdef CONFIG_COMPAT
69061 + const compat_uptr_t __user *compat;
69062 +#endif
69063 + } ptr;
69064 +};
69065 +
69066 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69067 +
69068 +void
69069 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69070 +{
69071 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69072 + char *grarg = gr_exec_arg_buf;
69073 + unsigned int i, x, execlen = 0;
69074 + char c;
69075 +
69076 + if (!((grsec_enable_execlog && grsec_enable_group &&
69077 + in_group_p(grsec_audit_gid))
69078 + || (grsec_enable_execlog && !grsec_enable_group)))
69079 + return;
69080 +
69081 + mutex_lock(&gr_exec_arg_mutex);
69082 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69083 +
69084 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69085 + const char __user *p;
69086 + unsigned int len;
69087 +
69088 + p = get_user_arg_ptr(argv, i);
69089 + if (IS_ERR(p))
69090 + goto log;
69091 +
69092 + len = strnlen_user(p, 128 - execlen);
69093 + if (len > 128 - execlen)
69094 + len = 128 - execlen;
69095 + else if (len > 0)
69096 + len--;
69097 + if (copy_from_user(grarg + execlen, p, len))
69098 + goto log;
69099 +
69100 + /* rewrite unprintable characters */
69101 + for (x = 0; x < len; x++) {
69102 + c = *(grarg + execlen + x);
69103 + if (c < 32 || c > 126)
69104 + *(grarg + execlen + x) = ' ';
69105 + }
69106 +
69107 + execlen += len;
69108 + *(grarg + execlen) = ' ';
69109 + *(grarg + execlen + 1) = '\0';
69110 + execlen++;
69111 + }
69112 +
69113 + log:
69114 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69115 + bprm->file->f_path.mnt, grarg);
69116 + mutex_unlock(&gr_exec_arg_mutex);
69117 +#endif
69118 + return;
69119 +}
69120 +
69121 +#ifdef CONFIG_GRKERNSEC
69122 +extern int gr_acl_is_capable(const int cap);
69123 +extern int gr_acl_is_capable_nolog(const int cap);
69124 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69125 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69126 +extern int gr_chroot_is_capable(const int cap);
69127 +extern int gr_chroot_is_capable_nolog(const int cap);
69128 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69129 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69130 +#endif
69131 +
69132 +const char *captab_log[] = {
69133 + "CAP_CHOWN",
69134 + "CAP_DAC_OVERRIDE",
69135 + "CAP_DAC_READ_SEARCH",
69136 + "CAP_FOWNER",
69137 + "CAP_FSETID",
69138 + "CAP_KILL",
69139 + "CAP_SETGID",
69140 + "CAP_SETUID",
69141 + "CAP_SETPCAP",
69142 + "CAP_LINUX_IMMUTABLE",
69143 + "CAP_NET_BIND_SERVICE",
69144 + "CAP_NET_BROADCAST",
69145 + "CAP_NET_ADMIN",
69146 + "CAP_NET_RAW",
69147 + "CAP_IPC_LOCK",
69148 + "CAP_IPC_OWNER",
69149 + "CAP_SYS_MODULE",
69150 + "CAP_SYS_RAWIO",
69151 + "CAP_SYS_CHROOT",
69152 + "CAP_SYS_PTRACE",
69153 + "CAP_SYS_PACCT",
69154 + "CAP_SYS_ADMIN",
69155 + "CAP_SYS_BOOT",
69156 + "CAP_SYS_NICE",
69157 + "CAP_SYS_RESOURCE",
69158 + "CAP_SYS_TIME",
69159 + "CAP_SYS_TTY_CONFIG",
69160 + "CAP_MKNOD",
69161 + "CAP_LEASE",
69162 + "CAP_AUDIT_WRITE",
69163 + "CAP_AUDIT_CONTROL",
69164 + "CAP_SETFCAP",
69165 + "CAP_MAC_OVERRIDE",
69166 + "CAP_MAC_ADMIN",
69167 + "CAP_SYSLOG",
69168 + "CAP_WAKE_ALARM"
69169 +};
69170 +
69171 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69172 +
69173 +int gr_is_capable(const int cap)
69174 +{
69175 +#ifdef CONFIG_GRKERNSEC
69176 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69177 + return 1;
69178 + return 0;
69179 +#else
69180 + return 1;
69181 +#endif
69182 +}
69183 +
69184 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69185 +{
69186 +#ifdef CONFIG_GRKERNSEC
69187 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69188 + return 1;
69189 + return 0;
69190 +#else
69191 + return 1;
69192 +#endif
69193 +}
69194 +
69195 +int gr_is_capable_nolog(const int cap)
69196 +{
69197 +#ifdef CONFIG_GRKERNSEC
69198 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69199 + return 1;
69200 + return 0;
69201 +#else
69202 + return 1;
69203 +#endif
69204 +}
69205 +
69206 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69207 +{
69208 +#ifdef CONFIG_GRKERNSEC
69209 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69210 + return 1;
69211 + return 0;
69212 +#else
69213 + return 1;
69214 +#endif
69215 +}
69216 +
69217 +EXPORT_SYMBOL(gr_is_capable);
69218 +EXPORT_SYMBOL(gr_is_capable_nolog);
69219 +EXPORT_SYMBOL(gr_task_is_capable);
69220 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69221 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69222 new file mode 100644
69223 index 0000000..06cc6ea
69224 --- /dev/null
69225 +++ b/grsecurity/grsec_fifo.c
69226 @@ -0,0 +1,24 @@
69227 +#include <linux/kernel.h>
69228 +#include <linux/sched.h>
69229 +#include <linux/fs.h>
69230 +#include <linux/file.h>
69231 +#include <linux/grinternal.h>
69232 +
69233 +int
69234 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69235 + const struct dentry *dir, const int flag, const int acc_mode)
69236 +{
69237 +#ifdef CONFIG_GRKERNSEC_FIFO
69238 + const struct cred *cred = current_cred();
69239 +
69240 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69241 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69242 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69243 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69244 + if (!inode_permission(dentry->d_inode, acc_mode))
69245 + 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));
69246 + return -EACCES;
69247 + }
69248 +#endif
69249 + return 0;
69250 +}
69251 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69252 new file mode 100644
69253 index 0000000..8ca18bf
69254 --- /dev/null
69255 +++ b/grsecurity/grsec_fork.c
69256 @@ -0,0 +1,23 @@
69257 +#include <linux/kernel.h>
69258 +#include <linux/sched.h>
69259 +#include <linux/grsecurity.h>
69260 +#include <linux/grinternal.h>
69261 +#include <linux/errno.h>
69262 +
69263 +void
69264 +gr_log_forkfail(const int retval)
69265 +{
69266 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69267 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69268 + switch (retval) {
69269 + case -EAGAIN:
69270 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69271 + break;
69272 + case -ENOMEM:
69273 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69274 + break;
69275 + }
69276 + }
69277 +#endif
69278 + return;
69279 +}
69280 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69281 new file mode 100644
69282 index 0000000..99a0cb9
69283 --- /dev/null
69284 +++ b/grsecurity/grsec_init.c
69285 @@ -0,0 +1,283 @@
69286 +#include <linux/kernel.h>
69287 +#include <linux/sched.h>
69288 +#include <linux/mm.h>
69289 +#include <linux/gracl.h>
69290 +#include <linux/slab.h>
69291 +#include <linux/vmalloc.h>
69292 +#include <linux/percpu.h>
69293 +#include <linux/module.h>
69294 +
69295 +int grsec_enable_ptrace_readexec;
69296 +int grsec_enable_setxid;
69297 +int grsec_enable_symlinkown;
69298 +kgid_t grsec_symlinkown_gid;
69299 +int grsec_enable_brute;
69300 +int grsec_enable_link;
69301 +int grsec_enable_dmesg;
69302 +int grsec_enable_harden_ptrace;
69303 +int grsec_enable_fifo;
69304 +int grsec_enable_execlog;
69305 +int grsec_enable_signal;
69306 +int grsec_enable_forkfail;
69307 +int grsec_enable_audit_ptrace;
69308 +int grsec_enable_time;
69309 +int grsec_enable_group;
69310 +kgid_t grsec_audit_gid;
69311 +int grsec_enable_chdir;
69312 +int grsec_enable_mount;
69313 +int grsec_enable_rofs;
69314 +int grsec_deny_new_usb;
69315 +int grsec_enable_chroot_findtask;
69316 +int grsec_enable_chroot_mount;
69317 +int grsec_enable_chroot_shmat;
69318 +int grsec_enable_chroot_fchdir;
69319 +int grsec_enable_chroot_double;
69320 +int grsec_enable_chroot_pivot;
69321 +int grsec_enable_chroot_chdir;
69322 +int grsec_enable_chroot_chmod;
69323 +int grsec_enable_chroot_mknod;
69324 +int grsec_enable_chroot_nice;
69325 +int grsec_enable_chroot_execlog;
69326 +int grsec_enable_chroot_caps;
69327 +int grsec_enable_chroot_sysctl;
69328 +int grsec_enable_chroot_unix;
69329 +int grsec_enable_tpe;
69330 +kgid_t grsec_tpe_gid;
69331 +int grsec_enable_blackhole;
69332 +#ifdef CONFIG_IPV6_MODULE
69333 +EXPORT_SYMBOL(grsec_enable_blackhole);
69334 +#endif
69335 +int grsec_lastack_retries;
69336 +int grsec_enable_tpe_all;
69337 +int grsec_enable_tpe_invert;
69338 +int grsec_enable_socket_all;
69339 +kgid_t grsec_socket_all_gid;
69340 +int grsec_enable_socket_client;
69341 +kgid_t grsec_socket_client_gid;
69342 +int grsec_enable_socket_server;
69343 +kgid_t grsec_socket_server_gid;
69344 +int grsec_resource_logging;
69345 +int grsec_disable_privio;
69346 +int grsec_enable_log_rwxmaps;
69347 +int grsec_lock;
69348 +
69349 +DEFINE_SPINLOCK(grsec_alert_lock);
69350 +unsigned long grsec_alert_wtime = 0;
69351 +unsigned long grsec_alert_fyet = 0;
69352 +
69353 +DEFINE_SPINLOCK(grsec_audit_lock);
69354 +
69355 +DEFINE_RWLOCK(grsec_exec_file_lock);
69356 +
69357 +char *gr_shared_page[4];
69358 +
69359 +char *gr_alert_log_fmt;
69360 +char *gr_audit_log_fmt;
69361 +char *gr_alert_log_buf;
69362 +char *gr_audit_log_buf;
69363 +
69364 +extern struct gr_arg *gr_usermode;
69365 +extern unsigned char *gr_system_salt;
69366 +extern unsigned char *gr_system_sum;
69367 +
69368 +void __init
69369 +grsecurity_init(void)
69370 +{
69371 + int j;
69372 + /* create the per-cpu shared pages */
69373 +
69374 +#ifdef CONFIG_X86
69375 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69376 +#endif
69377 +
69378 + for (j = 0; j < 4; j++) {
69379 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69380 + if (gr_shared_page[j] == NULL) {
69381 + panic("Unable to allocate grsecurity shared page");
69382 + return;
69383 + }
69384 + }
69385 +
69386 + /* allocate log buffers */
69387 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69388 + if (!gr_alert_log_fmt) {
69389 + panic("Unable to allocate grsecurity alert log format buffer");
69390 + return;
69391 + }
69392 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69393 + if (!gr_audit_log_fmt) {
69394 + panic("Unable to allocate grsecurity audit log format buffer");
69395 + return;
69396 + }
69397 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69398 + if (!gr_alert_log_buf) {
69399 + panic("Unable to allocate grsecurity alert log buffer");
69400 + return;
69401 + }
69402 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69403 + if (!gr_audit_log_buf) {
69404 + panic("Unable to allocate grsecurity audit log buffer");
69405 + return;
69406 + }
69407 +
69408 + /* allocate memory for authentication structure */
69409 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69410 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69411 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69412 +
69413 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69414 + panic("Unable to allocate grsecurity authentication structure");
69415 + return;
69416 + }
69417 +
69418 +
69419 +#ifdef CONFIG_GRKERNSEC_IO
69420 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69421 + grsec_disable_privio = 1;
69422 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69423 + grsec_disable_privio = 1;
69424 +#else
69425 + grsec_disable_privio = 0;
69426 +#endif
69427 +#endif
69428 +
69429 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69430 + /* for backward compatibility, tpe_invert always defaults to on if
69431 + enabled in the kernel
69432 + */
69433 + grsec_enable_tpe_invert = 1;
69434 +#endif
69435 +
69436 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69437 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69438 + grsec_lock = 1;
69439 +#endif
69440 +
69441 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69442 + grsec_enable_log_rwxmaps = 1;
69443 +#endif
69444 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69445 + grsec_enable_group = 1;
69446 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69447 +#endif
69448 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69449 + grsec_enable_ptrace_readexec = 1;
69450 +#endif
69451 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69452 + grsec_enable_chdir = 1;
69453 +#endif
69454 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69455 + grsec_enable_harden_ptrace = 1;
69456 +#endif
69457 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69458 + grsec_enable_mount = 1;
69459 +#endif
69460 +#ifdef CONFIG_GRKERNSEC_LINK
69461 + grsec_enable_link = 1;
69462 +#endif
69463 +#ifdef CONFIG_GRKERNSEC_BRUTE
69464 + grsec_enable_brute = 1;
69465 +#endif
69466 +#ifdef CONFIG_GRKERNSEC_DMESG
69467 + grsec_enable_dmesg = 1;
69468 +#endif
69469 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69470 + grsec_enable_blackhole = 1;
69471 + grsec_lastack_retries = 4;
69472 +#endif
69473 +#ifdef CONFIG_GRKERNSEC_FIFO
69474 + grsec_enable_fifo = 1;
69475 +#endif
69476 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69477 + grsec_enable_execlog = 1;
69478 +#endif
69479 +#ifdef CONFIG_GRKERNSEC_SETXID
69480 + grsec_enable_setxid = 1;
69481 +#endif
69482 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69483 + grsec_enable_signal = 1;
69484 +#endif
69485 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69486 + grsec_enable_forkfail = 1;
69487 +#endif
69488 +#ifdef CONFIG_GRKERNSEC_TIME
69489 + grsec_enable_time = 1;
69490 +#endif
69491 +#ifdef CONFIG_GRKERNSEC_RESLOG
69492 + grsec_resource_logging = 1;
69493 +#endif
69494 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69495 + grsec_enable_chroot_findtask = 1;
69496 +#endif
69497 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69498 + grsec_enable_chroot_unix = 1;
69499 +#endif
69500 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69501 + grsec_enable_chroot_mount = 1;
69502 +#endif
69503 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69504 + grsec_enable_chroot_fchdir = 1;
69505 +#endif
69506 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69507 + grsec_enable_chroot_shmat = 1;
69508 +#endif
69509 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69510 + grsec_enable_audit_ptrace = 1;
69511 +#endif
69512 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69513 + grsec_enable_chroot_double = 1;
69514 +#endif
69515 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69516 + grsec_enable_chroot_pivot = 1;
69517 +#endif
69518 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69519 + grsec_enable_chroot_chdir = 1;
69520 +#endif
69521 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69522 + grsec_enable_chroot_chmod = 1;
69523 +#endif
69524 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69525 + grsec_enable_chroot_mknod = 1;
69526 +#endif
69527 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69528 + grsec_enable_chroot_nice = 1;
69529 +#endif
69530 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69531 + grsec_enable_chroot_execlog = 1;
69532 +#endif
69533 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69534 + grsec_enable_chroot_caps = 1;
69535 +#endif
69536 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69537 + grsec_enable_chroot_sysctl = 1;
69538 +#endif
69539 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69540 + grsec_enable_symlinkown = 1;
69541 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69542 +#endif
69543 +#ifdef CONFIG_GRKERNSEC_TPE
69544 + grsec_enable_tpe = 1;
69545 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69546 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69547 + grsec_enable_tpe_all = 1;
69548 +#endif
69549 +#endif
69550 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69551 + grsec_enable_socket_all = 1;
69552 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69553 +#endif
69554 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69555 + grsec_enable_socket_client = 1;
69556 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69557 +#endif
69558 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69559 + grsec_enable_socket_server = 1;
69560 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69561 +#endif
69562 +#endif
69563 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69564 + grsec_deny_new_usb = 1;
69565 +#endif
69566 +
69567 + return;
69568 +}
69569 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69570 new file mode 100644
69571 index 0000000..5e05e20
69572 --- /dev/null
69573 +++ b/grsecurity/grsec_link.c
69574 @@ -0,0 +1,58 @@
69575 +#include <linux/kernel.h>
69576 +#include <linux/sched.h>
69577 +#include <linux/fs.h>
69578 +#include <linux/file.h>
69579 +#include <linux/grinternal.h>
69580 +
69581 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69582 +{
69583 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69584 + const struct inode *link_inode = link->dentry->d_inode;
69585 +
69586 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69587 + /* ignore root-owned links, e.g. /proc/self */
69588 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69589 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69590 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69591 + return 1;
69592 + }
69593 +#endif
69594 + return 0;
69595 +}
69596 +
69597 +int
69598 +gr_handle_follow_link(const struct inode *parent,
69599 + const struct inode *inode,
69600 + const struct dentry *dentry, const struct vfsmount *mnt)
69601 +{
69602 +#ifdef CONFIG_GRKERNSEC_LINK
69603 + const struct cred *cred = current_cred();
69604 +
69605 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69606 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69607 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69608 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69609 + return -EACCES;
69610 + }
69611 +#endif
69612 + return 0;
69613 +}
69614 +
69615 +int
69616 +gr_handle_hardlink(const struct dentry *dentry,
69617 + const struct vfsmount *mnt,
69618 + struct inode *inode, const int mode, const struct filename *to)
69619 +{
69620 +#ifdef CONFIG_GRKERNSEC_LINK
69621 + const struct cred *cred = current_cred();
69622 +
69623 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69624 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69625 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69626 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69627 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69628 + return -EPERM;
69629 + }
69630 +#endif
69631 + return 0;
69632 +}
69633 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69634 new file mode 100644
69635 index 0000000..dbe0a6b
69636 --- /dev/null
69637 +++ b/grsecurity/grsec_log.c
69638 @@ -0,0 +1,341 @@
69639 +#include <linux/kernel.h>
69640 +#include <linux/sched.h>
69641 +#include <linux/file.h>
69642 +#include <linux/tty.h>
69643 +#include <linux/fs.h>
69644 +#include <linux/mm.h>
69645 +#include <linux/grinternal.h>
69646 +
69647 +#ifdef CONFIG_TREE_PREEMPT_RCU
69648 +#define DISABLE_PREEMPT() preempt_disable()
69649 +#define ENABLE_PREEMPT() preempt_enable()
69650 +#else
69651 +#define DISABLE_PREEMPT()
69652 +#define ENABLE_PREEMPT()
69653 +#endif
69654 +
69655 +#define BEGIN_LOCKS(x) \
69656 + DISABLE_PREEMPT(); \
69657 + rcu_read_lock(); \
69658 + read_lock(&tasklist_lock); \
69659 + read_lock(&grsec_exec_file_lock); \
69660 + if (x != GR_DO_AUDIT) \
69661 + spin_lock(&grsec_alert_lock); \
69662 + else \
69663 + spin_lock(&grsec_audit_lock)
69664 +
69665 +#define END_LOCKS(x) \
69666 + if (x != GR_DO_AUDIT) \
69667 + spin_unlock(&grsec_alert_lock); \
69668 + else \
69669 + spin_unlock(&grsec_audit_lock); \
69670 + read_unlock(&grsec_exec_file_lock); \
69671 + read_unlock(&tasklist_lock); \
69672 + rcu_read_unlock(); \
69673 + ENABLE_PREEMPT(); \
69674 + if (x == GR_DONT_AUDIT) \
69675 + gr_handle_alertkill(current)
69676 +
69677 +enum {
69678 + FLOODING,
69679 + NO_FLOODING
69680 +};
69681 +
69682 +extern char *gr_alert_log_fmt;
69683 +extern char *gr_audit_log_fmt;
69684 +extern char *gr_alert_log_buf;
69685 +extern char *gr_audit_log_buf;
69686 +
69687 +static int gr_log_start(int audit)
69688 +{
69689 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
69690 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
69691 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69692 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
69693 + unsigned long curr_secs = get_seconds();
69694 +
69695 + if (audit == GR_DO_AUDIT)
69696 + goto set_fmt;
69697 +
69698 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
69699 + grsec_alert_wtime = curr_secs;
69700 + grsec_alert_fyet = 0;
69701 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
69702 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
69703 + grsec_alert_fyet++;
69704 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
69705 + grsec_alert_wtime = curr_secs;
69706 + grsec_alert_fyet++;
69707 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
69708 + return FLOODING;
69709 + }
69710 + else return FLOODING;
69711 +
69712 +set_fmt:
69713 +#endif
69714 + memset(buf, 0, PAGE_SIZE);
69715 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
69716 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
69717 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69718 + } else if (current->signal->curr_ip) {
69719 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
69720 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
69721 + } else if (gr_acl_is_enabled()) {
69722 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
69723 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69724 + } else {
69725 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
69726 + strcpy(buf, fmt);
69727 + }
69728 +
69729 + return NO_FLOODING;
69730 +}
69731 +
69732 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69733 + __attribute__ ((format (printf, 2, 0)));
69734 +
69735 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69736 +{
69737 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69738 + unsigned int len = strlen(buf);
69739 +
69740 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69741 +
69742 + return;
69743 +}
69744 +
69745 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69746 + __attribute__ ((format (printf, 2, 3)));
69747 +
69748 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69749 +{
69750 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69751 + unsigned int len = strlen(buf);
69752 + va_list ap;
69753 +
69754 + va_start(ap, msg);
69755 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69756 + va_end(ap);
69757 +
69758 + return;
69759 +}
69760 +
69761 +static void gr_log_end(int audit, int append_default)
69762 +{
69763 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69764 + if (append_default) {
69765 + struct task_struct *task = current;
69766 + struct task_struct *parent = task->real_parent;
69767 + const struct cred *cred = __task_cred(task);
69768 + const struct cred *pcred = __task_cred(parent);
69769 + unsigned int len = strlen(buf);
69770 +
69771 + 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));
69772 + }
69773 +
69774 + printk("%s\n", buf);
69775 +
69776 + return;
69777 +}
69778 +
69779 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
69780 +{
69781 + int logtype;
69782 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
69783 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
69784 + void *voidptr = NULL;
69785 + int num1 = 0, num2 = 0;
69786 + unsigned long ulong1 = 0, ulong2 = 0;
69787 + struct dentry *dentry = NULL;
69788 + struct vfsmount *mnt = NULL;
69789 + struct file *file = NULL;
69790 + struct task_struct *task = NULL;
69791 + struct vm_area_struct *vma = NULL;
69792 + const struct cred *cred, *pcred;
69793 + va_list ap;
69794 +
69795 + BEGIN_LOCKS(audit);
69796 + logtype = gr_log_start(audit);
69797 + if (logtype == FLOODING) {
69798 + END_LOCKS(audit);
69799 + return;
69800 + }
69801 + va_start(ap, argtypes);
69802 + switch (argtypes) {
69803 + case GR_TTYSNIFF:
69804 + task = va_arg(ap, struct task_struct *);
69805 + 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));
69806 + break;
69807 + case GR_SYSCTL_HIDDEN:
69808 + str1 = va_arg(ap, char *);
69809 + gr_log_middle_varargs(audit, msg, result, str1);
69810 + break;
69811 + case GR_RBAC:
69812 + dentry = va_arg(ap, struct dentry *);
69813 + mnt = va_arg(ap, struct vfsmount *);
69814 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
69815 + break;
69816 + case GR_RBAC_STR:
69817 + dentry = va_arg(ap, struct dentry *);
69818 + mnt = va_arg(ap, struct vfsmount *);
69819 + str1 = va_arg(ap, char *);
69820 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
69821 + break;
69822 + case GR_STR_RBAC:
69823 + str1 = va_arg(ap, char *);
69824 + dentry = va_arg(ap, struct dentry *);
69825 + mnt = va_arg(ap, struct vfsmount *);
69826 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
69827 + break;
69828 + case GR_RBAC_MODE2:
69829 + dentry = va_arg(ap, struct dentry *);
69830 + mnt = va_arg(ap, struct vfsmount *);
69831 + str1 = va_arg(ap, char *);
69832 + str2 = va_arg(ap, char *);
69833 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
69834 + break;
69835 + case GR_RBAC_MODE3:
69836 + dentry = va_arg(ap, struct dentry *);
69837 + mnt = va_arg(ap, struct vfsmount *);
69838 + str1 = va_arg(ap, char *);
69839 + str2 = va_arg(ap, char *);
69840 + str3 = va_arg(ap, char *);
69841 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
69842 + break;
69843 + case GR_FILENAME:
69844 + dentry = va_arg(ap, struct dentry *);
69845 + mnt = va_arg(ap, struct vfsmount *);
69846 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
69847 + break;
69848 + case GR_STR_FILENAME:
69849 + str1 = va_arg(ap, char *);
69850 + dentry = va_arg(ap, struct dentry *);
69851 + mnt = va_arg(ap, struct vfsmount *);
69852 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
69853 + break;
69854 + case GR_FILENAME_STR:
69855 + dentry = va_arg(ap, struct dentry *);
69856 + mnt = va_arg(ap, struct vfsmount *);
69857 + str1 = va_arg(ap, char *);
69858 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
69859 + break;
69860 + case GR_FILENAME_TWO_INT:
69861 + dentry = va_arg(ap, struct dentry *);
69862 + mnt = va_arg(ap, struct vfsmount *);
69863 + num1 = va_arg(ap, int);
69864 + num2 = va_arg(ap, int);
69865 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
69866 + break;
69867 + case GR_FILENAME_TWO_INT_STR:
69868 + dentry = va_arg(ap, struct dentry *);
69869 + mnt = va_arg(ap, struct vfsmount *);
69870 + num1 = va_arg(ap, int);
69871 + num2 = va_arg(ap, int);
69872 + str1 = va_arg(ap, char *);
69873 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
69874 + break;
69875 + case GR_TEXTREL:
69876 + file = va_arg(ap, struct file *);
69877 + ulong1 = va_arg(ap, unsigned long);
69878 + ulong2 = va_arg(ap, unsigned long);
69879 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
69880 + break;
69881 + case GR_PTRACE:
69882 + task = va_arg(ap, struct task_struct *);
69883 + 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));
69884 + break;
69885 + case GR_RESOURCE:
69886 + task = va_arg(ap, struct task_struct *);
69887 + cred = __task_cred(task);
69888 + pcred = __task_cred(task->real_parent);
69889 + ulong1 = va_arg(ap, unsigned long);
69890 + str1 = va_arg(ap, char *);
69891 + ulong2 = va_arg(ap, unsigned long);
69892 + 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));
69893 + break;
69894 + case GR_CAP:
69895 + task = va_arg(ap, struct task_struct *);
69896 + cred = __task_cred(task);
69897 + pcred = __task_cred(task->real_parent);
69898 + str1 = va_arg(ap, char *);
69899 + 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));
69900 + break;
69901 + case GR_SIG:
69902 + str1 = va_arg(ap, char *);
69903 + voidptr = va_arg(ap, void *);
69904 + gr_log_middle_varargs(audit, msg, str1, voidptr);
69905 + break;
69906 + case GR_SIG2:
69907 + task = va_arg(ap, struct task_struct *);
69908 + cred = __task_cred(task);
69909 + pcred = __task_cred(task->real_parent);
69910 + num1 = va_arg(ap, int);
69911 + 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));
69912 + break;
69913 + case GR_CRASH1:
69914 + task = va_arg(ap, struct task_struct *);
69915 + cred = __task_cred(task);
69916 + pcred = __task_cred(task->real_parent);
69917 + ulong1 = va_arg(ap, unsigned long);
69918 + 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);
69919 + break;
69920 + case GR_CRASH2:
69921 + task = va_arg(ap, struct task_struct *);
69922 + cred = __task_cred(task);
69923 + pcred = __task_cred(task->real_parent);
69924 + ulong1 = va_arg(ap, unsigned long);
69925 + 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);
69926 + break;
69927 + case GR_RWXMAP:
69928 + file = va_arg(ap, struct file *);
69929 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
69930 + break;
69931 + case GR_RWXMAPVMA:
69932 + vma = va_arg(ap, struct vm_area_struct *);
69933 + if (vma->vm_file)
69934 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
69935 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
69936 + str1 = "<stack>";
69937 + else if (vma->vm_start <= current->mm->brk &&
69938 + vma->vm_end >= current->mm->start_brk)
69939 + str1 = "<heap>";
69940 + else
69941 + str1 = "<anonymous mapping>";
69942 + gr_log_middle_varargs(audit, msg, str1);
69943 + break;
69944 + case GR_PSACCT:
69945 + {
69946 + unsigned int wday, cday;
69947 + __u8 whr, chr;
69948 + __u8 wmin, cmin;
69949 + __u8 wsec, csec;
69950 + char cur_tty[64] = { 0 };
69951 + char parent_tty[64] = { 0 };
69952 +
69953 + task = va_arg(ap, struct task_struct *);
69954 + wday = va_arg(ap, unsigned int);
69955 + cday = va_arg(ap, unsigned int);
69956 + whr = va_arg(ap, int);
69957 + chr = va_arg(ap, int);
69958 + wmin = va_arg(ap, int);
69959 + cmin = va_arg(ap, int);
69960 + wsec = va_arg(ap, int);
69961 + csec = va_arg(ap, int);
69962 + ulong1 = va_arg(ap, unsigned long);
69963 + cred = __task_cred(task);
69964 + pcred = __task_cred(task->real_parent);
69965 +
69966 + 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));
69967 + }
69968 + break;
69969 + default:
69970 + gr_log_middle(audit, msg, ap);
69971 + }
69972 + va_end(ap);
69973 + // these don't need DEFAULTSECARGS printed on the end
69974 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
69975 + gr_log_end(audit, 0);
69976 + else
69977 + gr_log_end(audit, 1);
69978 + END_LOCKS(audit);
69979 +}
69980 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
69981 new file mode 100644
69982 index 0000000..f536303
69983 --- /dev/null
69984 +++ b/grsecurity/grsec_mem.c
69985 @@ -0,0 +1,40 @@
69986 +#include <linux/kernel.h>
69987 +#include <linux/sched.h>
69988 +#include <linux/mm.h>
69989 +#include <linux/mman.h>
69990 +#include <linux/grinternal.h>
69991 +
69992 +void
69993 +gr_handle_ioperm(void)
69994 +{
69995 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
69996 + return;
69997 +}
69998 +
69999 +void
70000 +gr_handle_iopl(void)
70001 +{
70002 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70003 + return;
70004 +}
70005 +
70006 +void
70007 +gr_handle_mem_readwrite(u64 from, u64 to)
70008 +{
70009 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70010 + return;
70011 +}
70012 +
70013 +void
70014 +gr_handle_vm86(void)
70015 +{
70016 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70017 + return;
70018 +}
70019 +
70020 +void
70021 +gr_log_badprocpid(const char *entry)
70022 +{
70023 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70024 + return;
70025 +}
70026 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70027 new file mode 100644
70028 index 0000000..2131422
70029 --- /dev/null
70030 +++ b/grsecurity/grsec_mount.c
70031 @@ -0,0 +1,62 @@
70032 +#include <linux/kernel.h>
70033 +#include <linux/sched.h>
70034 +#include <linux/mount.h>
70035 +#include <linux/grsecurity.h>
70036 +#include <linux/grinternal.h>
70037 +
70038 +void
70039 +gr_log_remount(const char *devname, const int retval)
70040 +{
70041 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70042 + if (grsec_enable_mount && (retval >= 0))
70043 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70044 +#endif
70045 + return;
70046 +}
70047 +
70048 +void
70049 +gr_log_unmount(const char *devname, const int retval)
70050 +{
70051 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70052 + if (grsec_enable_mount && (retval >= 0))
70053 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70054 +#endif
70055 + return;
70056 +}
70057 +
70058 +void
70059 +gr_log_mount(const char *from, const char *to, const int retval)
70060 +{
70061 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70062 + if (grsec_enable_mount && (retval >= 0))
70063 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70064 +#endif
70065 + return;
70066 +}
70067 +
70068 +int
70069 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70070 +{
70071 +#ifdef CONFIG_GRKERNSEC_ROFS
70072 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70073 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70074 + return -EPERM;
70075 + } else
70076 + return 0;
70077 +#endif
70078 + return 0;
70079 +}
70080 +
70081 +int
70082 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70083 +{
70084 +#ifdef CONFIG_GRKERNSEC_ROFS
70085 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70086 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70087 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70088 + return -EPERM;
70089 + } else
70090 + return 0;
70091 +#endif
70092 + return 0;
70093 +}
70094 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70095 new file mode 100644
70096 index 0000000..6ee9d50
70097 --- /dev/null
70098 +++ b/grsecurity/grsec_pax.c
70099 @@ -0,0 +1,45 @@
70100 +#include <linux/kernel.h>
70101 +#include <linux/sched.h>
70102 +#include <linux/mm.h>
70103 +#include <linux/file.h>
70104 +#include <linux/grinternal.h>
70105 +#include <linux/grsecurity.h>
70106 +
70107 +void
70108 +gr_log_textrel(struct vm_area_struct * vma)
70109 +{
70110 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70111 + if (grsec_enable_log_rwxmaps)
70112 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70113 +#endif
70114 + return;
70115 +}
70116 +
70117 +void gr_log_ptgnustack(struct file *file)
70118 +{
70119 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70120 + if (grsec_enable_log_rwxmaps)
70121 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70122 +#endif
70123 + return;
70124 +}
70125 +
70126 +void
70127 +gr_log_rwxmmap(struct file *file)
70128 +{
70129 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70130 + if (grsec_enable_log_rwxmaps)
70131 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70132 +#endif
70133 + return;
70134 +}
70135 +
70136 +void
70137 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70138 +{
70139 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70140 + if (grsec_enable_log_rwxmaps)
70141 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70142 +#endif
70143 + return;
70144 +}
70145 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70146 new file mode 100644
70147 index 0000000..f7f29aa
70148 --- /dev/null
70149 +++ b/grsecurity/grsec_ptrace.c
70150 @@ -0,0 +1,30 @@
70151 +#include <linux/kernel.h>
70152 +#include <linux/sched.h>
70153 +#include <linux/grinternal.h>
70154 +#include <linux/security.h>
70155 +
70156 +void
70157 +gr_audit_ptrace(struct task_struct *task)
70158 +{
70159 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70160 + if (grsec_enable_audit_ptrace)
70161 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70162 +#endif
70163 + return;
70164 +}
70165 +
70166 +int
70167 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70168 +{
70169 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70170 + const struct dentry *dentry = file->f_path.dentry;
70171 + const struct vfsmount *mnt = file->f_path.mnt;
70172 +
70173 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70174 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70175 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70176 + return -EACCES;
70177 + }
70178 +#endif
70179 + return 0;
70180 +}
70181 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70182 new file mode 100644
70183 index 0000000..4e29cc7
70184 --- /dev/null
70185 +++ b/grsecurity/grsec_sig.c
70186 @@ -0,0 +1,246 @@
70187 +#include <linux/kernel.h>
70188 +#include <linux/sched.h>
70189 +#include <linux/fs.h>
70190 +#include <linux/delay.h>
70191 +#include <linux/grsecurity.h>
70192 +#include <linux/grinternal.h>
70193 +#include <linux/hardirq.h>
70194 +
70195 +char *signames[] = {
70196 + [SIGSEGV] = "Segmentation fault",
70197 + [SIGILL] = "Illegal instruction",
70198 + [SIGABRT] = "Abort",
70199 + [SIGBUS] = "Invalid alignment/Bus error"
70200 +};
70201 +
70202 +void
70203 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70204 +{
70205 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70206 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70207 + (sig == SIGABRT) || (sig == SIGBUS))) {
70208 + if (task_pid_nr(t) == task_pid_nr(current)) {
70209 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70210 + } else {
70211 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70212 + }
70213 + }
70214 +#endif
70215 + return;
70216 +}
70217 +
70218 +int
70219 +gr_handle_signal(const struct task_struct *p, const int sig)
70220 +{
70221 +#ifdef CONFIG_GRKERNSEC
70222 + /* ignore the 0 signal for protected task checks */
70223 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70224 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70225 + return -EPERM;
70226 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70227 + return -EPERM;
70228 + }
70229 +#endif
70230 + return 0;
70231 +}
70232 +
70233 +#ifdef CONFIG_GRKERNSEC
70234 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70235 +
70236 +int gr_fake_force_sig(int sig, struct task_struct *t)
70237 +{
70238 + unsigned long int flags;
70239 + int ret, blocked, ignored;
70240 + struct k_sigaction *action;
70241 +
70242 + spin_lock_irqsave(&t->sighand->siglock, flags);
70243 + action = &t->sighand->action[sig-1];
70244 + ignored = action->sa.sa_handler == SIG_IGN;
70245 + blocked = sigismember(&t->blocked, sig);
70246 + if (blocked || ignored) {
70247 + action->sa.sa_handler = SIG_DFL;
70248 + if (blocked) {
70249 + sigdelset(&t->blocked, sig);
70250 + recalc_sigpending_and_wake(t);
70251 + }
70252 + }
70253 + if (action->sa.sa_handler == SIG_DFL)
70254 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70255 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70256 +
70257 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70258 +
70259 + return ret;
70260 +}
70261 +#endif
70262 +
70263 +#ifdef CONFIG_GRKERNSEC_BRUTE
70264 +#define GR_USER_BAN_TIME (15 * 60)
70265 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70266 +
70267 +static int __get_dumpable(unsigned long mm_flags)
70268 +{
70269 + int ret;
70270 +
70271 + ret = mm_flags & MMF_DUMPABLE_MASK;
70272 + return (ret >= 2) ? 2 : ret;
70273 +}
70274 +#endif
70275 +
70276 +void gr_handle_brute_attach(unsigned long mm_flags)
70277 +{
70278 +#ifdef CONFIG_GRKERNSEC_BRUTE
70279 + struct task_struct *p = current;
70280 + kuid_t uid = GLOBAL_ROOT_UID;
70281 + int daemon = 0;
70282 +
70283 + if (!grsec_enable_brute)
70284 + return;
70285 +
70286 + rcu_read_lock();
70287 + read_lock(&tasklist_lock);
70288 + read_lock(&grsec_exec_file_lock);
70289 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70290 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70291 + p->real_parent->brute = 1;
70292 + daemon = 1;
70293 + } else {
70294 + const struct cred *cred = __task_cred(p), *cred2;
70295 + struct task_struct *tsk, *tsk2;
70296 +
70297 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70298 + struct user_struct *user;
70299 +
70300 + uid = cred->uid;
70301 +
70302 + /* this is put upon execution past expiration */
70303 + user = find_user(uid);
70304 + if (user == NULL)
70305 + goto unlock;
70306 + user->suid_banned = 1;
70307 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70308 + if (user->suid_ban_expires == ~0UL)
70309 + user->suid_ban_expires--;
70310 +
70311 + /* only kill other threads of the same binary, from the same user */
70312 + do_each_thread(tsk2, tsk) {
70313 + cred2 = __task_cred(tsk);
70314 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70315 + gr_fake_force_sig(SIGKILL, tsk);
70316 + } while_each_thread(tsk2, tsk);
70317 + }
70318 + }
70319 +unlock:
70320 + read_unlock(&grsec_exec_file_lock);
70321 + read_unlock(&tasklist_lock);
70322 + rcu_read_unlock();
70323 +
70324 + if (gr_is_global_nonroot(uid))
70325 + 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);
70326 + else if (daemon)
70327 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70328 +
70329 +#endif
70330 + return;
70331 +}
70332 +
70333 +void gr_handle_brute_check(void)
70334 +{
70335 +#ifdef CONFIG_GRKERNSEC_BRUTE
70336 + struct task_struct *p = current;
70337 +
70338 + if (unlikely(p->brute)) {
70339 + if (!grsec_enable_brute)
70340 + p->brute = 0;
70341 + else if (time_before(get_seconds(), p->brute_expires))
70342 + msleep(30 * 1000);
70343 + }
70344 +#endif
70345 + return;
70346 +}
70347 +
70348 +void gr_handle_kernel_exploit(void)
70349 +{
70350 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70351 + const struct cred *cred;
70352 + struct task_struct *tsk, *tsk2;
70353 + struct user_struct *user;
70354 + kuid_t uid;
70355 +
70356 + if (in_irq() || in_serving_softirq() || in_nmi())
70357 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70358 +
70359 + uid = current_uid();
70360 +
70361 + if (gr_is_global_root(uid))
70362 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70363 + else {
70364 + /* kill all the processes of this user, hold a reference
70365 + to their creds struct, and prevent them from creating
70366 + another process until system reset
70367 + */
70368 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70369 + GR_GLOBAL_UID(uid));
70370 + /* we intentionally leak this ref */
70371 + user = get_uid(current->cred->user);
70372 + if (user)
70373 + user->kernel_banned = 1;
70374 +
70375 + /* kill all processes of this user */
70376 + read_lock(&tasklist_lock);
70377 + do_each_thread(tsk2, tsk) {
70378 + cred = __task_cred(tsk);
70379 + if (uid_eq(cred->uid, uid))
70380 + gr_fake_force_sig(SIGKILL, tsk);
70381 + } while_each_thread(tsk2, tsk);
70382 + read_unlock(&tasklist_lock);
70383 + }
70384 +#endif
70385 +}
70386 +
70387 +#ifdef CONFIG_GRKERNSEC_BRUTE
70388 +static bool suid_ban_expired(struct user_struct *user)
70389 +{
70390 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70391 + user->suid_banned = 0;
70392 + user->suid_ban_expires = 0;
70393 + free_uid(user);
70394 + return true;
70395 + }
70396 +
70397 + return false;
70398 +}
70399 +#endif
70400 +
70401 +int gr_process_kernel_exec_ban(void)
70402 +{
70403 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70404 + if (unlikely(current->cred->user->kernel_banned))
70405 + return -EPERM;
70406 +#endif
70407 + return 0;
70408 +}
70409 +
70410 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70411 +{
70412 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70413 + if (unlikely(user->kernel_banned))
70414 + gr_fake_force_sig(SIGKILL, current);
70415 +#endif
70416 + return 0;
70417 +}
70418 +
70419 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70420 +{
70421 +#ifdef CONFIG_GRKERNSEC_BRUTE
70422 + struct user_struct *user = current->cred->user;
70423 + if (unlikely(user->suid_banned)) {
70424 + if (suid_ban_expired(user))
70425 + return 0;
70426 + /* disallow execution of suid binaries only */
70427 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70428 + return -EPERM;
70429 + }
70430 +#endif
70431 + return 0;
70432 +}
70433 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70434 new file mode 100644
70435 index 0000000..4030d57
70436 --- /dev/null
70437 +++ b/grsecurity/grsec_sock.c
70438 @@ -0,0 +1,244 @@
70439 +#include <linux/kernel.h>
70440 +#include <linux/module.h>
70441 +#include <linux/sched.h>
70442 +#include <linux/file.h>
70443 +#include <linux/net.h>
70444 +#include <linux/in.h>
70445 +#include <linux/ip.h>
70446 +#include <net/sock.h>
70447 +#include <net/inet_sock.h>
70448 +#include <linux/grsecurity.h>
70449 +#include <linux/grinternal.h>
70450 +#include <linux/gracl.h>
70451 +
70452 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70453 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70454 +
70455 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70456 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70457 +
70458 +#ifdef CONFIG_UNIX_MODULE
70459 +EXPORT_SYMBOL(gr_acl_handle_unix);
70460 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70461 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70462 +EXPORT_SYMBOL(gr_handle_create);
70463 +#endif
70464 +
70465 +#ifdef CONFIG_GRKERNSEC
70466 +#define gr_conn_table_size 32749
70467 +struct conn_table_entry {
70468 + struct conn_table_entry *next;
70469 + struct signal_struct *sig;
70470 +};
70471 +
70472 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70473 +DEFINE_SPINLOCK(gr_conn_table_lock);
70474 +
70475 +extern const char * gr_socktype_to_name(unsigned char type);
70476 +extern const char * gr_proto_to_name(unsigned char proto);
70477 +extern const char * gr_sockfamily_to_name(unsigned char family);
70478 +
70479 +static __inline__ int
70480 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70481 +{
70482 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70483 +}
70484 +
70485 +static __inline__ int
70486 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70487 + __u16 sport, __u16 dport)
70488 +{
70489 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70490 + sig->gr_sport == sport && sig->gr_dport == dport))
70491 + return 1;
70492 + else
70493 + return 0;
70494 +}
70495 +
70496 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70497 +{
70498 + struct conn_table_entry **match;
70499 + unsigned int index;
70500 +
70501 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70502 + sig->gr_sport, sig->gr_dport,
70503 + gr_conn_table_size);
70504 +
70505 + newent->sig = sig;
70506 +
70507 + match = &gr_conn_table[index];
70508 + newent->next = *match;
70509 + *match = newent;
70510 +
70511 + return;
70512 +}
70513 +
70514 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70515 +{
70516 + struct conn_table_entry *match, *last = NULL;
70517 + unsigned int index;
70518 +
70519 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70520 + sig->gr_sport, sig->gr_dport,
70521 + gr_conn_table_size);
70522 +
70523 + match = gr_conn_table[index];
70524 + while (match && !conn_match(match->sig,
70525 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70526 + sig->gr_dport)) {
70527 + last = match;
70528 + match = match->next;
70529 + }
70530 +
70531 + if (match) {
70532 + if (last)
70533 + last->next = match->next;
70534 + else
70535 + gr_conn_table[index] = NULL;
70536 + kfree(match);
70537 + }
70538 +
70539 + return;
70540 +}
70541 +
70542 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70543 + __u16 sport, __u16 dport)
70544 +{
70545 + struct conn_table_entry *match;
70546 + unsigned int index;
70547 +
70548 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70549 +
70550 + match = gr_conn_table[index];
70551 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70552 + match = match->next;
70553 +
70554 + if (match)
70555 + return match->sig;
70556 + else
70557 + return NULL;
70558 +}
70559 +
70560 +#endif
70561 +
70562 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70563 +{
70564 +#ifdef CONFIG_GRKERNSEC
70565 + struct signal_struct *sig = task->signal;
70566 + struct conn_table_entry *newent;
70567 +
70568 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70569 + if (newent == NULL)
70570 + return;
70571 + /* no bh lock needed since we are called with bh disabled */
70572 + spin_lock(&gr_conn_table_lock);
70573 + gr_del_task_from_ip_table_nolock(sig);
70574 + sig->gr_saddr = inet->inet_rcv_saddr;
70575 + sig->gr_daddr = inet->inet_daddr;
70576 + sig->gr_sport = inet->inet_sport;
70577 + sig->gr_dport = inet->inet_dport;
70578 + gr_add_to_task_ip_table_nolock(sig, newent);
70579 + spin_unlock(&gr_conn_table_lock);
70580 +#endif
70581 + return;
70582 +}
70583 +
70584 +void gr_del_task_from_ip_table(struct task_struct *task)
70585 +{
70586 +#ifdef CONFIG_GRKERNSEC
70587 + spin_lock_bh(&gr_conn_table_lock);
70588 + gr_del_task_from_ip_table_nolock(task->signal);
70589 + spin_unlock_bh(&gr_conn_table_lock);
70590 +#endif
70591 + return;
70592 +}
70593 +
70594 +void
70595 +gr_attach_curr_ip(const struct sock *sk)
70596 +{
70597 +#ifdef CONFIG_GRKERNSEC
70598 + struct signal_struct *p, *set;
70599 + const struct inet_sock *inet = inet_sk(sk);
70600 +
70601 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70602 + return;
70603 +
70604 + set = current->signal;
70605 +
70606 + spin_lock_bh(&gr_conn_table_lock);
70607 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70608 + inet->inet_dport, inet->inet_sport);
70609 + if (unlikely(p != NULL)) {
70610 + set->curr_ip = p->curr_ip;
70611 + set->used_accept = 1;
70612 + gr_del_task_from_ip_table_nolock(p);
70613 + spin_unlock_bh(&gr_conn_table_lock);
70614 + return;
70615 + }
70616 + spin_unlock_bh(&gr_conn_table_lock);
70617 +
70618 + set->curr_ip = inet->inet_daddr;
70619 + set->used_accept = 1;
70620 +#endif
70621 + return;
70622 +}
70623 +
70624 +int
70625 +gr_handle_sock_all(const int family, const int type, const int protocol)
70626 +{
70627 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70628 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70629 + (family != AF_UNIX)) {
70630 + if (family == AF_INET)
70631 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70632 + else
70633 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70634 + return -EACCES;
70635 + }
70636 +#endif
70637 + return 0;
70638 +}
70639 +
70640 +int
70641 +gr_handle_sock_server(const struct sockaddr *sck)
70642 +{
70643 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70644 + if (grsec_enable_socket_server &&
70645 + in_group_p(grsec_socket_server_gid) &&
70646 + sck && (sck->sa_family != AF_UNIX) &&
70647 + (sck->sa_family != AF_LOCAL)) {
70648 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70649 + return -EACCES;
70650 + }
70651 +#endif
70652 + return 0;
70653 +}
70654 +
70655 +int
70656 +gr_handle_sock_server_other(const struct sock *sck)
70657 +{
70658 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70659 + if (grsec_enable_socket_server &&
70660 + in_group_p(grsec_socket_server_gid) &&
70661 + sck && (sck->sk_family != AF_UNIX) &&
70662 + (sck->sk_family != AF_LOCAL)) {
70663 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70664 + return -EACCES;
70665 + }
70666 +#endif
70667 + return 0;
70668 +}
70669 +
70670 +int
70671 +gr_handle_sock_client(const struct sockaddr *sck)
70672 +{
70673 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70674 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70675 + sck && (sck->sa_family != AF_UNIX) &&
70676 + (sck->sa_family != AF_LOCAL)) {
70677 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
70678 + return -EACCES;
70679 + }
70680 +#endif
70681 + return 0;
70682 +}
70683 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
70684 new file mode 100644
70685 index 0000000..a147ae7
70686 --- /dev/null
70687 +++ b/grsecurity/grsec_sysctl.c
70688 @@ -0,0 +1,470 @@
70689 +#include <linux/kernel.h>
70690 +#include <linux/sched.h>
70691 +#include <linux/sysctl.h>
70692 +#include <linux/grsecurity.h>
70693 +#include <linux/grinternal.h>
70694 +
70695 +int
70696 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
70697 +{
70698 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70699 + if (dirname == NULL || name == NULL)
70700 + return 0;
70701 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
70702 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
70703 + return -EACCES;
70704 + }
70705 +#endif
70706 + return 0;
70707 +}
70708 +
70709 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
70710 +static int __maybe_unused __read_only one = 1;
70711 +#endif
70712 +
70713 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
70714 + defined(CONFIG_GRKERNSEC_DENYUSB)
70715 +struct ctl_table grsecurity_table[] = {
70716 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70717 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
70718 +#ifdef CONFIG_GRKERNSEC_IO
70719 + {
70720 + .procname = "disable_priv_io",
70721 + .data = &grsec_disable_privio,
70722 + .maxlen = sizeof(int),
70723 + .mode = 0600,
70724 + .proc_handler = &proc_dointvec,
70725 + },
70726 +#endif
70727 +#endif
70728 +#ifdef CONFIG_GRKERNSEC_LINK
70729 + {
70730 + .procname = "linking_restrictions",
70731 + .data = &grsec_enable_link,
70732 + .maxlen = sizeof(int),
70733 + .mode = 0600,
70734 + .proc_handler = &proc_dointvec,
70735 + },
70736 +#endif
70737 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70738 + {
70739 + .procname = "enforce_symlinksifowner",
70740 + .data = &grsec_enable_symlinkown,
70741 + .maxlen = sizeof(int),
70742 + .mode = 0600,
70743 + .proc_handler = &proc_dointvec,
70744 + },
70745 + {
70746 + .procname = "symlinkown_gid",
70747 + .data = &grsec_symlinkown_gid,
70748 + .maxlen = sizeof(int),
70749 + .mode = 0600,
70750 + .proc_handler = &proc_dointvec,
70751 + },
70752 +#endif
70753 +#ifdef CONFIG_GRKERNSEC_BRUTE
70754 + {
70755 + .procname = "deter_bruteforce",
70756 + .data = &grsec_enable_brute,
70757 + .maxlen = sizeof(int),
70758 + .mode = 0600,
70759 + .proc_handler = &proc_dointvec,
70760 + },
70761 +#endif
70762 +#ifdef CONFIG_GRKERNSEC_FIFO
70763 + {
70764 + .procname = "fifo_restrictions",
70765 + .data = &grsec_enable_fifo,
70766 + .maxlen = sizeof(int),
70767 + .mode = 0600,
70768 + .proc_handler = &proc_dointvec,
70769 + },
70770 +#endif
70771 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70772 + {
70773 + .procname = "ptrace_readexec",
70774 + .data = &grsec_enable_ptrace_readexec,
70775 + .maxlen = sizeof(int),
70776 + .mode = 0600,
70777 + .proc_handler = &proc_dointvec,
70778 + },
70779 +#endif
70780 +#ifdef CONFIG_GRKERNSEC_SETXID
70781 + {
70782 + .procname = "consistent_setxid",
70783 + .data = &grsec_enable_setxid,
70784 + .maxlen = sizeof(int),
70785 + .mode = 0600,
70786 + .proc_handler = &proc_dointvec,
70787 + },
70788 +#endif
70789 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70790 + {
70791 + .procname = "ip_blackhole",
70792 + .data = &grsec_enable_blackhole,
70793 + .maxlen = sizeof(int),
70794 + .mode = 0600,
70795 + .proc_handler = &proc_dointvec,
70796 + },
70797 + {
70798 + .procname = "lastack_retries",
70799 + .data = &grsec_lastack_retries,
70800 + .maxlen = sizeof(int),
70801 + .mode = 0600,
70802 + .proc_handler = &proc_dointvec,
70803 + },
70804 +#endif
70805 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70806 + {
70807 + .procname = "exec_logging",
70808 + .data = &grsec_enable_execlog,
70809 + .maxlen = sizeof(int),
70810 + .mode = 0600,
70811 + .proc_handler = &proc_dointvec,
70812 + },
70813 +#endif
70814 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70815 + {
70816 + .procname = "rwxmap_logging",
70817 + .data = &grsec_enable_log_rwxmaps,
70818 + .maxlen = sizeof(int),
70819 + .mode = 0600,
70820 + .proc_handler = &proc_dointvec,
70821 + },
70822 +#endif
70823 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70824 + {
70825 + .procname = "signal_logging",
70826 + .data = &grsec_enable_signal,
70827 + .maxlen = sizeof(int),
70828 + .mode = 0600,
70829 + .proc_handler = &proc_dointvec,
70830 + },
70831 +#endif
70832 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70833 + {
70834 + .procname = "forkfail_logging",
70835 + .data = &grsec_enable_forkfail,
70836 + .maxlen = sizeof(int),
70837 + .mode = 0600,
70838 + .proc_handler = &proc_dointvec,
70839 + },
70840 +#endif
70841 +#ifdef CONFIG_GRKERNSEC_TIME
70842 + {
70843 + .procname = "timechange_logging",
70844 + .data = &grsec_enable_time,
70845 + .maxlen = sizeof(int),
70846 + .mode = 0600,
70847 + .proc_handler = &proc_dointvec,
70848 + },
70849 +#endif
70850 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70851 + {
70852 + .procname = "chroot_deny_shmat",
70853 + .data = &grsec_enable_chroot_shmat,
70854 + .maxlen = sizeof(int),
70855 + .mode = 0600,
70856 + .proc_handler = &proc_dointvec,
70857 + },
70858 +#endif
70859 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70860 + {
70861 + .procname = "chroot_deny_unix",
70862 + .data = &grsec_enable_chroot_unix,
70863 + .maxlen = sizeof(int),
70864 + .mode = 0600,
70865 + .proc_handler = &proc_dointvec,
70866 + },
70867 +#endif
70868 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70869 + {
70870 + .procname = "chroot_deny_mount",
70871 + .data = &grsec_enable_chroot_mount,
70872 + .maxlen = sizeof(int),
70873 + .mode = 0600,
70874 + .proc_handler = &proc_dointvec,
70875 + },
70876 +#endif
70877 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70878 + {
70879 + .procname = "chroot_deny_fchdir",
70880 + .data = &grsec_enable_chroot_fchdir,
70881 + .maxlen = sizeof(int),
70882 + .mode = 0600,
70883 + .proc_handler = &proc_dointvec,
70884 + },
70885 +#endif
70886 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70887 + {
70888 + .procname = "chroot_deny_chroot",
70889 + .data = &grsec_enable_chroot_double,
70890 + .maxlen = sizeof(int),
70891 + .mode = 0600,
70892 + .proc_handler = &proc_dointvec,
70893 + },
70894 +#endif
70895 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70896 + {
70897 + .procname = "chroot_deny_pivot",
70898 + .data = &grsec_enable_chroot_pivot,
70899 + .maxlen = sizeof(int),
70900 + .mode = 0600,
70901 + .proc_handler = &proc_dointvec,
70902 + },
70903 +#endif
70904 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70905 + {
70906 + .procname = "chroot_enforce_chdir",
70907 + .data = &grsec_enable_chroot_chdir,
70908 + .maxlen = sizeof(int),
70909 + .mode = 0600,
70910 + .proc_handler = &proc_dointvec,
70911 + },
70912 +#endif
70913 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70914 + {
70915 + .procname = "chroot_deny_chmod",
70916 + .data = &grsec_enable_chroot_chmod,
70917 + .maxlen = sizeof(int),
70918 + .mode = 0600,
70919 + .proc_handler = &proc_dointvec,
70920 + },
70921 +#endif
70922 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70923 + {
70924 + .procname = "chroot_deny_mknod",
70925 + .data = &grsec_enable_chroot_mknod,
70926 + .maxlen = sizeof(int),
70927 + .mode = 0600,
70928 + .proc_handler = &proc_dointvec,
70929 + },
70930 +#endif
70931 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70932 + {
70933 + .procname = "chroot_restrict_nice",
70934 + .data = &grsec_enable_chroot_nice,
70935 + .maxlen = sizeof(int),
70936 + .mode = 0600,
70937 + .proc_handler = &proc_dointvec,
70938 + },
70939 +#endif
70940 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70941 + {
70942 + .procname = "chroot_execlog",
70943 + .data = &grsec_enable_chroot_execlog,
70944 + .maxlen = sizeof(int),
70945 + .mode = 0600,
70946 + .proc_handler = &proc_dointvec,
70947 + },
70948 +#endif
70949 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70950 + {
70951 + .procname = "chroot_caps",
70952 + .data = &grsec_enable_chroot_caps,
70953 + .maxlen = sizeof(int),
70954 + .mode = 0600,
70955 + .proc_handler = &proc_dointvec,
70956 + },
70957 +#endif
70958 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70959 + {
70960 + .procname = "chroot_deny_sysctl",
70961 + .data = &grsec_enable_chroot_sysctl,
70962 + .maxlen = sizeof(int),
70963 + .mode = 0600,
70964 + .proc_handler = &proc_dointvec,
70965 + },
70966 +#endif
70967 +#ifdef CONFIG_GRKERNSEC_TPE
70968 + {
70969 + .procname = "tpe",
70970 + .data = &grsec_enable_tpe,
70971 + .maxlen = sizeof(int),
70972 + .mode = 0600,
70973 + .proc_handler = &proc_dointvec,
70974 + },
70975 + {
70976 + .procname = "tpe_gid",
70977 + .data = &grsec_tpe_gid,
70978 + .maxlen = sizeof(int),
70979 + .mode = 0600,
70980 + .proc_handler = &proc_dointvec,
70981 + },
70982 +#endif
70983 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
70984 + {
70985 + .procname = "tpe_invert",
70986 + .data = &grsec_enable_tpe_invert,
70987 + .maxlen = sizeof(int),
70988 + .mode = 0600,
70989 + .proc_handler = &proc_dointvec,
70990 + },
70991 +#endif
70992 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
70993 + {
70994 + .procname = "tpe_restrict_all",
70995 + .data = &grsec_enable_tpe_all,
70996 + .maxlen = sizeof(int),
70997 + .mode = 0600,
70998 + .proc_handler = &proc_dointvec,
70999 + },
71000 +#endif
71001 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71002 + {
71003 + .procname = "socket_all",
71004 + .data = &grsec_enable_socket_all,
71005 + .maxlen = sizeof(int),
71006 + .mode = 0600,
71007 + .proc_handler = &proc_dointvec,
71008 + },
71009 + {
71010 + .procname = "socket_all_gid",
71011 + .data = &grsec_socket_all_gid,
71012 + .maxlen = sizeof(int),
71013 + .mode = 0600,
71014 + .proc_handler = &proc_dointvec,
71015 + },
71016 +#endif
71017 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71018 + {
71019 + .procname = "socket_client",
71020 + .data = &grsec_enable_socket_client,
71021 + .maxlen = sizeof(int),
71022 + .mode = 0600,
71023 + .proc_handler = &proc_dointvec,
71024 + },
71025 + {
71026 + .procname = "socket_client_gid",
71027 + .data = &grsec_socket_client_gid,
71028 + .maxlen = sizeof(int),
71029 + .mode = 0600,
71030 + .proc_handler = &proc_dointvec,
71031 + },
71032 +#endif
71033 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71034 + {
71035 + .procname = "socket_server",
71036 + .data = &grsec_enable_socket_server,
71037 + .maxlen = sizeof(int),
71038 + .mode = 0600,
71039 + .proc_handler = &proc_dointvec,
71040 + },
71041 + {
71042 + .procname = "socket_server_gid",
71043 + .data = &grsec_socket_server_gid,
71044 + .maxlen = sizeof(int),
71045 + .mode = 0600,
71046 + .proc_handler = &proc_dointvec,
71047 + },
71048 +#endif
71049 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71050 + {
71051 + .procname = "audit_group",
71052 + .data = &grsec_enable_group,
71053 + .maxlen = sizeof(int),
71054 + .mode = 0600,
71055 + .proc_handler = &proc_dointvec,
71056 + },
71057 + {
71058 + .procname = "audit_gid",
71059 + .data = &grsec_audit_gid,
71060 + .maxlen = sizeof(int),
71061 + .mode = 0600,
71062 + .proc_handler = &proc_dointvec,
71063 + },
71064 +#endif
71065 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71066 + {
71067 + .procname = "audit_chdir",
71068 + .data = &grsec_enable_chdir,
71069 + .maxlen = sizeof(int),
71070 + .mode = 0600,
71071 + .proc_handler = &proc_dointvec,
71072 + },
71073 +#endif
71074 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71075 + {
71076 + .procname = "audit_mount",
71077 + .data = &grsec_enable_mount,
71078 + .maxlen = sizeof(int),
71079 + .mode = 0600,
71080 + .proc_handler = &proc_dointvec,
71081 + },
71082 +#endif
71083 +#ifdef CONFIG_GRKERNSEC_DMESG
71084 + {
71085 + .procname = "dmesg",
71086 + .data = &grsec_enable_dmesg,
71087 + .maxlen = sizeof(int),
71088 + .mode = 0600,
71089 + .proc_handler = &proc_dointvec,
71090 + },
71091 +#endif
71092 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71093 + {
71094 + .procname = "chroot_findtask",
71095 + .data = &grsec_enable_chroot_findtask,
71096 + .maxlen = sizeof(int),
71097 + .mode = 0600,
71098 + .proc_handler = &proc_dointvec,
71099 + },
71100 +#endif
71101 +#ifdef CONFIG_GRKERNSEC_RESLOG
71102 + {
71103 + .procname = "resource_logging",
71104 + .data = &grsec_resource_logging,
71105 + .maxlen = sizeof(int),
71106 + .mode = 0600,
71107 + .proc_handler = &proc_dointvec,
71108 + },
71109 +#endif
71110 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71111 + {
71112 + .procname = "audit_ptrace",
71113 + .data = &grsec_enable_audit_ptrace,
71114 + .maxlen = sizeof(int),
71115 + .mode = 0600,
71116 + .proc_handler = &proc_dointvec,
71117 + },
71118 +#endif
71119 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71120 + {
71121 + .procname = "harden_ptrace",
71122 + .data = &grsec_enable_harden_ptrace,
71123 + .maxlen = sizeof(int),
71124 + .mode = 0600,
71125 + .proc_handler = &proc_dointvec,
71126 + },
71127 +#endif
71128 + {
71129 + .procname = "grsec_lock",
71130 + .data = &grsec_lock,
71131 + .maxlen = sizeof(int),
71132 + .mode = 0600,
71133 + .proc_handler = &proc_dointvec,
71134 + },
71135 +#endif
71136 +#ifdef CONFIG_GRKERNSEC_ROFS
71137 + {
71138 + .procname = "romount_protect",
71139 + .data = &grsec_enable_rofs,
71140 + .maxlen = sizeof(int),
71141 + .mode = 0600,
71142 + .proc_handler = &proc_dointvec_minmax,
71143 + .extra1 = &one,
71144 + .extra2 = &one,
71145 + },
71146 +#endif
71147 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71148 + {
71149 + .procname = "deny_new_usb",
71150 + .data = &grsec_deny_new_usb,
71151 + .maxlen = sizeof(int),
71152 + .mode = 0600,
71153 + .proc_handler = &proc_dointvec,
71154 + },
71155 +#endif
71156 + { }
71157 +};
71158 +#endif
71159 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71160 new file mode 100644
71161 index 0000000..0dc13c3
71162 --- /dev/null
71163 +++ b/grsecurity/grsec_time.c
71164 @@ -0,0 +1,16 @@
71165 +#include <linux/kernel.h>
71166 +#include <linux/sched.h>
71167 +#include <linux/grinternal.h>
71168 +#include <linux/module.h>
71169 +
71170 +void
71171 +gr_log_timechange(void)
71172 +{
71173 +#ifdef CONFIG_GRKERNSEC_TIME
71174 + if (grsec_enable_time)
71175 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71176 +#endif
71177 + return;
71178 +}
71179 +
71180 +EXPORT_SYMBOL(gr_log_timechange);
71181 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71182 new file mode 100644
71183 index 0000000..ee57dcf
71184 --- /dev/null
71185 +++ b/grsecurity/grsec_tpe.c
71186 @@ -0,0 +1,73 @@
71187 +#include <linux/kernel.h>
71188 +#include <linux/sched.h>
71189 +#include <linux/file.h>
71190 +#include <linux/fs.h>
71191 +#include <linux/grinternal.h>
71192 +
71193 +extern int gr_acl_tpe_check(void);
71194 +
71195 +int
71196 +gr_tpe_allow(const struct file *file)
71197 +{
71198 +#ifdef CONFIG_GRKERNSEC
71199 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71200 + const struct cred *cred = current_cred();
71201 + char *msg = NULL;
71202 + char *msg2 = NULL;
71203 +
71204 + // never restrict root
71205 + if (gr_is_global_root(cred->uid))
71206 + return 1;
71207 +
71208 + if (grsec_enable_tpe) {
71209 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71210 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71211 + msg = "not being in trusted group";
71212 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71213 + msg = "being in untrusted group";
71214 +#else
71215 + if (in_group_p(grsec_tpe_gid))
71216 + msg = "being in untrusted group";
71217 +#endif
71218 + }
71219 + if (!msg && gr_acl_tpe_check())
71220 + msg = "being in untrusted role";
71221 +
71222 + // not in any affected group/role
71223 + if (!msg)
71224 + goto next_check;
71225 +
71226 + if (gr_is_global_nonroot(inode->i_uid))
71227 + msg2 = "file in non-root-owned directory";
71228 + else if (inode->i_mode & S_IWOTH)
71229 + msg2 = "file in world-writable directory";
71230 + else if (inode->i_mode & S_IWGRP)
71231 + msg2 = "file in group-writable directory";
71232 +
71233 + if (msg && msg2) {
71234 + char fullmsg[70] = {0};
71235 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71236 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71237 + return 0;
71238 + }
71239 + msg = NULL;
71240 +next_check:
71241 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71242 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71243 + return 1;
71244 +
71245 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71246 + msg = "directory not owned by user";
71247 + else if (inode->i_mode & S_IWOTH)
71248 + msg = "file in world-writable directory";
71249 + else if (inode->i_mode & S_IWGRP)
71250 + msg = "file in group-writable directory";
71251 +
71252 + if (msg) {
71253 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71254 + return 0;
71255 + }
71256 +#endif
71257 +#endif
71258 + return 1;
71259 +}
71260 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71261 new file mode 100644
71262 index 0000000..ae02d8e
71263 --- /dev/null
71264 +++ b/grsecurity/grsec_usb.c
71265 @@ -0,0 +1,15 @@
71266 +#include <linux/kernel.h>
71267 +#include <linux/grinternal.h>
71268 +#include <linux/module.h>
71269 +
71270 +int gr_handle_new_usb(void)
71271 +{
71272 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71273 + if (grsec_deny_new_usb) {
71274 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71275 + return 1;
71276 + }
71277 +#endif
71278 + return 0;
71279 +}
71280 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71281 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71282 new file mode 100644
71283 index 0000000..9f7b1ac
71284 --- /dev/null
71285 +++ b/grsecurity/grsum.c
71286 @@ -0,0 +1,61 @@
71287 +#include <linux/err.h>
71288 +#include <linux/kernel.h>
71289 +#include <linux/sched.h>
71290 +#include <linux/mm.h>
71291 +#include <linux/scatterlist.h>
71292 +#include <linux/crypto.h>
71293 +#include <linux/gracl.h>
71294 +
71295 +
71296 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71297 +#error "crypto and sha256 must be built into the kernel"
71298 +#endif
71299 +
71300 +int
71301 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71302 +{
71303 + char *p;
71304 + struct crypto_hash *tfm;
71305 + struct hash_desc desc;
71306 + struct scatterlist sg;
71307 + unsigned char temp_sum[GR_SHA_LEN];
71308 + volatile int retval = 0;
71309 + volatile int dummy = 0;
71310 + unsigned int i;
71311 +
71312 + sg_init_table(&sg, 1);
71313 +
71314 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71315 + if (IS_ERR(tfm)) {
71316 + /* should never happen, since sha256 should be built in */
71317 + return 1;
71318 + }
71319 +
71320 + desc.tfm = tfm;
71321 + desc.flags = 0;
71322 +
71323 + crypto_hash_init(&desc);
71324 +
71325 + p = salt;
71326 + sg_set_buf(&sg, p, GR_SALT_LEN);
71327 + crypto_hash_update(&desc, &sg, sg.length);
71328 +
71329 + p = entry->pw;
71330 + sg_set_buf(&sg, p, strlen(p));
71331 +
71332 + crypto_hash_update(&desc, &sg, sg.length);
71333 +
71334 + crypto_hash_final(&desc, temp_sum);
71335 +
71336 + memset(entry->pw, 0, GR_PW_LEN);
71337 +
71338 + for (i = 0; i < GR_SHA_LEN; i++)
71339 + if (sum[i] != temp_sum[i])
71340 + retval = 1;
71341 + else
71342 + dummy = 1; // waste a cycle
71343 +
71344 + crypto_free_hash(tfm);
71345 +
71346 + return retval;
71347 +}
71348 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71349 index 77ff547..181834f 100644
71350 --- a/include/asm-generic/4level-fixup.h
71351 +++ b/include/asm-generic/4level-fixup.h
71352 @@ -13,8 +13,10 @@
71353 #define pmd_alloc(mm, pud, address) \
71354 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71355 NULL: pmd_offset(pud, address))
71356 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71357
71358 #define pud_alloc(mm, pgd, address) (pgd)
71359 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71360 #define pud_offset(pgd, start) (pgd)
71361 #define pud_none(pud) 0
71362 #define pud_bad(pud) 0
71363 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71364 index b7babf0..04ad282 100644
71365 --- a/include/asm-generic/atomic-long.h
71366 +++ b/include/asm-generic/atomic-long.h
71367 @@ -22,6 +22,12 @@
71368
71369 typedef atomic64_t atomic_long_t;
71370
71371 +#ifdef CONFIG_PAX_REFCOUNT
71372 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71373 +#else
71374 +typedef atomic64_t atomic_long_unchecked_t;
71375 +#endif
71376 +
71377 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71378
71379 static inline long atomic_long_read(atomic_long_t *l)
71380 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71381 return (long)atomic64_read(v);
71382 }
71383
71384 +#ifdef CONFIG_PAX_REFCOUNT
71385 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71386 +{
71387 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71388 +
71389 + return (long)atomic64_read_unchecked(v);
71390 +}
71391 +#endif
71392 +
71393 static inline void atomic_long_set(atomic_long_t *l, long i)
71394 {
71395 atomic64_t *v = (atomic64_t *)l;
71396 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71397 atomic64_set(v, i);
71398 }
71399
71400 +#ifdef CONFIG_PAX_REFCOUNT
71401 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71402 +{
71403 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71404 +
71405 + atomic64_set_unchecked(v, i);
71406 +}
71407 +#endif
71408 +
71409 static inline void atomic_long_inc(atomic_long_t *l)
71410 {
71411 atomic64_t *v = (atomic64_t *)l;
71412 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71413 atomic64_inc(v);
71414 }
71415
71416 +#ifdef CONFIG_PAX_REFCOUNT
71417 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71418 +{
71419 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71420 +
71421 + atomic64_inc_unchecked(v);
71422 +}
71423 +#endif
71424 +
71425 static inline void atomic_long_dec(atomic_long_t *l)
71426 {
71427 atomic64_t *v = (atomic64_t *)l;
71428 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71429 atomic64_dec(v);
71430 }
71431
71432 +#ifdef CONFIG_PAX_REFCOUNT
71433 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71434 +{
71435 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71436 +
71437 + atomic64_dec_unchecked(v);
71438 +}
71439 +#endif
71440 +
71441 static inline void atomic_long_add(long i, atomic_long_t *l)
71442 {
71443 atomic64_t *v = (atomic64_t *)l;
71444 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71445 atomic64_add(i, v);
71446 }
71447
71448 +#ifdef CONFIG_PAX_REFCOUNT
71449 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71450 +{
71451 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71452 +
71453 + atomic64_add_unchecked(i, v);
71454 +}
71455 +#endif
71456 +
71457 static inline void atomic_long_sub(long i, atomic_long_t *l)
71458 {
71459 atomic64_t *v = (atomic64_t *)l;
71460 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71461 atomic64_sub(i, v);
71462 }
71463
71464 +#ifdef CONFIG_PAX_REFCOUNT
71465 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71466 +{
71467 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71468 +
71469 + atomic64_sub_unchecked(i, v);
71470 +}
71471 +#endif
71472 +
71473 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71474 {
71475 atomic64_t *v = (atomic64_t *)l;
71476 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71477 return (long)atomic64_add_return(i, v);
71478 }
71479
71480 +#ifdef CONFIG_PAX_REFCOUNT
71481 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71482 +{
71483 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71484 +
71485 + return (long)atomic64_add_return_unchecked(i, v);
71486 +}
71487 +#endif
71488 +
71489 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71490 {
71491 atomic64_t *v = (atomic64_t *)l;
71492 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71493 return (long)atomic64_inc_return(v);
71494 }
71495
71496 +#ifdef CONFIG_PAX_REFCOUNT
71497 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71498 +{
71499 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71500 +
71501 + return (long)atomic64_inc_return_unchecked(v);
71502 +}
71503 +#endif
71504 +
71505 static inline long atomic_long_dec_return(atomic_long_t *l)
71506 {
71507 atomic64_t *v = (atomic64_t *)l;
71508 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71509
71510 typedef atomic_t atomic_long_t;
71511
71512 +#ifdef CONFIG_PAX_REFCOUNT
71513 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71514 +#else
71515 +typedef atomic_t atomic_long_unchecked_t;
71516 +#endif
71517 +
71518 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71519 static inline long atomic_long_read(atomic_long_t *l)
71520 {
71521 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71522 return (long)atomic_read(v);
71523 }
71524
71525 +#ifdef CONFIG_PAX_REFCOUNT
71526 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71527 +{
71528 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71529 +
71530 + return (long)atomic_read_unchecked(v);
71531 +}
71532 +#endif
71533 +
71534 static inline void atomic_long_set(atomic_long_t *l, long i)
71535 {
71536 atomic_t *v = (atomic_t *)l;
71537 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71538 atomic_set(v, i);
71539 }
71540
71541 +#ifdef CONFIG_PAX_REFCOUNT
71542 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71543 +{
71544 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71545 +
71546 + atomic_set_unchecked(v, i);
71547 +}
71548 +#endif
71549 +
71550 static inline void atomic_long_inc(atomic_long_t *l)
71551 {
71552 atomic_t *v = (atomic_t *)l;
71553 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71554 atomic_inc(v);
71555 }
71556
71557 +#ifdef CONFIG_PAX_REFCOUNT
71558 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71559 +{
71560 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71561 +
71562 + atomic_inc_unchecked(v);
71563 +}
71564 +#endif
71565 +
71566 static inline void atomic_long_dec(atomic_long_t *l)
71567 {
71568 atomic_t *v = (atomic_t *)l;
71569 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71570 atomic_dec(v);
71571 }
71572
71573 +#ifdef CONFIG_PAX_REFCOUNT
71574 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71575 +{
71576 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71577 +
71578 + atomic_dec_unchecked(v);
71579 +}
71580 +#endif
71581 +
71582 static inline void atomic_long_add(long i, atomic_long_t *l)
71583 {
71584 atomic_t *v = (atomic_t *)l;
71585 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71586 atomic_add(i, v);
71587 }
71588
71589 +#ifdef CONFIG_PAX_REFCOUNT
71590 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71591 +{
71592 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71593 +
71594 + atomic_add_unchecked(i, v);
71595 +}
71596 +#endif
71597 +
71598 static inline void atomic_long_sub(long i, atomic_long_t *l)
71599 {
71600 atomic_t *v = (atomic_t *)l;
71601 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71602 atomic_sub(i, v);
71603 }
71604
71605 +#ifdef CONFIG_PAX_REFCOUNT
71606 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71607 +{
71608 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71609 +
71610 + atomic_sub_unchecked(i, v);
71611 +}
71612 +#endif
71613 +
71614 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71615 {
71616 atomic_t *v = (atomic_t *)l;
71617 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71618 return (long)atomic_add_return(i, v);
71619 }
71620
71621 +#ifdef CONFIG_PAX_REFCOUNT
71622 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71623 +{
71624 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71625 +
71626 + return (long)atomic_add_return_unchecked(i, v);
71627 +}
71628 +
71629 +#endif
71630 +
71631 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71632 {
71633 atomic_t *v = (atomic_t *)l;
71634 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71635 return (long)atomic_inc_return(v);
71636 }
71637
71638 +#ifdef CONFIG_PAX_REFCOUNT
71639 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71640 +{
71641 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71642 +
71643 + return (long)atomic_inc_return_unchecked(v);
71644 +}
71645 +#endif
71646 +
71647 static inline long atomic_long_dec_return(atomic_long_t *l)
71648 {
71649 atomic_t *v = (atomic_t *)l;
71650 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71651
71652 #endif /* BITS_PER_LONG == 64 */
71653
71654 +#ifdef CONFIG_PAX_REFCOUNT
71655 +static inline void pax_refcount_needs_these_functions(void)
71656 +{
71657 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71658 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71659 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71660 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71661 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71662 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71663 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71664 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71665 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71666 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71667 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71668 +#ifdef CONFIG_X86
71669 + atomic_clear_mask_unchecked(0, NULL);
71670 + atomic_set_mask_unchecked(0, NULL);
71671 +#endif
71672 +
71673 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71674 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71675 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71676 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
71677 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
71678 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
71679 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
71680 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
71681 +}
71682 +#else
71683 +#define atomic_read_unchecked(v) atomic_read(v)
71684 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
71685 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
71686 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
71687 +#define atomic_inc_unchecked(v) atomic_inc(v)
71688 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
71689 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
71690 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
71691 +#define atomic_dec_unchecked(v) atomic_dec(v)
71692 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
71693 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
71694 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
71695 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
71696 +
71697 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
71698 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
71699 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
71700 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
71701 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
71702 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
71703 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
71704 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
71705 +#endif
71706 +
71707 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
71708 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
71709 index 33bd2de..f31bff97 100644
71710 --- a/include/asm-generic/atomic.h
71711 +++ b/include/asm-generic/atomic.h
71712 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
71713 * Atomically clears the bits set in @mask from @v
71714 */
71715 #ifndef atomic_clear_mask
71716 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
71717 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
71718 {
71719 unsigned long flags;
71720
71721 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
71722 index b18ce4f..2ee2843 100644
71723 --- a/include/asm-generic/atomic64.h
71724 +++ b/include/asm-generic/atomic64.h
71725 @@ -16,6 +16,8 @@ typedef struct {
71726 long long counter;
71727 } atomic64_t;
71728
71729 +typedef atomic64_t atomic64_unchecked_t;
71730 +
71731 #define ATOMIC64_INIT(i) { (i) }
71732
71733 extern long long atomic64_read(const atomic64_t *v);
71734 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
71735 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
71736 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
71737
71738 +#define atomic64_read_unchecked(v) atomic64_read(v)
71739 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
71740 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
71741 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
71742 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
71743 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
71744 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
71745 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
71746 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
71747 +
71748 #endif /* _ASM_GENERIC_ATOMIC64_H */
71749 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
71750 index 1bfcfe5..e04c5c9 100644
71751 --- a/include/asm-generic/cache.h
71752 +++ b/include/asm-generic/cache.h
71753 @@ -6,7 +6,7 @@
71754 * cache lines need to provide their own cache.h.
71755 */
71756
71757 -#define L1_CACHE_SHIFT 5
71758 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
71759 +#define L1_CACHE_SHIFT 5UL
71760 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
71761
71762 #endif /* __ASM_GENERIC_CACHE_H */
71763 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
71764 index 0d68a1e..b74a761 100644
71765 --- a/include/asm-generic/emergency-restart.h
71766 +++ b/include/asm-generic/emergency-restart.h
71767 @@ -1,7 +1,7 @@
71768 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
71769 #define _ASM_GENERIC_EMERGENCY_RESTART_H
71770
71771 -static inline void machine_emergency_restart(void)
71772 +static inline __noreturn void machine_emergency_restart(void)
71773 {
71774 machine_restart(NULL);
71775 }
71776 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
71777 index 90f99c7..00ce236 100644
71778 --- a/include/asm-generic/kmap_types.h
71779 +++ b/include/asm-generic/kmap_types.h
71780 @@ -2,9 +2,9 @@
71781 #define _ASM_GENERIC_KMAP_TYPES_H
71782
71783 #ifdef __WITH_KM_FENCE
71784 -# define KM_TYPE_NR 41
71785 +# define KM_TYPE_NR 42
71786 #else
71787 -# define KM_TYPE_NR 20
71788 +# define KM_TYPE_NR 21
71789 #endif
71790
71791 #endif
71792 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
71793 index 9ceb03b..62b0b8f 100644
71794 --- a/include/asm-generic/local.h
71795 +++ b/include/asm-generic/local.h
71796 @@ -23,24 +23,37 @@ typedef struct
71797 atomic_long_t a;
71798 } local_t;
71799
71800 +typedef struct {
71801 + atomic_long_unchecked_t a;
71802 +} local_unchecked_t;
71803 +
71804 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
71805
71806 #define local_read(l) atomic_long_read(&(l)->a)
71807 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
71808 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
71809 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
71810 #define local_inc(l) atomic_long_inc(&(l)->a)
71811 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
71812 #define local_dec(l) atomic_long_dec(&(l)->a)
71813 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
71814 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
71815 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
71816 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
71817 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
71818
71819 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
71820 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
71821 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
71822 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
71823 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
71824 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
71825 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
71826 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
71827 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
71828
71829 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
71830 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
71831 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
71832 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
71833 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
71834 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
71835 index 725612b..9cc513a 100644
71836 --- a/include/asm-generic/pgtable-nopmd.h
71837 +++ b/include/asm-generic/pgtable-nopmd.h
71838 @@ -1,14 +1,19 @@
71839 #ifndef _PGTABLE_NOPMD_H
71840 #define _PGTABLE_NOPMD_H
71841
71842 -#ifndef __ASSEMBLY__
71843 -
71844 #include <asm-generic/pgtable-nopud.h>
71845
71846 -struct mm_struct;
71847 -
71848 #define __PAGETABLE_PMD_FOLDED
71849
71850 +#define PMD_SHIFT PUD_SHIFT
71851 +#define PTRS_PER_PMD 1
71852 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
71853 +#define PMD_MASK (~(PMD_SIZE-1))
71854 +
71855 +#ifndef __ASSEMBLY__
71856 +
71857 +struct mm_struct;
71858 +
71859 /*
71860 * Having the pmd type consist of a pud gets the size right, and allows
71861 * us to conceptually access the pud entry that this pmd is folded into
71862 @@ -16,11 +21,6 @@ struct mm_struct;
71863 */
71864 typedef struct { pud_t pud; } pmd_t;
71865
71866 -#define PMD_SHIFT PUD_SHIFT
71867 -#define PTRS_PER_PMD 1
71868 -#define PMD_SIZE (1UL << PMD_SHIFT)
71869 -#define PMD_MASK (~(PMD_SIZE-1))
71870 -
71871 /*
71872 * The "pud_xxx()" functions here are trivial for a folded two-level
71873 * setup: the pmd is never bad, and a pmd always exists (as it's folded
71874 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
71875 index 810431d..0ec4804f 100644
71876 --- a/include/asm-generic/pgtable-nopud.h
71877 +++ b/include/asm-generic/pgtable-nopud.h
71878 @@ -1,10 +1,15 @@
71879 #ifndef _PGTABLE_NOPUD_H
71880 #define _PGTABLE_NOPUD_H
71881
71882 -#ifndef __ASSEMBLY__
71883 -
71884 #define __PAGETABLE_PUD_FOLDED
71885
71886 +#define PUD_SHIFT PGDIR_SHIFT
71887 +#define PTRS_PER_PUD 1
71888 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
71889 +#define PUD_MASK (~(PUD_SIZE-1))
71890 +
71891 +#ifndef __ASSEMBLY__
71892 +
71893 /*
71894 * Having the pud type consist of a pgd gets the size right, and allows
71895 * us to conceptually access the pgd entry that this pud is folded into
71896 @@ -12,11 +17,6 @@
71897 */
71898 typedef struct { pgd_t pgd; } pud_t;
71899
71900 -#define PUD_SHIFT PGDIR_SHIFT
71901 -#define PTRS_PER_PUD 1
71902 -#define PUD_SIZE (1UL << PUD_SHIFT)
71903 -#define PUD_MASK (~(PUD_SIZE-1))
71904 -
71905 /*
71906 * The "pgd_xxx()" functions here are trivial for a folded two-level
71907 * setup: the pud is never bad, and a pud always exists (as it's folded
71908 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
71909 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
71910
71911 #define pgd_populate(mm, pgd, pud) do { } while (0)
71912 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
71913 /*
71914 * (puds are folded into pgds so this doesn't get actually called,
71915 * but the define is needed for a generic inline function.)
71916 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
71917 index 0807ddf..cd67747 100644
71918 --- a/include/asm-generic/pgtable.h
71919 +++ b/include/asm-generic/pgtable.h
71920 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
71921 }
71922 #endif /* CONFIG_NUMA_BALANCING */
71923
71924 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
71925 +#ifdef CONFIG_PAX_KERNEXEC
71926 +#error KERNEXEC requires pax_open_kernel
71927 +#else
71928 +static inline unsigned long pax_open_kernel(void) { return 0; }
71929 +#endif
71930 +#endif
71931 +
71932 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
71933 +#ifdef CONFIG_PAX_KERNEXEC
71934 +#error KERNEXEC requires pax_close_kernel
71935 +#else
71936 +static inline unsigned long pax_close_kernel(void) { return 0; }
71937 +#endif
71938 +#endif
71939 +
71940 #endif /* CONFIG_MMU */
71941
71942 #endif /* !__ASSEMBLY__ */
71943 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
71944 index dc1269c..48a4f51 100644
71945 --- a/include/asm-generic/uaccess.h
71946 +++ b/include/asm-generic/uaccess.h
71947 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
71948 return __clear_user(to, n);
71949 }
71950
71951 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
71952 +#ifdef CONFIG_PAX_MEMORY_UDEREF
71953 +#error UDEREF requires pax_open_userland
71954 +#else
71955 +static inline unsigned long pax_open_userland(void) { return 0; }
71956 +#endif
71957 +#endif
71958 +
71959 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
71960 +#ifdef CONFIG_PAX_MEMORY_UDEREF
71961 +#error UDEREF requires pax_close_userland
71962 +#else
71963 +static inline unsigned long pax_close_userland(void) { return 0; }
71964 +#endif
71965 +#endif
71966 +
71967 #endif /* __ASM_GENERIC_UACCESS_H */
71968 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
71969 index 69732d2..cbe16d9 100644
71970 --- a/include/asm-generic/vmlinux.lds.h
71971 +++ b/include/asm-generic/vmlinux.lds.h
71972 @@ -227,6 +227,7 @@
71973 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
71974 VMLINUX_SYMBOL(__start_rodata) = .; \
71975 *(.rodata) *(.rodata.*) \
71976 + *(.data..read_only) \
71977 *(__vermagic) /* Kernel version magic */ \
71978 . = ALIGN(8); \
71979 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
71980 @@ -710,17 +711,18 @@
71981 * section in the linker script will go there too. @phdr should have
71982 * a leading colon.
71983 *
71984 - * Note that this macros defines __per_cpu_load as an absolute symbol.
71985 + * Note that this macros defines per_cpu_load as an absolute symbol.
71986 * If there is no need to put the percpu section at a predetermined
71987 * address, use PERCPU_SECTION.
71988 */
71989 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
71990 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
71991 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
71992 + per_cpu_load = .; \
71993 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
71994 - LOAD_OFFSET) { \
71995 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
71996 PERCPU_INPUT(cacheline) \
71997 } phdr \
71998 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
71999 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72000
72001 /**
72002 * PERCPU_SECTION - define output section for percpu area, simple version
72003 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72004 index 418d270..bfd2794 100644
72005 --- a/include/crypto/algapi.h
72006 +++ b/include/crypto/algapi.h
72007 @@ -34,7 +34,7 @@ struct crypto_type {
72008 unsigned int maskclear;
72009 unsigned int maskset;
72010 unsigned int tfmsize;
72011 -};
72012 +} __do_const;
72013
72014 struct crypto_instance {
72015 struct crypto_alg alg;
72016 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72017 index 12083dc..39740ec 100644
72018 --- a/include/drm/drmP.h
72019 +++ b/include/drm/drmP.h
72020 @@ -69,6 +69,7 @@
72021 #include <linux/workqueue.h>
72022 #include <linux/poll.h>
72023 #include <asm/pgalloc.h>
72024 +#include <asm/local.h>
72025 #include <drm/drm.h>
72026 #include <drm/drm_sarea.h>
72027
72028 @@ -293,10 +294,12 @@ do { \
72029 * \param cmd command.
72030 * \param arg argument.
72031 */
72032 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72033 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72034 + struct drm_file *file_priv);
72035 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72036 struct drm_file *file_priv);
72037
72038 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72039 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72040 unsigned long arg);
72041
72042 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72043 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72044 struct drm_ioctl_desc {
72045 unsigned int cmd;
72046 int flags;
72047 - drm_ioctl_t *func;
72048 + drm_ioctl_t func;
72049 unsigned int cmd_drv;
72050 const char *name;
72051 -};
72052 +} __do_const;
72053
72054 /**
72055 * Creates a driver or general drm_ioctl_desc array entry for the given
72056 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72057 int (*show)(struct seq_file*, void*); /** show callback */
72058 u32 driver_features; /**< Required driver features for this entry */
72059 void *data;
72060 -};
72061 +} __do_const;
72062
72063 /**
72064 * debugfs node structure. This structure represents a debugfs file.
72065 @@ -1088,7 +1091,7 @@ struct drm_device {
72066
72067 /** \name Usage Counters */
72068 /*@{ */
72069 - int open_count; /**< Outstanding files open */
72070 + local_t open_count; /**< Outstanding files open */
72071 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72072 atomic_t vma_count; /**< Outstanding vma areas open */
72073 int buf_use; /**< Buffers in use -- cannot alloc */
72074 @@ -1099,7 +1102,7 @@ struct drm_device {
72075 /*@{ */
72076 unsigned long counters;
72077 enum drm_stat_type types[15];
72078 - atomic_t counts[15];
72079 + atomic_unchecked_t counts[15];
72080 /*@} */
72081
72082 struct list_head filelist;
72083 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72084 index f43d556..94d9343 100644
72085 --- a/include/drm/drm_crtc_helper.h
72086 +++ b/include/drm/drm_crtc_helper.h
72087 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72088 struct drm_connector *connector);
72089 /* disable encoder when not in use - more explicit than dpms off */
72090 void (*disable)(struct drm_encoder *encoder);
72091 -};
72092 +} __no_const;
72093
72094 /**
72095 * drm_connector_helper_funcs - helper operations for connectors
72096 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72097 index 72dcbe8..8db58d7 100644
72098 --- a/include/drm/ttm/ttm_memory.h
72099 +++ b/include/drm/ttm/ttm_memory.h
72100 @@ -48,7 +48,7 @@
72101
72102 struct ttm_mem_shrink {
72103 int (*do_shrink) (struct ttm_mem_shrink *);
72104 -};
72105 +} __no_const;
72106
72107 /**
72108 * struct ttm_mem_global - Global memory accounting structure.
72109 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72110 index 4b840e8..155d235 100644
72111 --- a/include/keys/asymmetric-subtype.h
72112 +++ b/include/keys/asymmetric-subtype.h
72113 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72114 /* Verify the signature on a key of this subtype (optional) */
72115 int (*verify_signature)(const struct key *key,
72116 const struct public_key_signature *sig);
72117 -};
72118 +} __do_const;
72119
72120 /**
72121 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72122 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72123 index c1da539..1dcec55 100644
72124 --- a/include/linux/atmdev.h
72125 +++ b/include/linux/atmdev.h
72126 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72127 #endif
72128
72129 struct k_atm_aal_stats {
72130 -#define __HANDLE_ITEM(i) atomic_t i
72131 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72132 __AAL_STAT_ITEMS
72133 #undef __HANDLE_ITEM
72134 };
72135 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72136 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72137 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72138 struct module *owner;
72139 -};
72140 +} __do_const ;
72141
72142 struct atmphy_ops {
72143 int (*start)(struct atm_dev *dev);
72144 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72145 index 70cf138..0418ee2 100644
72146 --- a/include/linux/binfmts.h
72147 +++ b/include/linux/binfmts.h
72148 @@ -73,8 +73,10 @@ struct linux_binfmt {
72149 int (*load_binary)(struct linux_binprm *);
72150 int (*load_shlib)(struct file *);
72151 int (*core_dump)(struct coredump_params *cprm);
72152 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72153 + void (*handle_mmap)(struct file *);
72154 unsigned long min_coredump; /* minimal dump size */
72155 -};
72156 +} __do_const;
72157
72158 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72159
72160 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72161 index 2fdb4a4..54aad7e 100644
72162 --- a/include/linux/blkdev.h
72163 +++ b/include/linux/blkdev.h
72164 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72165 /* this callback is with swap_lock and sometimes page table lock held */
72166 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72167 struct module *owner;
72168 -};
72169 +} __do_const;
72170
72171 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72172 unsigned long);
72173 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72174 index 7c2e030..b72475d 100644
72175 --- a/include/linux/blktrace_api.h
72176 +++ b/include/linux/blktrace_api.h
72177 @@ -23,7 +23,7 @@ struct blk_trace {
72178 struct dentry *dir;
72179 struct dentry *dropped_file;
72180 struct dentry *msg_file;
72181 - atomic_t dropped;
72182 + atomic_unchecked_t dropped;
72183 };
72184
72185 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72186 diff --git a/include/linux/cache.h b/include/linux/cache.h
72187 index 4c57065..40346da 100644
72188 --- a/include/linux/cache.h
72189 +++ b/include/linux/cache.h
72190 @@ -16,6 +16,14 @@
72191 #define __read_mostly
72192 #endif
72193
72194 +#ifndef __read_only
72195 +#ifdef CONFIG_PAX_KERNEXEC
72196 +#error KERNEXEC requires __read_only
72197 +#else
72198 +#define __read_only __read_mostly
72199 +#endif
72200 +#endif
72201 +
72202 #ifndef ____cacheline_aligned
72203 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72204 #endif
72205 diff --git a/include/linux/capability.h b/include/linux/capability.h
72206 index d9a4f7f4..19f77d6 100644
72207 --- a/include/linux/capability.h
72208 +++ b/include/linux/capability.h
72209 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72210 extern bool nsown_capable(int cap);
72211 extern bool inode_capable(const struct inode *inode, int cap);
72212 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72213 +extern bool capable_nolog(int cap);
72214 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72215 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72216
72217 /* audit system wants to get cap info from files as well */
72218 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72219
72220 +extern int is_privileged_binary(const struct dentry *dentry);
72221 +
72222 #endif /* !_LINUX_CAPABILITY_H */
72223 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72224 index 8609d57..86e4d79 100644
72225 --- a/include/linux/cdrom.h
72226 +++ b/include/linux/cdrom.h
72227 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72228
72229 /* driver specifications */
72230 const int capability; /* capability flags */
72231 - int n_minors; /* number of active minor devices */
72232 /* handle uniform packets for scsi type devices (scsi,atapi) */
72233 int (*generic_packet) (struct cdrom_device_info *,
72234 struct packet_command *);
72235 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72236 index 4ce9056..86caac6 100644
72237 --- a/include/linux/cleancache.h
72238 +++ b/include/linux/cleancache.h
72239 @@ -31,7 +31,7 @@ struct cleancache_ops {
72240 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72241 void (*invalidate_inode)(int, struct cleancache_filekey);
72242 void (*invalidate_fs)(int);
72243 -};
72244 +} __no_const;
72245
72246 extern struct cleancache_ops *
72247 cleancache_register_ops(struct cleancache_ops *ops);
72248 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72249 index 1ec14a7..d0654a2 100644
72250 --- a/include/linux/clk-provider.h
72251 +++ b/include/linux/clk-provider.h
72252 @@ -132,6 +132,7 @@ struct clk_ops {
72253 unsigned long);
72254 void (*init)(struct clk_hw *hw);
72255 };
72256 +typedef struct clk_ops __no_const clk_ops_no_const;
72257
72258 /**
72259 * struct clk_init_data - holds init data that's common to all clocks and is
72260 diff --git a/include/linux/compat.h b/include/linux/compat.h
72261 index ec1aee4..1077986 100644
72262 --- a/include/linux/compat.h
72263 +++ b/include/linux/compat.h
72264 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72265 compat_size_t __user *len_ptr);
72266
72267 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72268 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72269 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72270 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72271 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72272 compat_ssize_t msgsz, int msgflg);
72273 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72274 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72275 compat_ulong_t addr, compat_ulong_t data);
72276 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72277 - compat_long_t addr, compat_long_t data);
72278 + compat_ulong_t addr, compat_ulong_t data);
72279
72280 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72281 /*
72282 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72283 index 842de22..7f3a41f 100644
72284 --- a/include/linux/compiler-gcc4.h
72285 +++ b/include/linux/compiler-gcc4.h
72286 @@ -39,9 +39,29 @@
72287 # define __compiletime_warning(message) __attribute__((warning(message)))
72288 # define __compiletime_error(message) __attribute__((error(message)))
72289 #endif /* __CHECKER__ */
72290 +
72291 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72292 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72293 +#define __bos0(ptr) __bos((ptr), 0)
72294 +#define __bos1(ptr) __bos((ptr), 1)
72295 #endif /* GCC_VERSION >= 40300 */
72296
72297 #if GCC_VERSION >= 40500
72298 +
72299 +#ifdef CONSTIFY_PLUGIN
72300 +#define __no_const __attribute__((no_const))
72301 +#define __do_const __attribute__((do_const))
72302 +#endif
72303 +
72304 +#ifdef SIZE_OVERFLOW_PLUGIN
72305 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72306 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72307 +#endif
72308 +
72309 +#ifdef LATENT_ENTROPY_PLUGIN
72310 +#define __latent_entropy __attribute__((latent_entropy))
72311 +#endif
72312 +
72313 /*
72314 * Mark a position in code as unreachable. This can be used to
72315 * suppress control flow warnings after asm blocks that transfer
72316 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72317 index 92669cd..1771a15 100644
72318 --- a/include/linux/compiler.h
72319 +++ b/include/linux/compiler.h
72320 @@ -5,11 +5,14 @@
72321
72322 #ifdef __CHECKER__
72323 # define __user __attribute__((noderef, address_space(1)))
72324 +# define __force_user __force __user
72325 # define __kernel __attribute__((address_space(0)))
72326 +# define __force_kernel __force __kernel
72327 # define __safe __attribute__((safe))
72328 # define __force __attribute__((force))
72329 # define __nocast __attribute__((nocast))
72330 # define __iomem __attribute__((noderef, address_space(2)))
72331 +# define __force_iomem __force __iomem
72332 # define __must_hold(x) __attribute__((context(x,1,1)))
72333 # define __acquires(x) __attribute__((context(x,0,1)))
72334 # define __releases(x) __attribute__((context(x,1,0)))
72335 @@ -17,20 +20,37 @@
72336 # define __release(x) __context__(x,-1)
72337 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72338 # define __percpu __attribute__((noderef, address_space(3)))
72339 +# define __force_percpu __force __percpu
72340 #ifdef CONFIG_SPARSE_RCU_POINTER
72341 # define __rcu __attribute__((noderef, address_space(4)))
72342 +# define __force_rcu __force __rcu
72343 #else
72344 # define __rcu
72345 +# define __force_rcu
72346 #endif
72347 extern void __chk_user_ptr(const volatile void __user *);
72348 extern void __chk_io_ptr(const volatile void __iomem *);
72349 #else
72350 -# define __user
72351 -# define __kernel
72352 +# ifdef CHECKER_PLUGIN
72353 +//# define __user
72354 +//# define __force_user
72355 +//# define __kernel
72356 +//# define __force_kernel
72357 +# else
72358 +# ifdef STRUCTLEAK_PLUGIN
72359 +# define __user __attribute__((user))
72360 +# else
72361 +# define __user
72362 +# endif
72363 +# define __force_user
72364 +# define __kernel
72365 +# define __force_kernel
72366 +# endif
72367 # define __safe
72368 # define __force
72369 # define __nocast
72370 # define __iomem
72371 +# define __force_iomem
72372 # define __chk_user_ptr(x) (void)0
72373 # define __chk_io_ptr(x) (void)0
72374 # define __builtin_warning(x, y...) (1)
72375 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72376 # define __release(x) (void)0
72377 # define __cond_lock(x,c) (c)
72378 # define __percpu
72379 +# define __force_percpu
72380 # define __rcu
72381 +# define __force_rcu
72382 #endif
72383
72384 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72385 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72386 # define __attribute_const__ /* unimplemented */
72387 #endif
72388
72389 +#ifndef __no_const
72390 +# define __no_const
72391 +#endif
72392 +
72393 +#ifndef __do_const
72394 +# define __do_const
72395 +#endif
72396 +
72397 +#ifndef __size_overflow
72398 +# define __size_overflow(...)
72399 +#endif
72400 +
72401 +#ifndef __intentional_overflow
72402 +# define __intentional_overflow(...)
72403 +#endif
72404 +
72405 +#ifndef __latent_entropy
72406 +# define __latent_entropy
72407 +#endif
72408 +
72409 /*
72410 * Tell gcc if a function is cold. The compiler will assume any path
72411 * directly leading to the call is unlikely.
72412 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72413 #define __cold
72414 #endif
72415
72416 +#ifndef __alloc_size
72417 +#define __alloc_size(...)
72418 +#endif
72419 +
72420 +#ifndef __bos
72421 +#define __bos(ptr, arg)
72422 +#endif
72423 +
72424 +#ifndef __bos0
72425 +#define __bos0(ptr)
72426 +#endif
72427 +
72428 +#ifndef __bos1
72429 +#define __bos1(ptr)
72430 +#endif
72431 +
72432 /* Simple shorthand for a section definition */
72433 #ifndef __section
72434 # define __section(S) __attribute__ ((__section__(#S)))
72435 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72436 * use is to mediate communication between process-level code and irq/NMI
72437 * handlers, all running on the same CPU.
72438 */
72439 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72440 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72441 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72442
72443 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72444 #ifdef CONFIG_KPROBES
72445 diff --git a/include/linux/completion.h b/include/linux/completion.h
72446 index 3cd574d..adce5fa 100644
72447 --- a/include/linux/completion.h
72448 +++ b/include/linux/completion.h
72449 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72450 extern void wait_for_completion(struct completion *);
72451 extern void wait_for_completion_io(struct completion *);
72452 extern int wait_for_completion_interruptible(struct completion *x);
72453 -extern int wait_for_completion_killable(struct completion *x);
72454 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72455 extern unsigned long wait_for_completion_timeout(struct completion *x,
72456 unsigned long timeout);
72457 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72458 unsigned long timeout);
72459 extern long wait_for_completion_interruptible_timeout(
72460 - struct completion *x, unsigned long timeout);
72461 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72462 extern long wait_for_completion_killable_timeout(
72463 - struct completion *x, unsigned long timeout);
72464 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72465 extern bool try_wait_for_completion(struct completion *x);
72466 extern bool completion_done(struct completion *x);
72467
72468 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72469 index 34025df..d94bbbc 100644
72470 --- a/include/linux/configfs.h
72471 +++ b/include/linux/configfs.h
72472 @@ -125,7 +125,7 @@ struct configfs_attribute {
72473 const char *ca_name;
72474 struct module *ca_owner;
72475 umode_t ca_mode;
72476 -};
72477 +} __do_const;
72478
72479 /*
72480 * Users often need to create attribute structures for their configurable
72481 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72482 index 90d5a15..950cb80 100644
72483 --- a/include/linux/cpufreq.h
72484 +++ b/include/linux/cpufreq.h
72485 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72486 int (*suspend) (struct cpufreq_policy *policy);
72487 int (*resume) (struct cpufreq_policy *policy);
72488 struct freq_attr **attr;
72489 -};
72490 +} __do_const;
72491
72492 /* flags */
72493
72494 @@ -325,6 +325,7 @@ struct global_attr {
72495 ssize_t (*store)(struct kobject *a, struct attribute *b,
72496 const char *c, size_t count);
72497 };
72498 +typedef struct global_attr __no_const global_attr_no_const;
72499
72500 #define define_one_global_ro(_name) \
72501 static struct global_attr _name = \
72502 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72503 index 0bc4b74..973b368 100644
72504 --- a/include/linux/cpuidle.h
72505 +++ b/include/linux/cpuidle.h
72506 @@ -52,7 +52,8 @@ struct cpuidle_state {
72507 int index);
72508
72509 int (*enter_dead) (struct cpuidle_device *dev, int index);
72510 -};
72511 +} __do_const;
72512 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72513
72514 /* Idle State Flags */
72515 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72516 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72517 void (*reflect) (struct cpuidle_device *dev, int index);
72518
72519 struct module *owner;
72520 -};
72521 +} __do_const;
72522
72523 #ifdef CONFIG_CPU_IDLE
72524
72525 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72526 index d08e4d2..95fad61 100644
72527 --- a/include/linux/cpumask.h
72528 +++ b/include/linux/cpumask.h
72529 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72530 }
72531
72532 /* Valid inputs for n are -1 and 0. */
72533 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72534 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72535 {
72536 return n+1;
72537 }
72538
72539 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72540 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72541 {
72542 return n+1;
72543 }
72544
72545 -static inline unsigned int cpumask_next_and(int n,
72546 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72547 const struct cpumask *srcp,
72548 const struct cpumask *andp)
72549 {
72550 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72551 *
72552 * Returns >= nr_cpu_ids if no further cpus set.
72553 */
72554 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72555 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72556 {
72557 /* -1 is a legal arg here. */
72558 if (n != -1)
72559 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72560 *
72561 * Returns >= nr_cpu_ids if no further cpus unset.
72562 */
72563 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72564 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72565 {
72566 /* -1 is a legal arg here. */
72567 if (n != -1)
72568 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72569 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72570 }
72571
72572 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72573 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72574 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72575
72576 /**
72577 diff --git a/include/linux/cred.h b/include/linux/cred.h
72578 index 04421e8..6bce4ef 100644
72579 --- a/include/linux/cred.h
72580 +++ b/include/linux/cred.h
72581 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72582 static inline void validate_process_creds(void)
72583 {
72584 }
72585 +static inline void validate_task_creds(struct task_struct *task)
72586 +{
72587 +}
72588 #endif
72589
72590 /**
72591 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72592 index b92eadf..b4ecdc1 100644
72593 --- a/include/linux/crypto.h
72594 +++ b/include/linux/crypto.h
72595 @@ -373,7 +373,7 @@ struct cipher_tfm {
72596 const u8 *key, unsigned int keylen);
72597 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72598 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72599 -};
72600 +} __no_const;
72601
72602 struct hash_tfm {
72603 int (*init)(struct hash_desc *desc);
72604 @@ -394,13 +394,13 @@ struct compress_tfm {
72605 int (*cot_decompress)(struct crypto_tfm *tfm,
72606 const u8 *src, unsigned int slen,
72607 u8 *dst, unsigned int *dlen);
72608 -};
72609 +} __no_const;
72610
72611 struct rng_tfm {
72612 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72613 unsigned int dlen);
72614 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72615 -};
72616 +} __no_const;
72617
72618 #define crt_ablkcipher crt_u.ablkcipher
72619 #define crt_aead crt_u.aead
72620 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72621 index 653589e..4ef254a 100644
72622 --- a/include/linux/ctype.h
72623 +++ b/include/linux/ctype.h
72624 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72625 * Fast implementation of tolower() for internal usage. Do not use in your
72626 * code.
72627 */
72628 -static inline char _tolower(const char c)
72629 +static inline unsigned char _tolower(const unsigned char c)
72630 {
72631 return c | 0x20;
72632 }
72633 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72634 index 7925bf0..d5143d2 100644
72635 --- a/include/linux/decompress/mm.h
72636 +++ b/include/linux/decompress/mm.h
72637 @@ -77,7 +77,7 @@ static void free(void *where)
72638 * warnings when not needed (indeed large_malloc / large_free are not
72639 * needed by inflate */
72640
72641 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72642 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72643 #define free(a) kfree(a)
72644
72645 #define large_malloc(a) vmalloc(a)
72646 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72647 index 5f1ab92..39c35ae 100644
72648 --- a/include/linux/devfreq.h
72649 +++ b/include/linux/devfreq.h
72650 @@ -114,7 +114,7 @@ struct devfreq_governor {
72651 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72652 int (*event_handler)(struct devfreq *devfreq,
72653 unsigned int event, void *data);
72654 -};
72655 +} __do_const;
72656
72657 /**
72658 * struct devfreq - Device devfreq structure
72659 diff --git a/include/linux/device.h b/include/linux/device.h
72660 index 22b546a..a573dc9 100644
72661 --- a/include/linux/device.h
72662 +++ b/include/linux/device.h
72663 @@ -305,7 +305,7 @@ struct subsys_interface {
72664 struct list_head node;
72665 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72666 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72667 -};
72668 +} __do_const;
72669
72670 int subsys_interface_register(struct subsys_interface *sif);
72671 void subsys_interface_unregister(struct subsys_interface *sif);
72672 @@ -493,7 +493,7 @@ struct device_type {
72673 void (*release)(struct device *dev);
72674
72675 const struct dev_pm_ops *pm;
72676 -};
72677 +} __do_const;
72678
72679 /* interface for exporting device attributes */
72680 struct device_attribute {
72681 @@ -503,11 +503,12 @@ struct device_attribute {
72682 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
72683 const char *buf, size_t count);
72684 };
72685 +typedef struct device_attribute __no_const device_attribute_no_const;
72686
72687 struct dev_ext_attribute {
72688 struct device_attribute attr;
72689 void *var;
72690 -};
72691 +} __do_const;
72692
72693 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
72694 char *buf);
72695 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
72696 index 94af418..b1ca7a2 100644
72697 --- a/include/linux/dma-mapping.h
72698 +++ b/include/linux/dma-mapping.h
72699 @@ -54,7 +54,7 @@ struct dma_map_ops {
72700 u64 (*get_required_mask)(struct device *dev);
72701 #endif
72702 int is_phys;
72703 -};
72704 +} __do_const;
72705
72706 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
72707
72708 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
72709 index cb286b1..923d066 100644
72710 --- a/include/linux/dmaengine.h
72711 +++ b/include/linux/dmaengine.h
72712 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
72713 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
72714 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
72715
72716 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72717 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72718 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
72719 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72720 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72721 struct dma_pinned_list *pinned_list, struct page *page,
72722 unsigned int offset, size_t len);
72723
72724 diff --git a/include/linux/efi.h b/include/linux/efi.h
72725 index 5f8f176..62a0556 100644
72726 --- a/include/linux/efi.h
72727 +++ b/include/linux/efi.h
72728 @@ -745,6 +745,7 @@ struct efivar_operations {
72729 efi_set_variable_t *set_variable;
72730 efi_query_variable_store_t *query_variable_store;
72731 };
72732 +typedef struct efivar_operations __no_const efivar_operations_no_const;
72733
72734 struct efivars {
72735 /*
72736 diff --git a/include/linux/elf.h b/include/linux/elf.h
72737 index 40a3c0e..4c45a38 100644
72738 --- a/include/linux/elf.h
72739 +++ b/include/linux/elf.h
72740 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
72741 #define elf_note elf32_note
72742 #define elf_addr_t Elf32_Off
72743 #define Elf_Half Elf32_Half
72744 +#define elf_dyn Elf32_Dyn
72745
72746 #else
72747
72748 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
72749 #define elf_note elf64_note
72750 #define elf_addr_t Elf64_Off
72751 #define Elf_Half Elf64_Half
72752 +#define elf_dyn Elf64_Dyn
72753
72754 #endif
72755
72756 diff --git a/include/linux/err.h b/include/linux/err.h
72757 index 221fcfb..f29e5e2 100644
72758 --- a/include/linux/err.h
72759 +++ b/include/linux/err.h
72760 @@ -19,12 +19,12 @@
72761
72762 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
72763
72764 -static inline void * __must_check ERR_PTR(long error)
72765 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
72766 {
72767 return (void *) error;
72768 }
72769
72770 -static inline long __must_check PTR_ERR(__force const void *ptr)
72771 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
72772 {
72773 return (long) ptr;
72774 }
72775 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
72776 index fcb51c8..bdafcf6 100644
72777 --- a/include/linux/extcon.h
72778 +++ b/include/linux/extcon.h
72779 @@ -134,7 +134,7 @@ struct extcon_dev {
72780 /* /sys/class/extcon/.../mutually_exclusive/... */
72781 struct attribute_group attr_g_muex;
72782 struct attribute **attrs_muex;
72783 - struct device_attribute *d_attrs_muex;
72784 + device_attribute_no_const *d_attrs_muex;
72785 };
72786
72787 /**
72788 diff --git a/include/linux/fb.h b/include/linux/fb.h
72789 index ffac70a..ca3e711 100644
72790 --- a/include/linux/fb.h
72791 +++ b/include/linux/fb.h
72792 @@ -304,7 +304,7 @@ struct fb_ops {
72793 /* called at KDB enter and leave time to prepare the console */
72794 int (*fb_debug_enter)(struct fb_info *info);
72795 int (*fb_debug_leave)(struct fb_info *info);
72796 -};
72797 +} __do_const;
72798
72799 #ifdef CONFIG_FB_TILEBLITTING
72800 #define FB_TILE_CURSOR_NONE 0
72801 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
72802 index 085197b..0fa6f0b 100644
72803 --- a/include/linux/fdtable.h
72804 +++ b/include/linux/fdtable.h
72805 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
72806 void put_files_struct(struct files_struct *fs);
72807 void reset_files_struct(struct files_struct *);
72808 int unshare_files(struct files_struct **);
72809 -struct files_struct *dup_fd(struct files_struct *, int *);
72810 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
72811 void do_close_on_exec(struct files_struct *);
72812 int iterate_fd(struct files_struct *, unsigned,
72813 int (*)(const void *, struct file *, unsigned),
72814 diff --git a/include/linux/filter.h b/include/linux/filter.h
72815 index a6ac848..a104a76 100644
72816 --- a/include/linux/filter.h
72817 +++ b/include/linux/filter.h
72818 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
72819
72820 struct sk_buff;
72821 struct sock;
72822 +struct bpf_jit_work;
72823
72824 struct sk_filter
72825 {
72826 @@ -27,6 +28,9 @@ struct sk_filter
72827 unsigned int len; /* Number of filter blocks */
72828 unsigned int (*bpf_func)(const struct sk_buff *skb,
72829 const struct sock_filter *filter);
72830 +#ifdef CONFIG_BPF_JIT
72831 + struct bpf_jit_work *work;
72832 +#endif
72833 struct rcu_head rcu;
72834 struct sock_filter insns[0];
72835 };
72836 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
72837 index 8293262..2b3b8bd 100644
72838 --- a/include/linux/frontswap.h
72839 +++ b/include/linux/frontswap.h
72840 @@ -11,7 +11,7 @@ struct frontswap_ops {
72841 int (*load)(unsigned, pgoff_t, struct page *);
72842 void (*invalidate_page)(unsigned, pgoff_t);
72843 void (*invalidate_area)(unsigned);
72844 -};
72845 +} __no_const;
72846
72847 extern bool frontswap_enabled;
72848 extern struct frontswap_ops *
72849 diff --git a/include/linux/fs.h b/include/linux/fs.h
72850 index 9818747..788bfbd 100644
72851 --- a/include/linux/fs.h
72852 +++ b/include/linux/fs.h
72853 @@ -1554,7 +1554,8 @@ struct file_operations {
72854 long (*fallocate)(struct file *file, int mode, loff_t offset,
72855 loff_t len);
72856 int (*show_fdinfo)(struct seq_file *m, struct file *f);
72857 -};
72858 +} __do_const;
72859 +typedef struct file_operations __no_const file_operations_no_const;
72860
72861 struct inode_operations {
72862 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
72863 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
72864 return !IS_DEADDIR(inode);
72865 }
72866
72867 +static inline bool is_sidechannel_device(const struct inode *inode)
72868 +{
72869 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
72870 + umode_t mode = inode->i_mode;
72871 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
72872 +#else
72873 + return false;
72874 +#endif
72875 +}
72876 +
72877 #endif /* _LINUX_FS_H */
72878 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
72879 index 2b93a9a..855d94a 100644
72880 --- a/include/linux/fs_struct.h
72881 +++ b/include/linux/fs_struct.h
72882 @@ -6,7 +6,7 @@
72883 #include <linux/seqlock.h>
72884
72885 struct fs_struct {
72886 - int users;
72887 + atomic_t users;
72888 spinlock_t lock;
72889 seqcount_t seq;
72890 int umask;
72891 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
72892 index a9ff9a3..1ba1788 100644
72893 --- a/include/linux/fscache-cache.h
72894 +++ b/include/linux/fscache-cache.h
72895 @@ -113,7 +113,7 @@ struct fscache_operation {
72896 fscache_operation_release_t release;
72897 };
72898
72899 -extern atomic_t fscache_op_debug_id;
72900 +extern atomic_unchecked_t fscache_op_debug_id;
72901 extern void fscache_op_work_func(struct work_struct *work);
72902
72903 extern void fscache_enqueue_operation(struct fscache_operation *);
72904 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
72905 INIT_WORK(&op->work, fscache_op_work_func);
72906 atomic_set(&op->usage, 1);
72907 op->state = FSCACHE_OP_ST_INITIALISED;
72908 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
72909 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
72910 op->processor = processor;
72911 op->release = release;
72912 INIT_LIST_HEAD(&op->pend_link);
72913 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
72914 index 7a08623..4c07b0f 100644
72915 --- a/include/linux/fscache.h
72916 +++ b/include/linux/fscache.h
72917 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
72918 * - this is mandatory for any object that may have data
72919 */
72920 void (*now_uncached)(void *cookie_netfs_data);
72921 -};
72922 +} __do_const;
72923
72924 /*
72925 * fscache cached network filesystem type
72926 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
72927 index 1c804b0..1432c2b 100644
72928 --- a/include/linux/fsnotify.h
72929 +++ b/include/linux/fsnotify.h
72930 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
72931 struct inode *inode = file_inode(file);
72932 __u32 mask = FS_ACCESS;
72933
72934 + if (is_sidechannel_device(inode))
72935 + return;
72936 +
72937 if (S_ISDIR(inode->i_mode))
72938 mask |= FS_ISDIR;
72939
72940 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
72941 struct inode *inode = file_inode(file);
72942 __u32 mask = FS_MODIFY;
72943
72944 + if (is_sidechannel_device(inode))
72945 + return;
72946 +
72947 if (S_ISDIR(inode->i_mode))
72948 mask |= FS_ISDIR;
72949
72950 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
72951 */
72952 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
72953 {
72954 - return kstrdup(name, GFP_KERNEL);
72955 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
72956 }
72957
72958 /*
72959 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
72960 index 9f3c275..8bdff5d 100644
72961 --- a/include/linux/genhd.h
72962 +++ b/include/linux/genhd.h
72963 @@ -194,7 +194,7 @@ struct gendisk {
72964 struct kobject *slave_dir;
72965
72966 struct timer_rand_state *random;
72967 - atomic_t sync_io; /* RAID */
72968 + atomic_unchecked_t sync_io; /* RAID */
72969 struct disk_events *ev;
72970 #ifdef CONFIG_BLK_DEV_INTEGRITY
72971 struct blk_integrity *integrity;
72972 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
72973 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
72974
72975 /* drivers/char/random.c */
72976 -extern void add_disk_randomness(struct gendisk *disk);
72977 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
72978 extern void rand_initialize_disk(struct gendisk *disk);
72979
72980 static inline sector_t get_start_sect(struct block_device *bdev)
72981 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
72982 index 023bc34..b02b46a 100644
72983 --- a/include/linux/genl_magic_func.h
72984 +++ b/include/linux/genl_magic_func.h
72985 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
72986 },
72987
72988 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
72989 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
72990 +static struct genl_ops ZZZ_genl_ops[] = {
72991 #include GENL_MAGIC_INCLUDE_FILE
72992 };
72993
72994 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
72995 index 9b4dd49..61fd41d 100644
72996 --- a/include/linux/gfp.h
72997 +++ b/include/linux/gfp.h
72998 @@ -35,6 +35,13 @@ struct vm_area_struct;
72999 #define ___GFP_NO_KSWAPD 0x400000u
73000 #define ___GFP_OTHER_NODE 0x800000u
73001 #define ___GFP_WRITE 0x1000000u
73002 +
73003 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73004 +#define ___GFP_USERCOPY 0x2000000u
73005 +#else
73006 +#define ___GFP_USERCOPY 0
73007 +#endif
73008 +
73009 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73010
73011 /*
73012 @@ -92,6 +99,7 @@ struct vm_area_struct;
73013 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73014 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73015 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73016 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73017
73018 /*
73019 * This may seem redundant, but it's a way of annotating false positives vs.
73020 @@ -99,7 +107,7 @@ struct vm_area_struct;
73021 */
73022 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73023
73024 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73025 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73026 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73027
73028 /* This equals 0, but use constants in case they ever change */
73029 @@ -153,6 +161,8 @@ struct vm_area_struct;
73030 /* 4GB DMA on some platforms */
73031 #define GFP_DMA32 __GFP_DMA32
73032
73033 +#define GFP_USERCOPY __GFP_USERCOPY
73034 +
73035 /* Convert GFP flags to their corresponding migrate type */
73036 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73037 {
73038 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73039 new file mode 100644
73040 index 0000000..ebe6d72
73041 --- /dev/null
73042 +++ b/include/linux/gracl.h
73043 @@ -0,0 +1,319 @@
73044 +#ifndef GR_ACL_H
73045 +#define GR_ACL_H
73046 +
73047 +#include <linux/grdefs.h>
73048 +#include <linux/resource.h>
73049 +#include <linux/capability.h>
73050 +#include <linux/dcache.h>
73051 +#include <asm/resource.h>
73052 +
73053 +/* Major status information */
73054 +
73055 +#define GR_VERSION "grsecurity 2.9.1"
73056 +#define GRSECURITY_VERSION 0x2901
73057 +
73058 +enum {
73059 + GR_SHUTDOWN = 0,
73060 + GR_ENABLE = 1,
73061 + GR_SPROLE = 2,
73062 + GR_RELOAD = 3,
73063 + GR_SEGVMOD = 4,
73064 + GR_STATUS = 5,
73065 + GR_UNSPROLE = 6,
73066 + GR_PASSSET = 7,
73067 + GR_SPROLEPAM = 8,
73068 +};
73069 +
73070 +/* Password setup definitions
73071 + * kernel/grhash.c */
73072 +enum {
73073 + GR_PW_LEN = 128,
73074 + GR_SALT_LEN = 16,
73075 + GR_SHA_LEN = 32,
73076 +};
73077 +
73078 +enum {
73079 + GR_SPROLE_LEN = 64,
73080 +};
73081 +
73082 +enum {
73083 + GR_NO_GLOB = 0,
73084 + GR_REG_GLOB,
73085 + GR_CREATE_GLOB
73086 +};
73087 +
73088 +#define GR_NLIMITS 32
73089 +
73090 +/* Begin Data Structures */
73091 +
73092 +struct sprole_pw {
73093 + unsigned char *rolename;
73094 + unsigned char salt[GR_SALT_LEN];
73095 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73096 +};
73097 +
73098 +struct name_entry {
73099 + __u32 key;
73100 + ino_t inode;
73101 + dev_t device;
73102 + char *name;
73103 + __u16 len;
73104 + __u8 deleted;
73105 + struct name_entry *prev;
73106 + struct name_entry *next;
73107 +};
73108 +
73109 +struct inodev_entry {
73110 + struct name_entry *nentry;
73111 + struct inodev_entry *prev;
73112 + struct inodev_entry *next;
73113 +};
73114 +
73115 +struct acl_role_db {
73116 + struct acl_role_label **r_hash;
73117 + __u32 r_size;
73118 +};
73119 +
73120 +struct inodev_db {
73121 + struct inodev_entry **i_hash;
73122 + __u32 i_size;
73123 +};
73124 +
73125 +struct name_db {
73126 + struct name_entry **n_hash;
73127 + __u32 n_size;
73128 +};
73129 +
73130 +struct crash_uid {
73131 + uid_t uid;
73132 + unsigned long expires;
73133 +};
73134 +
73135 +struct gr_hash_struct {
73136 + void **table;
73137 + void **nametable;
73138 + void *first;
73139 + __u32 table_size;
73140 + __u32 used_size;
73141 + int type;
73142 +};
73143 +
73144 +/* Userspace Grsecurity ACL data structures */
73145 +
73146 +struct acl_subject_label {
73147 + char *filename;
73148 + ino_t inode;
73149 + dev_t device;
73150 + __u32 mode;
73151 + kernel_cap_t cap_mask;
73152 + kernel_cap_t cap_lower;
73153 + kernel_cap_t cap_invert_audit;
73154 +
73155 + struct rlimit res[GR_NLIMITS];
73156 + __u32 resmask;
73157 +
73158 + __u8 user_trans_type;
73159 + __u8 group_trans_type;
73160 + uid_t *user_transitions;
73161 + gid_t *group_transitions;
73162 + __u16 user_trans_num;
73163 + __u16 group_trans_num;
73164 +
73165 + __u32 sock_families[2];
73166 + __u32 ip_proto[8];
73167 + __u32 ip_type;
73168 + struct acl_ip_label **ips;
73169 + __u32 ip_num;
73170 + __u32 inaddr_any_override;
73171 +
73172 + __u32 crashes;
73173 + unsigned long expires;
73174 +
73175 + struct acl_subject_label *parent_subject;
73176 + struct gr_hash_struct *hash;
73177 + struct acl_subject_label *prev;
73178 + struct acl_subject_label *next;
73179 +
73180 + struct acl_object_label **obj_hash;
73181 + __u32 obj_hash_size;
73182 + __u16 pax_flags;
73183 +};
73184 +
73185 +struct role_allowed_ip {
73186 + __u32 addr;
73187 + __u32 netmask;
73188 +
73189 + struct role_allowed_ip *prev;
73190 + struct role_allowed_ip *next;
73191 +};
73192 +
73193 +struct role_transition {
73194 + char *rolename;
73195 +
73196 + struct role_transition *prev;
73197 + struct role_transition *next;
73198 +};
73199 +
73200 +struct acl_role_label {
73201 + char *rolename;
73202 + uid_t uidgid;
73203 + __u16 roletype;
73204 +
73205 + __u16 auth_attempts;
73206 + unsigned long expires;
73207 +
73208 + struct acl_subject_label *root_label;
73209 + struct gr_hash_struct *hash;
73210 +
73211 + struct acl_role_label *prev;
73212 + struct acl_role_label *next;
73213 +
73214 + struct role_transition *transitions;
73215 + struct role_allowed_ip *allowed_ips;
73216 + uid_t *domain_children;
73217 + __u16 domain_child_num;
73218 +
73219 + umode_t umask;
73220 +
73221 + struct acl_subject_label **subj_hash;
73222 + __u32 subj_hash_size;
73223 +};
73224 +
73225 +struct user_acl_role_db {
73226 + struct acl_role_label **r_table;
73227 + __u32 num_pointers; /* Number of allocations to track */
73228 + __u32 num_roles; /* Number of roles */
73229 + __u32 num_domain_children; /* Number of domain children */
73230 + __u32 num_subjects; /* Number of subjects */
73231 + __u32 num_objects; /* Number of objects */
73232 +};
73233 +
73234 +struct acl_object_label {
73235 + char *filename;
73236 + ino_t inode;
73237 + dev_t device;
73238 + __u32 mode;
73239 +
73240 + struct acl_subject_label *nested;
73241 + struct acl_object_label *globbed;
73242 +
73243 + /* next two structures not used */
73244 +
73245 + struct acl_object_label *prev;
73246 + struct acl_object_label *next;
73247 +};
73248 +
73249 +struct acl_ip_label {
73250 + char *iface;
73251 + __u32 addr;
73252 + __u32 netmask;
73253 + __u16 low, high;
73254 + __u8 mode;
73255 + __u32 type;
73256 + __u32 proto[8];
73257 +
73258 + /* next two structures not used */
73259 +
73260 + struct acl_ip_label *prev;
73261 + struct acl_ip_label *next;
73262 +};
73263 +
73264 +struct gr_arg {
73265 + struct user_acl_role_db role_db;
73266 + unsigned char pw[GR_PW_LEN];
73267 + unsigned char salt[GR_SALT_LEN];
73268 + unsigned char sum[GR_SHA_LEN];
73269 + unsigned char sp_role[GR_SPROLE_LEN];
73270 + struct sprole_pw *sprole_pws;
73271 + dev_t segv_device;
73272 + ino_t segv_inode;
73273 + uid_t segv_uid;
73274 + __u16 num_sprole_pws;
73275 + __u16 mode;
73276 +};
73277 +
73278 +struct gr_arg_wrapper {
73279 + struct gr_arg *arg;
73280 + __u32 version;
73281 + __u32 size;
73282 +};
73283 +
73284 +struct subject_map {
73285 + struct acl_subject_label *user;
73286 + struct acl_subject_label *kernel;
73287 + struct subject_map *prev;
73288 + struct subject_map *next;
73289 +};
73290 +
73291 +struct acl_subj_map_db {
73292 + struct subject_map **s_hash;
73293 + __u32 s_size;
73294 +};
73295 +
73296 +/* End Data Structures Section */
73297 +
73298 +/* Hash functions generated by empirical testing by Brad Spengler
73299 + Makes good use of the low bits of the inode. Generally 0-1 times
73300 + in loop for successful match. 0-3 for unsuccessful match.
73301 + Shift/add algorithm with modulus of table size and an XOR*/
73302 +
73303 +static __inline__ unsigned int
73304 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73305 +{
73306 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73307 +}
73308 +
73309 + static __inline__ unsigned int
73310 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73311 +{
73312 + return ((const unsigned long)userp % sz);
73313 +}
73314 +
73315 +static __inline__ unsigned int
73316 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73317 +{
73318 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73319 +}
73320 +
73321 +static __inline__ unsigned int
73322 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73323 +{
73324 + return full_name_hash((const unsigned char *)name, len) % sz;
73325 +}
73326 +
73327 +#define FOR_EACH_ROLE_START(role) \
73328 + role = role_list; \
73329 + while (role) {
73330 +
73331 +#define FOR_EACH_ROLE_END(role) \
73332 + role = role->prev; \
73333 + }
73334 +
73335 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73336 + subj = NULL; \
73337 + iter = 0; \
73338 + while (iter < role->subj_hash_size) { \
73339 + if (subj == NULL) \
73340 + subj = role->subj_hash[iter]; \
73341 + if (subj == NULL) { \
73342 + iter++; \
73343 + continue; \
73344 + }
73345 +
73346 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73347 + subj = subj->next; \
73348 + if (subj == NULL) \
73349 + iter++; \
73350 + }
73351 +
73352 +
73353 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73354 + subj = role->hash->first; \
73355 + while (subj != NULL) {
73356 +
73357 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73358 + subj = subj->next; \
73359 + }
73360 +
73361 +#endif
73362 +
73363 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73364 new file mode 100644
73365 index 0000000..33ebd1f
73366 --- /dev/null
73367 +++ b/include/linux/gracl_compat.h
73368 @@ -0,0 +1,156 @@
73369 +#ifndef GR_ACL_COMPAT_H
73370 +#define GR_ACL_COMPAT_H
73371 +
73372 +#include <linux/resource.h>
73373 +#include <asm/resource.h>
73374 +
73375 +struct sprole_pw_compat {
73376 + compat_uptr_t rolename;
73377 + unsigned char salt[GR_SALT_LEN];
73378 + unsigned char sum[GR_SHA_LEN];
73379 +};
73380 +
73381 +struct gr_hash_struct_compat {
73382 + compat_uptr_t table;
73383 + compat_uptr_t nametable;
73384 + compat_uptr_t first;
73385 + __u32 table_size;
73386 + __u32 used_size;
73387 + int type;
73388 +};
73389 +
73390 +struct acl_subject_label_compat {
73391 + compat_uptr_t filename;
73392 + compat_ino_t inode;
73393 + __u32 device;
73394 + __u32 mode;
73395 + kernel_cap_t cap_mask;
73396 + kernel_cap_t cap_lower;
73397 + kernel_cap_t cap_invert_audit;
73398 +
73399 + struct compat_rlimit res[GR_NLIMITS];
73400 + __u32 resmask;
73401 +
73402 + __u8 user_trans_type;
73403 + __u8 group_trans_type;
73404 + compat_uptr_t user_transitions;
73405 + compat_uptr_t group_transitions;
73406 + __u16 user_trans_num;
73407 + __u16 group_trans_num;
73408 +
73409 + __u32 sock_families[2];
73410 + __u32 ip_proto[8];
73411 + __u32 ip_type;
73412 + compat_uptr_t ips;
73413 + __u32 ip_num;
73414 + __u32 inaddr_any_override;
73415 +
73416 + __u32 crashes;
73417 + compat_ulong_t expires;
73418 +
73419 + compat_uptr_t parent_subject;
73420 + compat_uptr_t hash;
73421 + compat_uptr_t prev;
73422 + compat_uptr_t next;
73423 +
73424 + compat_uptr_t obj_hash;
73425 + __u32 obj_hash_size;
73426 + __u16 pax_flags;
73427 +};
73428 +
73429 +struct role_allowed_ip_compat {
73430 + __u32 addr;
73431 + __u32 netmask;
73432 +
73433 + compat_uptr_t prev;
73434 + compat_uptr_t next;
73435 +};
73436 +
73437 +struct role_transition_compat {
73438 + compat_uptr_t rolename;
73439 +
73440 + compat_uptr_t prev;
73441 + compat_uptr_t next;
73442 +};
73443 +
73444 +struct acl_role_label_compat {
73445 + compat_uptr_t rolename;
73446 + uid_t uidgid;
73447 + __u16 roletype;
73448 +
73449 + __u16 auth_attempts;
73450 + compat_ulong_t expires;
73451 +
73452 + compat_uptr_t root_label;
73453 + compat_uptr_t hash;
73454 +
73455 + compat_uptr_t prev;
73456 + compat_uptr_t next;
73457 +
73458 + compat_uptr_t transitions;
73459 + compat_uptr_t allowed_ips;
73460 + compat_uptr_t domain_children;
73461 + __u16 domain_child_num;
73462 +
73463 + umode_t umask;
73464 +
73465 + compat_uptr_t subj_hash;
73466 + __u32 subj_hash_size;
73467 +};
73468 +
73469 +struct user_acl_role_db_compat {
73470 + compat_uptr_t r_table;
73471 + __u32 num_pointers;
73472 + __u32 num_roles;
73473 + __u32 num_domain_children;
73474 + __u32 num_subjects;
73475 + __u32 num_objects;
73476 +};
73477 +
73478 +struct acl_object_label_compat {
73479 + compat_uptr_t filename;
73480 + compat_ino_t inode;
73481 + __u32 device;
73482 + __u32 mode;
73483 +
73484 + compat_uptr_t nested;
73485 + compat_uptr_t globbed;
73486 +
73487 + compat_uptr_t prev;
73488 + compat_uptr_t next;
73489 +};
73490 +
73491 +struct acl_ip_label_compat {
73492 + compat_uptr_t iface;
73493 + __u32 addr;
73494 + __u32 netmask;
73495 + __u16 low, high;
73496 + __u8 mode;
73497 + __u32 type;
73498 + __u32 proto[8];
73499 +
73500 + compat_uptr_t prev;
73501 + compat_uptr_t next;
73502 +};
73503 +
73504 +struct gr_arg_compat {
73505 + struct user_acl_role_db_compat role_db;
73506 + unsigned char pw[GR_PW_LEN];
73507 + unsigned char salt[GR_SALT_LEN];
73508 + unsigned char sum[GR_SHA_LEN];
73509 + unsigned char sp_role[GR_SPROLE_LEN];
73510 + compat_uptr_t sprole_pws;
73511 + __u32 segv_device;
73512 + compat_ino_t segv_inode;
73513 + uid_t segv_uid;
73514 + __u16 num_sprole_pws;
73515 + __u16 mode;
73516 +};
73517 +
73518 +struct gr_arg_wrapper_compat {
73519 + compat_uptr_t arg;
73520 + __u32 version;
73521 + __u32 size;
73522 +};
73523 +
73524 +#endif
73525 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73526 new file mode 100644
73527 index 0000000..323ecf2
73528 --- /dev/null
73529 +++ b/include/linux/gralloc.h
73530 @@ -0,0 +1,9 @@
73531 +#ifndef __GRALLOC_H
73532 +#define __GRALLOC_H
73533 +
73534 +void acl_free_all(void);
73535 +int acl_alloc_stack_init(unsigned long size);
73536 +void *acl_alloc(unsigned long len);
73537 +void *acl_alloc_num(unsigned long num, unsigned long len);
73538 +
73539 +#endif
73540 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73541 new file mode 100644
73542 index 0000000..be66033
73543 --- /dev/null
73544 +++ b/include/linux/grdefs.h
73545 @@ -0,0 +1,140 @@
73546 +#ifndef GRDEFS_H
73547 +#define GRDEFS_H
73548 +
73549 +/* Begin grsecurity status declarations */
73550 +
73551 +enum {
73552 + GR_READY = 0x01,
73553 + GR_STATUS_INIT = 0x00 // disabled state
73554 +};
73555 +
73556 +/* Begin ACL declarations */
73557 +
73558 +/* Role flags */
73559 +
73560 +enum {
73561 + GR_ROLE_USER = 0x0001,
73562 + GR_ROLE_GROUP = 0x0002,
73563 + GR_ROLE_DEFAULT = 0x0004,
73564 + GR_ROLE_SPECIAL = 0x0008,
73565 + GR_ROLE_AUTH = 0x0010,
73566 + GR_ROLE_NOPW = 0x0020,
73567 + GR_ROLE_GOD = 0x0040,
73568 + GR_ROLE_LEARN = 0x0080,
73569 + GR_ROLE_TPE = 0x0100,
73570 + GR_ROLE_DOMAIN = 0x0200,
73571 + GR_ROLE_PAM = 0x0400,
73572 + GR_ROLE_PERSIST = 0x0800
73573 +};
73574 +
73575 +/* ACL Subject and Object mode flags */
73576 +enum {
73577 + GR_DELETED = 0x80000000
73578 +};
73579 +
73580 +/* ACL Object-only mode flags */
73581 +enum {
73582 + GR_READ = 0x00000001,
73583 + GR_APPEND = 0x00000002,
73584 + GR_WRITE = 0x00000004,
73585 + GR_EXEC = 0x00000008,
73586 + GR_FIND = 0x00000010,
73587 + GR_INHERIT = 0x00000020,
73588 + GR_SETID = 0x00000040,
73589 + GR_CREATE = 0x00000080,
73590 + GR_DELETE = 0x00000100,
73591 + GR_LINK = 0x00000200,
73592 + GR_AUDIT_READ = 0x00000400,
73593 + GR_AUDIT_APPEND = 0x00000800,
73594 + GR_AUDIT_WRITE = 0x00001000,
73595 + GR_AUDIT_EXEC = 0x00002000,
73596 + GR_AUDIT_FIND = 0x00004000,
73597 + GR_AUDIT_INHERIT= 0x00008000,
73598 + GR_AUDIT_SETID = 0x00010000,
73599 + GR_AUDIT_CREATE = 0x00020000,
73600 + GR_AUDIT_DELETE = 0x00040000,
73601 + GR_AUDIT_LINK = 0x00080000,
73602 + GR_PTRACERD = 0x00100000,
73603 + GR_NOPTRACE = 0x00200000,
73604 + GR_SUPPRESS = 0x00400000,
73605 + GR_NOLEARN = 0x00800000,
73606 + GR_INIT_TRANSFER= 0x01000000
73607 +};
73608 +
73609 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73610 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73611 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73612 +
73613 +/* ACL subject-only mode flags */
73614 +enum {
73615 + GR_KILL = 0x00000001,
73616 + GR_VIEW = 0x00000002,
73617 + GR_PROTECTED = 0x00000004,
73618 + GR_LEARN = 0x00000008,
73619 + GR_OVERRIDE = 0x00000010,
73620 + /* just a placeholder, this mode is only used in userspace */
73621 + GR_DUMMY = 0x00000020,
73622 + GR_PROTSHM = 0x00000040,
73623 + GR_KILLPROC = 0x00000080,
73624 + GR_KILLIPPROC = 0x00000100,
73625 + /* just a placeholder, this mode is only used in userspace */
73626 + GR_NOTROJAN = 0x00000200,
73627 + GR_PROTPROCFD = 0x00000400,
73628 + GR_PROCACCT = 0x00000800,
73629 + GR_RELAXPTRACE = 0x00001000,
73630 + //GR_NESTED = 0x00002000,
73631 + GR_INHERITLEARN = 0x00004000,
73632 + GR_PROCFIND = 0x00008000,
73633 + GR_POVERRIDE = 0x00010000,
73634 + GR_KERNELAUTH = 0x00020000,
73635 + GR_ATSECURE = 0x00040000,
73636 + GR_SHMEXEC = 0x00080000
73637 +};
73638 +
73639 +enum {
73640 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73641 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73642 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73643 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73644 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73645 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73646 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73647 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73648 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73649 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73650 +};
73651 +
73652 +enum {
73653 + GR_ID_USER = 0x01,
73654 + GR_ID_GROUP = 0x02,
73655 +};
73656 +
73657 +enum {
73658 + GR_ID_ALLOW = 0x01,
73659 + GR_ID_DENY = 0x02,
73660 +};
73661 +
73662 +#define GR_CRASH_RES 31
73663 +#define GR_UIDTABLE_MAX 500
73664 +
73665 +/* begin resource learning section */
73666 +enum {
73667 + GR_RLIM_CPU_BUMP = 60,
73668 + GR_RLIM_FSIZE_BUMP = 50000,
73669 + GR_RLIM_DATA_BUMP = 10000,
73670 + GR_RLIM_STACK_BUMP = 1000,
73671 + GR_RLIM_CORE_BUMP = 10000,
73672 + GR_RLIM_RSS_BUMP = 500000,
73673 + GR_RLIM_NPROC_BUMP = 1,
73674 + GR_RLIM_NOFILE_BUMP = 5,
73675 + GR_RLIM_MEMLOCK_BUMP = 50000,
73676 + GR_RLIM_AS_BUMP = 500000,
73677 + GR_RLIM_LOCKS_BUMP = 2,
73678 + GR_RLIM_SIGPENDING_BUMP = 5,
73679 + GR_RLIM_MSGQUEUE_BUMP = 10000,
73680 + GR_RLIM_NICE_BUMP = 1,
73681 + GR_RLIM_RTPRIO_BUMP = 1,
73682 + GR_RLIM_RTTIME_BUMP = 1000000
73683 +};
73684 +
73685 +#endif
73686 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
73687 new file mode 100644
73688 index 0000000..e337683
73689 --- /dev/null
73690 +++ b/include/linux/grinternal.h
73691 @@ -0,0 +1,229 @@
73692 +#ifndef __GRINTERNAL_H
73693 +#define __GRINTERNAL_H
73694 +
73695 +#ifdef CONFIG_GRKERNSEC
73696 +
73697 +#include <linux/fs.h>
73698 +#include <linux/mnt_namespace.h>
73699 +#include <linux/nsproxy.h>
73700 +#include <linux/gracl.h>
73701 +#include <linux/grdefs.h>
73702 +#include <linux/grmsg.h>
73703 +
73704 +void gr_add_learn_entry(const char *fmt, ...)
73705 + __attribute__ ((format (printf, 1, 2)));
73706 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
73707 + const struct vfsmount *mnt);
73708 +__u32 gr_check_create(const struct dentry *new_dentry,
73709 + const struct dentry *parent,
73710 + const struct vfsmount *mnt, const __u32 mode);
73711 +int gr_check_protected_task(const struct task_struct *task);
73712 +__u32 to_gr_audit(const __u32 reqmode);
73713 +int gr_set_acls(const int type);
73714 +int gr_apply_subject_to_task(struct task_struct *task);
73715 +int gr_acl_is_enabled(void);
73716 +char gr_roletype_to_char(void);
73717 +
73718 +void gr_handle_alertkill(struct task_struct *task);
73719 +char *gr_to_filename(const struct dentry *dentry,
73720 + const struct vfsmount *mnt);
73721 +char *gr_to_filename1(const struct dentry *dentry,
73722 + const struct vfsmount *mnt);
73723 +char *gr_to_filename2(const struct dentry *dentry,
73724 + const struct vfsmount *mnt);
73725 +char *gr_to_filename3(const struct dentry *dentry,
73726 + const struct vfsmount *mnt);
73727 +
73728 +extern int grsec_enable_ptrace_readexec;
73729 +extern int grsec_enable_harden_ptrace;
73730 +extern int grsec_enable_link;
73731 +extern int grsec_enable_fifo;
73732 +extern int grsec_enable_execve;
73733 +extern int grsec_enable_shm;
73734 +extern int grsec_enable_execlog;
73735 +extern int grsec_enable_signal;
73736 +extern int grsec_enable_audit_ptrace;
73737 +extern int grsec_enable_forkfail;
73738 +extern int grsec_enable_time;
73739 +extern int grsec_enable_rofs;
73740 +extern int grsec_deny_new_usb;
73741 +extern int grsec_enable_chroot_shmat;
73742 +extern int grsec_enable_chroot_mount;
73743 +extern int grsec_enable_chroot_double;
73744 +extern int grsec_enable_chroot_pivot;
73745 +extern int grsec_enable_chroot_chdir;
73746 +extern int grsec_enable_chroot_chmod;
73747 +extern int grsec_enable_chroot_mknod;
73748 +extern int grsec_enable_chroot_fchdir;
73749 +extern int grsec_enable_chroot_nice;
73750 +extern int grsec_enable_chroot_execlog;
73751 +extern int grsec_enable_chroot_caps;
73752 +extern int grsec_enable_chroot_sysctl;
73753 +extern int grsec_enable_chroot_unix;
73754 +extern int grsec_enable_symlinkown;
73755 +extern kgid_t grsec_symlinkown_gid;
73756 +extern int grsec_enable_tpe;
73757 +extern kgid_t grsec_tpe_gid;
73758 +extern int grsec_enable_tpe_all;
73759 +extern int grsec_enable_tpe_invert;
73760 +extern int grsec_enable_socket_all;
73761 +extern kgid_t grsec_socket_all_gid;
73762 +extern int grsec_enable_socket_client;
73763 +extern kgid_t grsec_socket_client_gid;
73764 +extern int grsec_enable_socket_server;
73765 +extern kgid_t grsec_socket_server_gid;
73766 +extern kgid_t grsec_audit_gid;
73767 +extern int grsec_enable_group;
73768 +extern int grsec_enable_log_rwxmaps;
73769 +extern int grsec_enable_mount;
73770 +extern int grsec_enable_chdir;
73771 +extern int grsec_resource_logging;
73772 +extern int grsec_enable_blackhole;
73773 +extern int grsec_lastack_retries;
73774 +extern int grsec_enable_brute;
73775 +extern int grsec_lock;
73776 +
73777 +extern spinlock_t grsec_alert_lock;
73778 +extern unsigned long grsec_alert_wtime;
73779 +extern unsigned long grsec_alert_fyet;
73780 +
73781 +extern spinlock_t grsec_audit_lock;
73782 +
73783 +extern rwlock_t grsec_exec_file_lock;
73784 +
73785 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
73786 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
73787 + (tsk)->exec_file->f_path.mnt) : "/")
73788 +
73789 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
73790 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
73791 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73792 +
73793 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
73794 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
73795 + (tsk)->exec_file->f_path.mnt) : "/")
73796 +
73797 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
73798 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
73799 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73800 +
73801 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
73802 +
73803 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
73804 +
73805 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
73806 +{
73807 + if (file1 && file2) {
73808 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
73809 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
73810 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
73811 + return true;
73812 + }
73813 +
73814 + return false;
73815 +}
73816 +
73817 +#define GR_CHROOT_CAPS {{ \
73818 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
73819 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
73820 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
73821 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
73822 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
73823 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
73824 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
73825 +
73826 +#define security_learn(normal_msg,args...) \
73827 +({ \
73828 + read_lock(&grsec_exec_file_lock); \
73829 + gr_add_learn_entry(normal_msg "\n", ## args); \
73830 + read_unlock(&grsec_exec_file_lock); \
73831 +})
73832 +
73833 +enum {
73834 + GR_DO_AUDIT,
73835 + GR_DONT_AUDIT,
73836 + /* used for non-audit messages that we shouldn't kill the task on */
73837 + GR_DONT_AUDIT_GOOD
73838 +};
73839 +
73840 +enum {
73841 + GR_TTYSNIFF,
73842 + GR_RBAC,
73843 + GR_RBAC_STR,
73844 + GR_STR_RBAC,
73845 + GR_RBAC_MODE2,
73846 + GR_RBAC_MODE3,
73847 + GR_FILENAME,
73848 + GR_SYSCTL_HIDDEN,
73849 + GR_NOARGS,
73850 + GR_ONE_INT,
73851 + GR_ONE_INT_TWO_STR,
73852 + GR_ONE_STR,
73853 + GR_STR_INT,
73854 + GR_TWO_STR_INT,
73855 + GR_TWO_INT,
73856 + GR_TWO_U64,
73857 + GR_THREE_INT,
73858 + GR_FIVE_INT_TWO_STR,
73859 + GR_TWO_STR,
73860 + GR_THREE_STR,
73861 + GR_FOUR_STR,
73862 + GR_STR_FILENAME,
73863 + GR_FILENAME_STR,
73864 + GR_FILENAME_TWO_INT,
73865 + GR_FILENAME_TWO_INT_STR,
73866 + GR_TEXTREL,
73867 + GR_PTRACE,
73868 + GR_RESOURCE,
73869 + GR_CAP,
73870 + GR_SIG,
73871 + GR_SIG2,
73872 + GR_CRASH1,
73873 + GR_CRASH2,
73874 + GR_PSACCT,
73875 + GR_RWXMAP,
73876 + GR_RWXMAPVMA
73877 +};
73878 +
73879 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
73880 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
73881 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
73882 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
73883 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
73884 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
73885 +#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)
73886 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
73887 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
73888 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
73889 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
73890 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
73891 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
73892 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
73893 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
73894 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
73895 +#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)
73896 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
73897 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
73898 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
73899 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
73900 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
73901 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
73902 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
73903 +#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)
73904 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
73905 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
73906 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
73907 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
73908 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
73909 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
73910 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
73911 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
73912 +#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)
73913 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
73914 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
73915 +
73916 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
73917 +
73918 +#endif
73919 +
73920 +#endif
73921 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
73922 new file mode 100644
73923 index 0000000..a4396b5
73924 --- /dev/null
73925 +++ b/include/linux/grmsg.h
73926 @@ -0,0 +1,113 @@
73927 +#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"
73928 +#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"
73929 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
73930 +#define GR_STOPMOD_MSG "denied modification of module state by "
73931 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
73932 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
73933 +#define GR_IOPERM_MSG "denied use of ioperm() by "
73934 +#define GR_IOPL_MSG "denied use of iopl() by "
73935 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
73936 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
73937 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
73938 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
73939 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
73940 +#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"
73941 +#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"
73942 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
73943 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
73944 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
73945 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
73946 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
73947 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
73948 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
73949 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
73950 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
73951 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
73952 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
73953 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
73954 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
73955 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
73956 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
73957 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
73958 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
73959 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
73960 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
73961 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
73962 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
73963 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
73964 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
73965 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
73966 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
73967 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
73968 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
73969 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
73970 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
73971 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
73972 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
73973 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
73974 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
73975 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
73976 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
73977 +#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"
73978 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
73979 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
73980 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
73981 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
73982 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
73983 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
73984 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
73985 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
73986 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
73987 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
73988 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
73989 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
73990 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
73991 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
73992 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
73993 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
73994 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
73995 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
73996 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
73997 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
73998 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
73999 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74000 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74001 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74002 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74003 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74004 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74005 +#define GR_TIME_MSG "time set by "
74006 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74007 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74008 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74009 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74010 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74011 +#define GR_BIND_MSG "denied bind() by "
74012 +#define GR_CONNECT_MSG "denied connect() by "
74013 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74014 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74015 +#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"
74016 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74017 +#define GR_CAP_ACL_MSG "use of %s denied for "
74018 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74019 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74020 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74021 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74022 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74023 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74024 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74025 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74026 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74027 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74028 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74029 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74030 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74031 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74032 +#define GR_VM86_MSG "denied use of vm86 by "
74033 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74034 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74035 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74036 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74037 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74038 +#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 "
74039 +#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 "
74040 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74041 new file mode 100644
74042 index 0000000..d6f5a21
74043 --- /dev/null
74044 +++ b/include/linux/grsecurity.h
74045 @@ -0,0 +1,244 @@
74046 +#ifndef GR_SECURITY_H
74047 +#define GR_SECURITY_H
74048 +#include <linux/fs.h>
74049 +#include <linux/fs_struct.h>
74050 +#include <linux/binfmts.h>
74051 +#include <linux/gracl.h>
74052 +
74053 +/* notify of brain-dead configs */
74054 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74055 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74056 +#endif
74057 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74058 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74059 +#endif
74060 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74061 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74062 +#endif
74063 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74064 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74065 +#endif
74066 +
74067 +int gr_handle_new_usb(void);
74068 +
74069 +void gr_handle_brute_attach(unsigned long mm_flags);
74070 +void gr_handle_brute_check(void);
74071 +void gr_handle_kernel_exploit(void);
74072 +
74073 +char gr_roletype_to_char(void);
74074 +
74075 +int gr_acl_enable_at_secure(void);
74076 +
74077 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74078 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74079 +
74080 +void gr_del_task_from_ip_table(struct task_struct *p);
74081 +
74082 +int gr_pid_is_chrooted(struct task_struct *p);
74083 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74084 +int gr_handle_chroot_nice(void);
74085 +int gr_handle_chroot_sysctl(const int op);
74086 +int gr_handle_chroot_setpriority(struct task_struct *p,
74087 + const int niceval);
74088 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74089 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74090 + const struct vfsmount *mnt);
74091 +void gr_handle_chroot_chdir(const struct path *path);
74092 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74093 + const struct vfsmount *mnt, const int mode);
74094 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74095 + const struct vfsmount *mnt, const int mode);
74096 +int gr_handle_chroot_mount(const struct dentry *dentry,
74097 + const struct vfsmount *mnt,
74098 + const char *dev_name);
74099 +int gr_handle_chroot_pivot(void);
74100 +int gr_handle_chroot_unix(const pid_t pid);
74101 +
74102 +int gr_handle_rawio(const struct inode *inode);
74103 +
74104 +void gr_handle_ioperm(void);
74105 +void gr_handle_iopl(void);
74106 +
74107 +umode_t gr_acl_umask(void);
74108 +
74109 +int gr_tpe_allow(const struct file *file);
74110 +
74111 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74112 +void gr_clear_chroot_entries(struct task_struct *task);
74113 +
74114 +void gr_log_forkfail(const int retval);
74115 +void gr_log_timechange(void);
74116 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74117 +void gr_log_chdir(const struct dentry *dentry,
74118 + const struct vfsmount *mnt);
74119 +void gr_log_chroot_exec(const struct dentry *dentry,
74120 + const struct vfsmount *mnt);
74121 +void gr_log_remount(const char *devname, const int retval);
74122 +void gr_log_unmount(const char *devname, const int retval);
74123 +void gr_log_mount(const char *from, const char *to, const int retval);
74124 +void gr_log_textrel(struct vm_area_struct *vma);
74125 +void gr_log_ptgnustack(struct file *file);
74126 +void gr_log_rwxmmap(struct file *file);
74127 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74128 +
74129 +int gr_handle_follow_link(const struct inode *parent,
74130 + const struct inode *inode,
74131 + const struct dentry *dentry,
74132 + const struct vfsmount *mnt);
74133 +int gr_handle_fifo(const struct dentry *dentry,
74134 + const struct vfsmount *mnt,
74135 + const struct dentry *dir, const int flag,
74136 + const int acc_mode);
74137 +int gr_handle_hardlink(const struct dentry *dentry,
74138 + const struct vfsmount *mnt,
74139 + struct inode *inode,
74140 + const int mode, const struct filename *to);
74141 +
74142 +int gr_is_capable(const int cap);
74143 +int gr_is_capable_nolog(const int cap);
74144 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74145 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74146 +
74147 +void gr_copy_label(struct task_struct *tsk);
74148 +void gr_handle_crash(struct task_struct *task, const int sig);
74149 +int gr_handle_signal(const struct task_struct *p, const int sig);
74150 +int gr_check_crash_uid(const kuid_t uid);
74151 +int gr_check_protected_task(const struct task_struct *task);
74152 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74153 +int gr_acl_handle_mmap(const struct file *file,
74154 + const unsigned long prot);
74155 +int gr_acl_handle_mprotect(const struct file *file,
74156 + const unsigned long prot);
74157 +int gr_check_hidden_task(const struct task_struct *tsk);
74158 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74159 + const struct vfsmount *mnt);
74160 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74161 + const struct vfsmount *mnt);
74162 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74163 + const struct vfsmount *mnt, const int fmode);
74164 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74165 + const struct vfsmount *mnt, umode_t *mode);
74166 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74167 + const struct vfsmount *mnt);
74168 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74169 + const struct vfsmount *mnt);
74170 +int gr_handle_ptrace(struct task_struct *task, const long request);
74171 +int gr_handle_proc_ptrace(struct task_struct *task);
74172 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74173 + const struct vfsmount *mnt);
74174 +int gr_check_crash_exec(const struct file *filp);
74175 +int gr_acl_is_enabled(void);
74176 +void gr_set_kernel_label(struct task_struct *task);
74177 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74178 + const kgid_t gid);
74179 +int gr_set_proc_label(const struct dentry *dentry,
74180 + const struct vfsmount *mnt,
74181 + const int unsafe_flags);
74182 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74183 + const struct vfsmount *mnt);
74184 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74185 + const struct vfsmount *mnt, int acc_mode);
74186 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74187 + const struct dentry *p_dentry,
74188 + const struct vfsmount *p_mnt,
74189 + int open_flags, int acc_mode, const int imode);
74190 +void gr_handle_create(const struct dentry *dentry,
74191 + const struct vfsmount *mnt);
74192 +void gr_handle_proc_create(const struct dentry *dentry,
74193 + const struct inode *inode);
74194 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74195 + const struct dentry *parent_dentry,
74196 + const struct vfsmount *parent_mnt,
74197 + const int mode);
74198 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74199 + const struct dentry *parent_dentry,
74200 + const struct vfsmount *parent_mnt);
74201 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74202 + const struct vfsmount *mnt);
74203 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74204 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74205 + const struct vfsmount *mnt);
74206 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74207 + const struct dentry *parent_dentry,
74208 + const struct vfsmount *parent_mnt,
74209 + const struct filename *from);
74210 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74211 + const struct dentry *parent_dentry,
74212 + const struct vfsmount *parent_mnt,
74213 + const struct dentry *old_dentry,
74214 + const struct vfsmount *old_mnt, const struct filename *to);
74215 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74216 +int gr_acl_handle_rename(struct dentry *new_dentry,
74217 + struct dentry *parent_dentry,
74218 + const struct vfsmount *parent_mnt,
74219 + struct dentry *old_dentry,
74220 + struct inode *old_parent_inode,
74221 + struct vfsmount *old_mnt, const struct filename *newname);
74222 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74223 + struct dentry *old_dentry,
74224 + struct dentry *new_dentry,
74225 + struct vfsmount *mnt, const __u8 replace);
74226 +__u32 gr_check_link(const struct dentry *new_dentry,
74227 + const struct dentry *parent_dentry,
74228 + const struct vfsmount *parent_mnt,
74229 + const struct dentry *old_dentry,
74230 + const struct vfsmount *old_mnt);
74231 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74232 + const unsigned int namelen, const ino_t ino);
74233 +
74234 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74235 + const struct vfsmount *mnt);
74236 +void gr_acl_handle_exit(void);
74237 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74238 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74239 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74240 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74241 +void gr_audit_ptrace(struct task_struct *task);
74242 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74243 +void gr_put_exec_file(struct task_struct *task);
74244 +
74245 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74246 +
74247 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74248 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74249 + const unsigned long wanted, const int gt);
74250 +#else
74251 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74252 + const unsigned long wanted, const int gt)
74253 +{
74254 +}
74255 +#endif
74256 +
74257 +#ifdef CONFIG_GRKERNSEC_RESLOG
74258 +extern void gr_log_resource(const struct task_struct *task, const int res,
74259 + const unsigned long wanted, const int gt);
74260 +#else
74261 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74262 + const unsigned long wanted, const int gt)
74263 +{
74264 +}
74265 +#endif
74266 +
74267 +#ifdef CONFIG_GRKERNSEC
74268 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74269 +void gr_handle_vm86(void);
74270 +void gr_handle_mem_readwrite(u64 from, u64 to);
74271 +
74272 +void gr_log_badprocpid(const char *entry);
74273 +
74274 +extern int grsec_enable_dmesg;
74275 +extern int grsec_disable_privio;
74276 +
74277 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74278 +extern kgid_t grsec_proc_gid;
74279 +#endif
74280 +
74281 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74282 +extern int grsec_enable_chroot_findtask;
74283 +#endif
74284 +#ifdef CONFIG_GRKERNSEC_SETXID
74285 +extern int grsec_enable_setxid;
74286 +#endif
74287 +#endif
74288 +
74289 +#endif
74290 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74291 new file mode 100644
74292 index 0000000..e7ffaaf
74293 --- /dev/null
74294 +++ b/include/linux/grsock.h
74295 @@ -0,0 +1,19 @@
74296 +#ifndef __GRSOCK_H
74297 +#define __GRSOCK_H
74298 +
74299 +extern void gr_attach_curr_ip(const struct sock *sk);
74300 +extern int gr_handle_sock_all(const int family, const int type,
74301 + const int protocol);
74302 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74303 +extern int gr_handle_sock_server_other(const struct sock *sck);
74304 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74305 +extern int gr_search_connect(struct socket * sock,
74306 + struct sockaddr_in * addr);
74307 +extern int gr_search_bind(struct socket * sock,
74308 + struct sockaddr_in * addr);
74309 +extern int gr_search_listen(struct socket * sock);
74310 +extern int gr_search_accept(struct socket * sock);
74311 +extern int gr_search_socket(const int domain, const int type,
74312 + const int protocol);
74313 +
74314 +#endif
74315 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74316 index 7fb31da..08b5114 100644
74317 --- a/include/linux/highmem.h
74318 +++ b/include/linux/highmem.h
74319 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74320 kunmap_atomic(kaddr);
74321 }
74322
74323 +static inline void sanitize_highpage(struct page *page)
74324 +{
74325 + void *kaddr;
74326 + unsigned long flags;
74327 +
74328 + local_irq_save(flags);
74329 + kaddr = kmap_atomic(page);
74330 + clear_page(kaddr);
74331 + kunmap_atomic(kaddr);
74332 + local_irq_restore(flags);
74333 +}
74334 +
74335 static inline void zero_user_segments(struct page *page,
74336 unsigned start1, unsigned end1,
74337 unsigned start2, unsigned end2)
74338 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74339 index 1c7b89a..7f52502 100644
74340 --- a/include/linux/hwmon-sysfs.h
74341 +++ b/include/linux/hwmon-sysfs.h
74342 @@ -25,7 +25,8 @@
74343 struct sensor_device_attribute{
74344 struct device_attribute dev_attr;
74345 int index;
74346 -};
74347 +} __do_const;
74348 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74349 #define to_sensor_dev_attr(_dev_attr) \
74350 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74351
74352 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74353 struct device_attribute dev_attr;
74354 u8 index;
74355 u8 nr;
74356 -};
74357 +} __do_const;
74358 #define to_sensor_dev_attr_2(_dev_attr) \
74359 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74360
74361 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74362 index e988fa9..ff9f17e 100644
74363 --- a/include/linux/i2c.h
74364 +++ b/include/linux/i2c.h
74365 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74366 /* To determine what the adapter supports */
74367 u32 (*functionality) (struct i2c_adapter *);
74368 };
74369 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74370
74371 /**
74372 * struct i2c_bus_recovery_info - I2C bus recovery information
74373 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74374 index d23c3c2..eb63c81 100644
74375 --- a/include/linux/i2o.h
74376 +++ b/include/linux/i2o.h
74377 @@ -565,7 +565,7 @@ struct i2o_controller {
74378 struct i2o_device *exec; /* Executive */
74379 #if BITS_PER_LONG == 64
74380 spinlock_t context_list_lock; /* lock for context_list */
74381 - atomic_t context_list_counter; /* needed for unique contexts */
74382 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74383 struct list_head context_list; /* list of context id's
74384 and pointers */
74385 #endif
74386 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74387 index aff7ad8..3942bbd 100644
74388 --- a/include/linux/if_pppox.h
74389 +++ b/include/linux/if_pppox.h
74390 @@ -76,7 +76,7 @@ struct pppox_proto {
74391 int (*ioctl)(struct socket *sock, unsigned int cmd,
74392 unsigned long arg);
74393 struct module *owner;
74394 -};
74395 +} __do_const;
74396
74397 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74398 extern void unregister_pppox_proto(int proto_num);
74399 diff --git a/include/linux/init.h b/include/linux/init.h
74400 index e73f2b7..cc996e0 100644
74401 --- a/include/linux/init.h
74402 +++ b/include/linux/init.h
74403 @@ -39,9 +39,17 @@
74404 * Also note, that this data cannot be "const".
74405 */
74406
74407 +#define add_init_latent_entropy __latent_entropy
74408 +
74409 +#ifdef CONFIG_MEMORY_HOTPLUG
74410 +#define add_meminit_latent_entropy
74411 +#else
74412 +#define add_meminit_latent_entropy __latent_entropy
74413 +#endif
74414 +
74415 /* These are for everybody (although not all archs will actually
74416 discard it in modules) */
74417 -#define __init __section(.init.text) __cold notrace
74418 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74419 #define __initdata __section(.init.data)
74420 #define __initconst __constsection(.init.rodata)
74421 #define __exitdata __section(.exit.data)
74422 @@ -102,7 +110,7 @@
74423 #define __cpuexitconst
74424
74425 /* Used for MEMORY_HOTPLUG */
74426 -#define __meminit __section(.meminit.text) __cold notrace
74427 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74428 #define __meminitdata __section(.meminit.data)
74429 #define __meminitconst __constsection(.meminit.rodata)
74430 #define __memexit __section(.memexit.text) __exitused __cold notrace
74431 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74432 index 5cd0f09..c9f67cc 100644
74433 --- a/include/linux/init_task.h
74434 +++ b/include/linux/init_task.h
74435 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74436
74437 #define INIT_TASK_COMM "swapper"
74438
74439 +#ifdef CONFIG_X86
74440 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74441 +#else
74442 +#define INIT_TASK_THREAD_INFO
74443 +#endif
74444 +
74445 /*
74446 * INIT_TASK is used to set up the first task table, touch at
74447 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74448 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74449 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74450 .comm = INIT_TASK_COMM, \
74451 .thread = INIT_THREAD, \
74452 + INIT_TASK_THREAD_INFO \
74453 .fs = &init_fs, \
74454 .files = &init_files, \
74455 .signal = &init_signals, \
74456 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74457 index 5fa5afe..ac55b25 100644
74458 --- a/include/linux/interrupt.h
74459 +++ b/include/linux/interrupt.h
74460 @@ -430,7 +430,7 @@ enum
74461 /* map softirq index to softirq name. update 'softirq_to_name' in
74462 * kernel/softirq.c when adding a new softirq.
74463 */
74464 -extern char *softirq_to_name[NR_SOFTIRQS];
74465 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74466
74467 /* softirq mask and active fields moved to irq_cpustat_t in
74468 * asm/hardirq.h to get better cache usage. KAO
74469 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74470
74471 struct softirq_action
74472 {
74473 - void (*action)(struct softirq_action *);
74474 -};
74475 + void (*action)(void);
74476 +} __no_const;
74477
74478 asmlinkage void do_softirq(void);
74479 asmlinkage void __do_softirq(void);
74480 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74481 +extern void open_softirq(int nr, void (*action)(void));
74482 extern void softirq_init(void);
74483 extern void __raise_softirq_irqoff(unsigned int nr);
74484
74485 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74486 index 3aeb730..2177f39 100644
74487 --- a/include/linux/iommu.h
74488 +++ b/include/linux/iommu.h
74489 @@ -113,7 +113,7 @@ struct iommu_ops {
74490 u32 (*domain_get_windows)(struct iommu_domain *domain);
74491
74492 unsigned long pgsize_bitmap;
74493 -};
74494 +} __do_const;
74495
74496 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74497 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74498 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74499 index 89b7c24..382af74 100644
74500 --- a/include/linux/ioport.h
74501 +++ b/include/linux/ioport.h
74502 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74503 int adjust_resource(struct resource *res, resource_size_t start,
74504 resource_size_t size);
74505 resource_size_t resource_alignment(struct resource *res);
74506 -static inline resource_size_t resource_size(const struct resource *res)
74507 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74508 {
74509 return res->end - res->start + 1;
74510 }
74511 diff --git a/include/linux/irq.h b/include/linux/irq.h
74512 index f04d3ba..bcf2cfb 100644
74513 --- a/include/linux/irq.h
74514 +++ b/include/linux/irq.h
74515 @@ -333,7 +333,8 @@ struct irq_chip {
74516 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74517
74518 unsigned long flags;
74519 -};
74520 +} __do_const;
74521 +typedef struct irq_chip __no_const irq_chip_no_const;
74522
74523 /*
74524 * irq_chip specific flags
74525 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74526 index 3e203eb..3fe68d0 100644
74527 --- a/include/linux/irqchip/arm-gic.h
74528 +++ b/include/linux/irqchip/arm-gic.h
74529 @@ -59,9 +59,11 @@
74530
74531 #ifndef __ASSEMBLY__
74532
74533 +#include <linux/irq.h>
74534 +
74535 struct device_node;
74536
74537 -extern struct irq_chip gic_arch_extn;
74538 +extern irq_chip_no_const gic_arch_extn;
74539
74540 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74541 u32 offset, struct device_node *);
74542 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74543 index 6883e19..e854fcb 100644
74544 --- a/include/linux/kallsyms.h
74545 +++ b/include/linux/kallsyms.h
74546 @@ -15,7 +15,8 @@
74547
74548 struct module;
74549
74550 -#ifdef CONFIG_KALLSYMS
74551 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74552 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74553 /* Lookup the address for a symbol. Returns 0 if not found. */
74554 unsigned long kallsyms_lookup_name(const char *name);
74555
74556 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74557 /* Stupid that this does nothing, but I didn't create this mess. */
74558 #define __print_symbol(fmt, addr)
74559 #endif /*CONFIG_KALLSYMS*/
74560 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74561 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74562 +extern unsigned long kallsyms_lookup_name(const char *name);
74563 +extern void __print_symbol(const char *fmt, unsigned long address);
74564 +extern int sprint_backtrace(char *buffer, unsigned long address);
74565 +extern int sprint_symbol(char *buffer, unsigned long address);
74566 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74567 +const char *kallsyms_lookup(unsigned long addr,
74568 + unsigned long *symbolsize,
74569 + unsigned long *offset,
74570 + char **modname, char *namebuf);
74571 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74572 + unsigned long *symbolsize,
74573 + unsigned long *offset);
74574 +#endif
74575
74576 /* This macro allows us to keep printk typechecking */
74577 static __printf(1, 2)
74578 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74579 index 518a53a..5e28358 100644
74580 --- a/include/linux/key-type.h
74581 +++ b/include/linux/key-type.h
74582 @@ -125,7 +125,7 @@ struct key_type {
74583 /* internal fields */
74584 struct list_head link; /* link in types list */
74585 struct lock_class_key lock_class; /* key->sem lock class */
74586 -};
74587 +} __do_const;
74588
74589 extern struct key_type key_type_keyring;
74590
74591 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74592 index c6e091b..a940adf 100644
74593 --- a/include/linux/kgdb.h
74594 +++ b/include/linux/kgdb.h
74595 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74596 extern int kgdb_io_module_registered;
74597
74598 extern atomic_t kgdb_setting_breakpoint;
74599 -extern atomic_t kgdb_cpu_doing_single_step;
74600 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74601
74602 extern struct task_struct *kgdb_usethread;
74603 extern struct task_struct *kgdb_contthread;
74604 @@ -254,7 +254,7 @@ struct kgdb_arch {
74605 void (*correct_hw_break)(void);
74606
74607 void (*enable_nmi)(bool on);
74608 -};
74609 +} __do_const;
74610
74611 /**
74612 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74613 @@ -279,7 +279,7 @@ struct kgdb_io {
74614 void (*pre_exception) (void);
74615 void (*post_exception) (void);
74616 int is_console;
74617 -};
74618 +} __do_const;
74619
74620 extern struct kgdb_arch arch_kgdb_ops;
74621
74622 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74623 index 0555cc6..b16a7a4 100644
74624 --- a/include/linux/kmod.h
74625 +++ b/include/linux/kmod.h
74626 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74627 * usually useless though. */
74628 extern __printf(2, 3)
74629 int __request_module(bool wait, const char *name, ...);
74630 +extern __printf(3, 4)
74631 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74632 #define request_module(mod...) __request_module(true, mod)
74633 #define request_module_nowait(mod...) __request_module(false, mod)
74634 #define try_then_request_module(x, mod...) \
74635 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74636 index 939b112..ed6ed51 100644
74637 --- a/include/linux/kobject.h
74638 +++ b/include/linux/kobject.h
74639 @@ -111,7 +111,7 @@ struct kobj_type {
74640 struct attribute **default_attrs;
74641 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74642 const void *(*namespace)(struct kobject *kobj);
74643 -};
74644 +} __do_const;
74645
74646 struct kobj_uevent_env {
74647 char *envp[UEVENT_NUM_ENVP];
74648 @@ -134,6 +134,7 @@ struct kobj_attribute {
74649 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74650 const char *buf, size_t count);
74651 };
74652 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74653
74654 extern const struct sysfs_ops kobj_sysfs_ops;
74655
74656 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74657 index f66b065..c2c29b4 100644
74658 --- a/include/linux/kobject_ns.h
74659 +++ b/include/linux/kobject_ns.h
74660 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74661 const void *(*netlink_ns)(struct sock *sk);
74662 const void *(*initial_ns)(void);
74663 void (*drop_ns)(void *);
74664 -};
74665 +} __do_const;
74666
74667 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74668 int kobj_ns_type_registered(enum kobj_ns_type type);
74669 diff --git a/include/linux/kref.h b/include/linux/kref.h
74670 index 484604d..0f6c5b6 100644
74671 --- a/include/linux/kref.h
74672 +++ b/include/linux/kref.h
74673 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74674 static inline int kref_sub(struct kref *kref, unsigned int count,
74675 void (*release)(struct kref *kref))
74676 {
74677 - WARN_ON(release == NULL);
74678 + BUG_ON(release == NULL);
74679
74680 if (atomic_sub_and_test((int) count, &kref->refcount)) {
74681 release(kref);
74682 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
74683 index a63d83e..77fd685 100644
74684 --- a/include/linux/kvm_host.h
74685 +++ b/include/linux/kvm_host.h
74686 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
74687 {
74688 }
74689 #endif
74690 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74691 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74692 struct module *module);
74693 void kvm_exit(void);
74694
74695 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
74696 struct kvm_guest_debug *dbg);
74697 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
74698
74699 -int kvm_arch_init(void *opaque);
74700 +int kvm_arch_init(const void *opaque);
74701 void kvm_arch_exit(void);
74702
74703 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
74704 diff --git a/include/linux/libata.h b/include/linux/libata.h
74705 index 4ea55bb..dcd2601 100644
74706 --- a/include/linux/libata.h
74707 +++ b/include/linux/libata.h
74708 @@ -924,7 +924,7 @@ struct ata_port_operations {
74709 * fields must be pointers.
74710 */
74711 const struct ata_port_operations *inherits;
74712 -};
74713 +} __do_const;
74714
74715 struct ata_port_info {
74716 unsigned long flags;
74717 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
74718 index d3e8ad2..a949f68 100644
74719 --- a/include/linux/linkage.h
74720 +++ b/include/linux/linkage.h
74721 @@ -31,6 +31,7 @@
74722 #endif
74723
74724 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
74725 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
74726 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
74727
74728 /*
74729 diff --git a/include/linux/list.h b/include/linux/list.h
74730 index f4d8a2f..38e6e46 100644
74731 --- a/include/linux/list.h
74732 +++ b/include/linux/list.h
74733 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
74734 extern void list_del(struct list_head *entry);
74735 #endif
74736
74737 +extern void __pax_list_add(struct list_head *new,
74738 + struct list_head *prev,
74739 + struct list_head *next);
74740 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
74741 +{
74742 + __pax_list_add(new, head, head->next);
74743 +}
74744 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
74745 +{
74746 + __pax_list_add(new, head->prev, head);
74747 +}
74748 +extern void pax_list_del(struct list_head *entry);
74749 +
74750 /**
74751 * list_replace - replace old entry by new one
74752 * @old : the element to be replaced
74753 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
74754 INIT_LIST_HEAD(entry);
74755 }
74756
74757 +extern void pax_list_del_init(struct list_head *entry);
74758 +
74759 /**
74760 * list_move - delete from one list and add as another's head
74761 * @list: the entry to move
74762 diff --git a/include/linux/math64.h b/include/linux/math64.h
74763 index 2913b86..8dcbb1e 100644
74764 --- a/include/linux/math64.h
74765 +++ b/include/linux/math64.h
74766 @@ -15,7 +15,7 @@
74767 * This is commonly provided by 32bit archs to provide an optimized 64bit
74768 * divide.
74769 */
74770 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74771 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74772 {
74773 *remainder = dividend % divisor;
74774 return dividend / divisor;
74775 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
74776 /**
74777 * div64_u64 - unsigned 64bit divide with 64bit divisor
74778 */
74779 -static inline u64 div64_u64(u64 dividend, u64 divisor)
74780 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
74781 {
74782 return dividend / divisor;
74783 }
74784 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
74785 #define div64_ul(x, y) div_u64((x), (y))
74786
74787 #ifndef div_u64_rem
74788 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74789 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74790 {
74791 *remainder = do_div(dividend, divisor);
74792 return dividend;
74793 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
74794 * divide.
74795 */
74796 #ifndef div_u64
74797 -static inline u64 div_u64(u64 dividend, u32 divisor)
74798 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
74799 {
74800 u32 remainder;
74801 return div_u64_rem(dividend, divisor, &remainder);
74802 diff --git a/include/linux/mm.h b/include/linux/mm.h
74803 index f022460..6ecf4f9 100644
74804 --- a/include/linux/mm.h
74805 +++ b/include/linux/mm.h
74806 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
74807 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
74808 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
74809 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
74810 +
74811 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
74812 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
74813 +#endif
74814 +
74815 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
74816
74817 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
74818 @@ -208,8 +213,8 @@ struct vm_operations_struct {
74819 /* called by access_process_vm when get_user_pages() fails, typically
74820 * for use by special VMAs that can switch between memory and hardware
74821 */
74822 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
74823 - void *buf, int len, int write);
74824 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
74825 + void *buf, size_t len, int write);
74826 #ifdef CONFIG_NUMA
74827 /*
74828 * set_policy() op must add a reference to any non-NULL @new mempolicy
74829 @@ -239,6 +244,7 @@ struct vm_operations_struct {
74830 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
74831 unsigned long size, pgoff_t pgoff);
74832 };
74833 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
74834
74835 struct mmu_gather;
74836 struct inode;
74837 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
74838 unsigned long *pfn);
74839 int follow_phys(struct vm_area_struct *vma, unsigned long address,
74840 unsigned int flags, unsigned long *prot, resource_size_t *phys);
74841 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
74842 - void *buf, int len, int write);
74843 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
74844 + void *buf, size_t len, int write);
74845
74846 static inline void unmap_shared_mapping_range(struct address_space *mapping,
74847 loff_t const holebegin, loff_t const holelen)
74848 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
74849 }
74850 #endif
74851
74852 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
74853 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
74854 - void *buf, int len, int write);
74855 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
74856 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
74857 + void *buf, size_t len, int write);
74858
74859 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
74860 unsigned long start, unsigned long nr_pages,
74861 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
74862 int set_page_dirty_lock(struct page *page);
74863 int clear_page_dirty_for_io(struct page *page);
74864
74865 -/* Is the vma a continuation of the stack vma above it? */
74866 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
74867 -{
74868 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
74869 -}
74870 -
74871 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
74872 - unsigned long addr)
74873 -{
74874 - return (vma->vm_flags & VM_GROWSDOWN) &&
74875 - (vma->vm_start == addr) &&
74876 - !vma_growsdown(vma->vm_prev, addr);
74877 -}
74878 -
74879 -/* Is the vma a continuation of the stack vma below it? */
74880 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
74881 -{
74882 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
74883 -}
74884 -
74885 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
74886 - unsigned long addr)
74887 -{
74888 - return (vma->vm_flags & VM_GROWSUP) &&
74889 - (vma->vm_end == addr) &&
74890 - !vma_growsup(vma->vm_next, addr);
74891 -}
74892 -
74893 extern pid_t
74894 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
74895
74896 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
74897 }
74898 #endif
74899
74900 +#ifdef CONFIG_MMU
74901 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
74902 +#else
74903 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
74904 +{
74905 + return __pgprot(0);
74906 +}
74907 +#endif
74908 +
74909 int vma_wants_writenotify(struct vm_area_struct *vma);
74910
74911 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
74912 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
74913 {
74914 return 0;
74915 }
74916 +
74917 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
74918 + unsigned long address)
74919 +{
74920 + return 0;
74921 +}
74922 #else
74923 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
74924 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
74925 #endif
74926
74927 #ifdef __PAGETABLE_PMD_FOLDED
74928 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
74929 {
74930 return 0;
74931 }
74932 +
74933 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
74934 + unsigned long address)
74935 +{
74936 + return 0;
74937 +}
74938 #else
74939 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
74940 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
74941 #endif
74942
74943 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
74944 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
74945 NULL: pud_offset(pgd, address);
74946 }
74947
74948 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
74949 +{
74950 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
74951 + NULL: pud_offset(pgd, address);
74952 +}
74953 +
74954 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
74955 {
74956 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
74957 NULL: pmd_offset(pud, address);
74958 }
74959 +
74960 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
74961 +{
74962 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
74963 + NULL: pmd_offset(pud, address);
74964 +}
74965 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
74966
74967 #if USE_SPLIT_PTLOCKS
74968 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
74969 unsigned long len, unsigned long prot, unsigned long flags,
74970 unsigned long pgoff, unsigned long *populate);
74971 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
74972 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
74973
74974 #ifdef CONFIG_MMU
74975 extern int __mm_populate(unsigned long addr, unsigned long len,
74976 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
74977 unsigned long high_limit;
74978 unsigned long align_mask;
74979 unsigned long align_offset;
74980 + unsigned long threadstack_offset;
74981 };
74982
74983 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
74984 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
74985 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
74986 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
74987
74988 /*
74989 * Search for an unmapped address range.
74990 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
74991 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
74992 */
74993 static inline unsigned long
74994 -vm_unmapped_area(struct vm_unmapped_area_info *info)
74995 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
74996 {
74997 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
74998 return unmapped_area(info);
74999 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75000 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75001 struct vm_area_struct **pprev);
75002
75003 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75004 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75005 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75006 +
75007 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75008 NULL if none. Assume start_addr < end_addr. */
75009 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75010 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75011 return vma;
75012 }
75013
75014 -#ifdef CONFIG_MMU
75015 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75016 -#else
75017 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75018 -{
75019 - return __pgprot(0);
75020 -}
75021 -#endif
75022 -
75023 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75024 unsigned long change_prot_numa(struct vm_area_struct *vma,
75025 unsigned long start, unsigned long end);
75026 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75027 static inline void vm_stat_account(struct mm_struct *mm,
75028 unsigned long flags, struct file *file, long pages)
75029 {
75030 +
75031 +#ifdef CONFIG_PAX_RANDMMAP
75032 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75033 +#endif
75034 +
75035 mm->total_vm += pages;
75036 }
75037 #endif /* CONFIG_PROC_FS */
75038 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75039 extern int sysctl_memory_failure_early_kill;
75040 extern int sysctl_memory_failure_recovery;
75041 extern void shake_page(struct page *p, int access);
75042 -extern atomic_long_t num_poisoned_pages;
75043 +extern atomic_long_unchecked_t num_poisoned_pages;
75044 extern int soft_offline_page(struct page *page, int flags);
75045
75046 extern void dump_page(struct page *page);
75047 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75048 static inline void setup_nr_node_ids(void) {}
75049 #endif
75050
75051 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75052 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75053 +#else
75054 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75055 +#endif
75056 +
75057 #endif /* __KERNEL__ */
75058 #endif /* _LINUX_MM_H */
75059 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75060 index faf4b7c..1e70c6e 100644
75061 --- a/include/linux/mm_types.h
75062 +++ b/include/linux/mm_types.h
75063 @@ -289,6 +289,8 @@ struct vm_area_struct {
75064 #ifdef CONFIG_NUMA
75065 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75066 #endif
75067 +
75068 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75069 };
75070
75071 struct core_thread {
75072 @@ -435,6 +437,24 @@ struct mm_struct {
75073 int first_nid;
75074 #endif
75075 struct uprobes_state uprobes_state;
75076 +
75077 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75078 + unsigned long pax_flags;
75079 +#endif
75080 +
75081 +#ifdef CONFIG_PAX_DLRESOLVE
75082 + unsigned long call_dl_resolve;
75083 +#endif
75084 +
75085 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75086 + unsigned long call_syscall;
75087 +#endif
75088 +
75089 +#ifdef CONFIG_PAX_ASLR
75090 + unsigned long delta_mmap; /* randomized offset */
75091 + unsigned long delta_stack; /* randomized offset */
75092 +#endif
75093 +
75094 };
75095
75096 /* first nid will either be a valid NID or one of these values */
75097 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75098 index c5d5278..f0b68c8 100644
75099 --- a/include/linux/mmiotrace.h
75100 +++ b/include/linux/mmiotrace.h
75101 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75102 /* Called from ioremap.c */
75103 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75104 void __iomem *addr);
75105 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75106 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75107
75108 /* For anyone to insert markers. Remember trailing newline. */
75109 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75110 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75111 {
75112 }
75113
75114 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75115 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75116 {
75117 }
75118
75119 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75120 index af4a3b7..9ad8889 100644
75121 --- a/include/linux/mmzone.h
75122 +++ b/include/linux/mmzone.h
75123 @@ -396,7 +396,7 @@ struct zone {
75124 unsigned long flags; /* zone flags, see below */
75125
75126 /* Zone statistics */
75127 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75128 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75129
75130 /*
75131 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75132 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75133 index 45e9214..a7227d6 100644
75134 --- a/include/linux/mod_devicetable.h
75135 +++ b/include/linux/mod_devicetable.h
75136 @@ -13,7 +13,7 @@
75137 typedef unsigned long kernel_ulong_t;
75138 #endif
75139
75140 -#define PCI_ANY_ID (~0)
75141 +#define PCI_ANY_ID ((__u16)~0)
75142
75143 struct pci_device_id {
75144 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75145 @@ -139,7 +139,7 @@ struct usb_device_id {
75146 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75147 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75148
75149 -#define HID_ANY_ID (~0)
75150 +#define HID_ANY_ID (~0U)
75151 #define HID_BUS_ANY 0xffff
75152 #define HID_GROUP_ANY 0x0000
75153
75154 @@ -467,7 +467,7 @@ struct dmi_system_id {
75155 const char *ident;
75156 struct dmi_strmatch matches[4];
75157 void *driver_data;
75158 -};
75159 +} __do_const;
75160 /*
75161 * struct dmi_device_id appears during expansion of
75162 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75163 diff --git a/include/linux/module.h b/include/linux/module.h
75164 index 46f1ea0..a34ca37 100644
75165 --- a/include/linux/module.h
75166 +++ b/include/linux/module.h
75167 @@ -17,9 +17,11 @@
75168 #include <linux/moduleparam.h>
75169 #include <linux/tracepoint.h>
75170 #include <linux/export.h>
75171 +#include <linux/fs.h>
75172
75173 #include <linux/percpu.h>
75174 #include <asm/module.h>
75175 +#include <asm/pgtable.h>
75176
75177 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75178 #define MODULE_SIG_STRING "~Module signature appended~\n"
75179 @@ -54,12 +56,13 @@ struct module_attribute {
75180 int (*test)(struct module *);
75181 void (*free)(struct module *);
75182 };
75183 +typedef struct module_attribute __no_const module_attribute_no_const;
75184
75185 struct module_version_attribute {
75186 struct module_attribute mattr;
75187 const char *module_name;
75188 const char *version;
75189 -} __attribute__ ((__aligned__(sizeof(void *))));
75190 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75191
75192 extern ssize_t __modver_version_show(struct module_attribute *,
75193 struct module_kobject *, char *);
75194 @@ -232,7 +235,7 @@ struct module
75195
75196 /* Sysfs stuff. */
75197 struct module_kobject mkobj;
75198 - struct module_attribute *modinfo_attrs;
75199 + module_attribute_no_const *modinfo_attrs;
75200 const char *version;
75201 const char *srcversion;
75202 struct kobject *holders_dir;
75203 @@ -281,19 +284,16 @@ struct module
75204 int (*init)(void);
75205
75206 /* If this is non-NULL, vfree after init() returns */
75207 - void *module_init;
75208 + void *module_init_rx, *module_init_rw;
75209
75210 /* Here is the actual code + data, vfree'd on unload. */
75211 - void *module_core;
75212 + void *module_core_rx, *module_core_rw;
75213
75214 /* Here are the sizes of the init and core sections */
75215 - unsigned int init_size, core_size;
75216 + unsigned int init_size_rw, core_size_rw;
75217
75218 /* The size of the executable code in each section. */
75219 - unsigned int init_text_size, core_text_size;
75220 -
75221 - /* Size of RO sections of the module (text+rodata) */
75222 - unsigned int init_ro_size, core_ro_size;
75223 + unsigned int init_size_rx, core_size_rx;
75224
75225 /* Arch-specific module values */
75226 struct mod_arch_specific arch;
75227 @@ -349,6 +349,10 @@ struct module
75228 #ifdef CONFIG_EVENT_TRACING
75229 struct ftrace_event_call **trace_events;
75230 unsigned int num_trace_events;
75231 + struct file_operations trace_id;
75232 + struct file_operations trace_enable;
75233 + struct file_operations trace_format;
75234 + struct file_operations trace_filter;
75235 #endif
75236 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75237 unsigned int num_ftrace_callsites;
75238 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75239 bool is_module_percpu_address(unsigned long addr);
75240 bool is_module_text_address(unsigned long addr);
75241
75242 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75243 +{
75244 +
75245 +#ifdef CONFIG_PAX_KERNEXEC
75246 + if (ktla_ktva(addr) >= (unsigned long)start &&
75247 + ktla_ktva(addr) < (unsigned long)start + size)
75248 + return 1;
75249 +#endif
75250 +
75251 + return ((void *)addr >= start && (void *)addr < start + size);
75252 +}
75253 +
75254 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75255 +{
75256 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75257 +}
75258 +
75259 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75260 +{
75261 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75262 +}
75263 +
75264 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75265 +{
75266 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75267 +}
75268 +
75269 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75270 +{
75271 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75272 +}
75273 +
75274 static inline int within_module_core(unsigned long addr, const struct module *mod)
75275 {
75276 - return (unsigned long)mod->module_core <= addr &&
75277 - addr < (unsigned long)mod->module_core + mod->core_size;
75278 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75279 }
75280
75281 static inline int within_module_init(unsigned long addr, const struct module *mod)
75282 {
75283 - return (unsigned long)mod->module_init <= addr &&
75284 - addr < (unsigned long)mod->module_init + mod->init_size;
75285 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75286 }
75287
75288 /* Search for module by name: must hold module_mutex. */
75289 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75290 index 560ca53..ef621ef 100644
75291 --- a/include/linux/moduleloader.h
75292 +++ b/include/linux/moduleloader.h
75293 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75294 sections. Returns NULL on failure. */
75295 void *module_alloc(unsigned long size);
75296
75297 +#ifdef CONFIG_PAX_KERNEXEC
75298 +void *module_alloc_exec(unsigned long size);
75299 +#else
75300 +#define module_alloc_exec(x) module_alloc(x)
75301 +#endif
75302 +
75303 /* Free memory returned from module_alloc. */
75304 void module_free(struct module *mod, void *module_region);
75305
75306 +#ifdef CONFIG_PAX_KERNEXEC
75307 +void module_free_exec(struct module *mod, void *module_region);
75308 +#else
75309 +#define module_free_exec(x, y) module_free((x), (y))
75310 +#endif
75311 +
75312 /*
75313 * Apply the given relocation to the (simplified) ELF. Return -error
75314 * or 0.
75315 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75316 unsigned int relsec,
75317 struct module *me)
75318 {
75319 +#ifdef CONFIG_MODULES
75320 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75321 +#endif
75322 return -ENOEXEC;
75323 }
75324 #endif
75325 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75326 unsigned int relsec,
75327 struct module *me)
75328 {
75329 +#ifdef CONFIG_MODULES
75330 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75331 +#endif
75332 return -ENOEXEC;
75333 }
75334 #endif
75335 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75336 index 27d9da3..5d94aa3 100644
75337 --- a/include/linux/moduleparam.h
75338 +++ b/include/linux/moduleparam.h
75339 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75340 * @len is usually just sizeof(string).
75341 */
75342 #define module_param_string(name, string, len, perm) \
75343 - static const struct kparam_string __param_string_##name \
75344 + static const struct kparam_string __param_string_##name __used \
75345 = { len, string }; \
75346 __module_param_call(MODULE_PARAM_PREFIX, name, \
75347 &param_ops_string, \
75348 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75349 */
75350 #define module_param_array_named(name, array, type, nump, perm) \
75351 param_check_##type(name, &(array)[0]); \
75352 - static const struct kparam_array __param_arr_##name \
75353 + static const struct kparam_array __param_arr_##name __used \
75354 = { .max = ARRAY_SIZE(array), .num = nump, \
75355 .ops = &param_ops_##type, \
75356 .elemsize = sizeof(array[0]), .elem = array }; \
75357 diff --git a/include/linux/namei.h b/include/linux/namei.h
75358 index 5a5ff57..5ae5070 100644
75359 --- a/include/linux/namei.h
75360 +++ b/include/linux/namei.h
75361 @@ -19,7 +19,7 @@ struct nameidata {
75362 unsigned seq;
75363 int last_type;
75364 unsigned depth;
75365 - char *saved_names[MAX_NESTED_LINKS + 1];
75366 + const char *saved_names[MAX_NESTED_LINKS + 1];
75367 };
75368
75369 /*
75370 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75371
75372 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75373
75374 -static inline void nd_set_link(struct nameidata *nd, char *path)
75375 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75376 {
75377 nd->saved_names[nd->depth] = path;
75378 }
75379
75380 -static inline char *nd_get_link(struct nameidata *nd)
75381 +static inline const char *nd_get_link(const struct nameidata *nd)
75382 {
75383 return nd->saved_names[nd->depth];
75384 }
75385 diff --git a/include/linux/net.h b/include/linux/net.h
75386 index 4f27575..fc8a65f 100644
75387 --- a/include/linux/net.h
75388 +++ b/include/linux/net.h
75389 @@ -183,7 +183,7 @@ struct net_proto_family {
75390 int (*create)(struct net *net, struct socket *sock,
75391 int protocol, int kern);
75392 struct module *owner;
75393 -};
75394 +} __do_const;
75395
75396 struct iovec;
75397 struct kvec;
75398 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75399 index 9a41568..203d903 100644
75400 --- a/include/linux/netdevice.h
75401 +++ b/include/linux/netdevice.h
75402 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75403 int (*ndo_change_carrier)(struct net_device *dev,
75404 bool new_carrier);
75405 };
75406 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75407
75408 /*
75409 * The DEVICE structure.
75410 @@ -1131,7 +1132,7 @@ struct net_device {
75411 int iflink;
75412
75413 struct net_device_stats stats;
75414 - atomic_long_t rx_dropped; /* dropped packets by core network
75415 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75416 * Do not use this in drivers.
75417 */
75418
75419 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75420 index de70f7b..2675e91 100644
75421 --- a/include/linux/netfilter.h
75422 +++ b/include/linux/netfilter.h
75423 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75424 #endif
75425 /* Use the module struct to lock set/get code in place */
75426 struct module *owner;
75427 -};
75428 +} __do_const;
75429
75430 /* Function to register/unregister hook points. */
75431 int nf_register_hook(struct nf_hook_ops *reg);
75432 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75433 index d80e275..c3510b8 100644
75434 --- a/include/linux/netfilter/ipset/ip_set.h
75435 +++ b/include/linux/netfilter/ipset/ip_set.h
75436 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75437 /* Return true if "b" set is the same as "a"
75438 * according to the create set parameters */
75439 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75440 -};
75441 +} __do_const;
75442
75443 /* The core set type structure */
75444 struct ip_set_type {
75445 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75446 index cadb740..d7c37c0 100644
75447 --- a/include/linux/netfilter/nfnetlink.h
75448 +++ b/include/linux/netfilter/nfnetlink.h
75449 @@ -16,7 +16,7 @@ struct nfnl_callback {
75450 const struct nlattr * const cda[]);
75451 const struct nla_policy *policy; /* netlink attribute policy */
75452 const u_int16_t attr_count; /* number of nlattr's */
75453 -};
75454 +} __do_const;
75455
75456 struct nfnetlink_subsystem {
75457 const char *name;
75458 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75459 new file mode 100644
75460 index 0000000..33f4af8
75461 --- /dev/null
75462 +++ b/include/linux/netfilter/xt_gradm.h
75463 @@ -0,0 +1,9 @@
75464 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75465 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75466 +
75467 +struct xt_gradm_mtinfo {
75468 + __u16 flags;
75469 + __u16 invflags;
75470 +};
75471 +
75472 +#endif
75473 diff --git a/include/linux/nls.h b/include/linux/nls.h
75474 index 5dc635f..35f5e11 100644
75475 --- a/include/linux/nls.h
75476 +++ b/include/linux/nls.h
75477 @@ -31,7 +31,7 @@ struct nls_table {
75478 const unsigned char *charset2upper;
75479 struct module *owner;
75480 struct nls_table *next;
75481 -};
75482 +} __do_const;
75483
75484 /* this value hold the maximum octet of charset */
75485 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75486 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75487 index d14a4c3..a078786 100644
75488 --- a/include/linux/notifier.h
75489 +++ b/include/linux/notifier.h
75490 @@ -54,7 +54,8 @@ struct notifier_block {
75491 notifier_fn_t notifier_call;
75492 struct notifier_block __rcu *next;
75493 int priority;
75494 -};
75495 +} __do_const;
75496 +typedef struct notifier_block __no_const notifier_block_no_const;
75497
75498 struct atomic_notifier_head {
75499 spinlock_t lock;
75500 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75501 index a4c5624..79d6d88 100644
75502 --- a/include/linux/oprofile.h
75503 +++ b/include/linux/oprofile.h
75504 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75505 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75506 char const * name, ulong * val);
75507
75508 -/** Create a file for read-only access to an atomic_t. */
75509 +/** Create a file for read-only access to an atomic_unchecked_t. */
75510 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75511 - char const * name, atomic_t * val);
75512 + char const * name, atomic_unchecked_t * val);
75513
75514 /** create a directory */
75515 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75516 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75517 index 8db71dc..a76bf2c 100644
75518 --- a/include/linux/pci_hotplug.h
75519 +++ b/include/linux/pci_hotplug.h
75520 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75521 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75522 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75523 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75524 -};
75525 +} __do_const;
75526 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75527
75528 /**
75529 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75530 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75531 index c43f6ea..2d4416f 100644
75532 --- a/include/linux/perf_event.h
75533 +++ b/include/linux/perf_event.h
75534 @@ -328,8 +328,8 @@ struct perf_event {
75535
75536 enum perf_event_active_state state;
75537 unsigned int attach_state;
75538 - local64_t count;
75539 - atomic64_t child_count;
75540 + local64_t count; /* PaX: fix it one day */
75541 + atomic64_unchecked_t child_count;
75542
75543 /*
75544 * These are the total time in nanoseconds that the event
75545 @@ -380,8 +380,8 @@ struct perf_event {
75546 * These accumulate total time (in nanoseconds) that children
75547 * events have been enabled and running, respectively.
75548 */
75549 - atomic64_t child_total_time_enabled;
75550 - atomic64_t child_total_time_running;
75551 + atomic64_unchecked_t child_total_time_enabled;
75552 + atomic64_unchecked_t child_total_time_running;
75553
75554 /*
75555 * Protect attach/detach and child_list:
75556 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75557 entry->ip[entry->nr++] = ip;
75558 }
75559
75560 -extern int sysctl_perf_event_paranoid;
75561 +extern int sysctl_perf_event_legitimately_concerned;
75562 extern int sysctl_perf_event_mlock;
75563 extern int sysctl_perf_event_sample_rate;
75564 extern int sysctl_perf_cpu_time_max_percent;
75565 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75566 loff_t *ppos);
75567
75568
75569 +static inline bool perf_paranoid_any(void)
75570 +{
75571 + return sysctl_perf_event_legitimately_concerned > 2;
75572 +}
75573 +
75574 static inline bool perf_paranoid_tracepoint_raw(void)
75575 {
75576 - return sysctl_perf_event_paranoid > -1;
75577 + return sysctl_perf_event_legitimately_concerned > -1;
75578 }
75579
75580 static inline bool perf_paranoid_cpu(void)
75581 {
75582 - return sysctl_perf_event_paranoid > 0;
75583 + return sysctl_perf_event_legitimately_concerned > 0;
75584 }
75585
75586 static inline bool perf_paranoid_kernel(void)
75587 {
75588 - return sysctl_perf_event_paranoid > 1;
75589 + return sysctl_perf_event_legitimately_concerned > 1;
75590 }
75591
75592 extern void perf_event_init(void);
75593 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75594 struct device_attribute attr;
75595 u64 id;
75596 const char *event_str;
75597 -};
75598 +} __do_const;
75599
75600 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75601 static struct perf_pmu_events_attr _var = { \
75602 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75603 index b8809fe..ae4ccd0 100644
75604 --- a/include/linux/pipe_fs_i.h
75605 +++ b/include/linux/pipe_fs_i.h
75606 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75607 struct mutex mutex;
75608 wait_queue_head_t wait;
75609 unsigned int nrbufs, curbuf, buffers;
75610 - unsigned int readers;
75611 - unsigned int writers;
75612 - unsigned int files;
75613 - unsigned int waiting_writers;
75614 + atomic_t readers;
75615 + atomic_t writers;
75616 + atomic_t files;
75617 + atomic_t waiting_writers;
75618 unsigned int r_counter;
75619 unsigned int w_counter;
75620 struct page *tmp_page;
75621 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75622 index 5f28cae..3d23723 100644
75623 --- a/include/linux/platform_data/usb-ehci-s5p.h
75624 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75625 @@ -14,7 +14,7 @@
75626 struct s5p_ehci_platdata {
75627 int (*phy_init)(struct platform_device *pdev, int type);
75628 int (*phy_exit)(struct platform_device *pdev, int type);
75629 -};
75630 +} __no_const;
75631
75632 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75633
75634 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75635 index c256c59..8ea94c7 100644
75636 --- a/include/linux/platform_data/usb-ohci-exynos.h
75637 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75638 @@ -14,7 +14,7 @@
75639 struct exynos4_ohci_platdata {
75640 int (*phy_init)(struct platform_device *pdev, int type);
75641 int (*phy_exit)(struct platform_device *pdev, int type);
75642 -};
75643 +} __no_const;
75644
75645 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75646
75647 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75648 index 7c1d252..c5c773e 100644
75649 --- a/include/linux/pm_domain.h
75650 +++ b/include/linux/pm_domain.h
75651 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75652
75653 struct gpd_cpu_data {
75654 unsigned int saved_exit_latency;
75655 - struct cpuidle_state *idle_state;
75656 + cpuidle_state_no_const *idle_state;
75657 };
75658
75659 struct generic_pm_domain {
75660 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75661 index 6fa7cea..7bf6415 100644
75662 --- a/include/linux/pm_runtime.h
75663 +++ b/include/linux/pm_runtime.h
75664 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75665
75666 static inline void pm_runtime_mark_last_busy(struct device *dev)
75667 {
75668 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75669 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75670 }
75671
75672 #else /* !CONFIG_PM_RUNTIME */
75673 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75674 index 195aafc..49a7bc2 100644
75675 --- a/include/linux/pnp.h
75676 +++ b/include/linux/pnp.h
75677 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
75678 struct pnp_fixup {
75679 char id[7];
75680 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
75681 -};
75682 +} __do_const;
75683
75684 /* config parameters */
75685 #define PNP_CONFIG_NORMAL 0x0001
75686 diff --git a/include/linux/poison.h b/include/linux/poison.h
75687 index 2110a81..13a11bb 100644
75688 --- a/include/linux/poison.h
75689 +++ b/include/linux/poison.h
75690 @@ -19,8 +19,8 @@
75691 * under normal circumstances, used to verify that nobody uses
75692 * non-initialized list entries.
75693 */
75694 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
75695 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
75696 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
75697 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
75698
75699 /********** include/linux/timer.h **********/
75700 /*
75701 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
75702 index d8b187c3..9a9257a 100644
75703 --- a/include/linux/power/smartreflex.h
75704 +++ b/include/linux/power/smartreflex.h
75705 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
75706 int (*notify)(struct omap_sr *sr, u32 status);
75707 u8 notify_flags;
75708 u8 class_type;
75709 -};
75710 +} __do_const;
75711
75712 /**
75713 * struct omap_sr_nvalue_table - Smartreflex n-target value info
75714 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
75715 index 4ea1d37..80f4b33 100644
75716 --- a/include/linux/ppp-comp.h
75717 +++ b/include/linux/ppp-comp.h
75718 @@ -84,7 +84,7 @@ struct compressor {
75719 struct module *owner;
75720 /* Extra skb space needed by the compressor algorithm */
75721 unsigned int comp_extra;
75722 -};
75723 +} __do_const;
75724
75725 /*
75726 * The return value from decompress routine is the length of the
75727 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
75728 index f5d4723..a6ea2fa 100644
75729 --- a/include/linux/preempt.h
75730 +++ b/include/linux/preempt.h
75731 @@ -18,8 +18,13 @@
75732 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75733 #endif
75734
75735 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
75736 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75737 +
75738 #define inc_preempt_count() add_preempt_count(1)
75739 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
75740 #define dec_preempt_count() sub_preempt_count(1)
75741 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
75742
75743 #define preempt_count() (current_thread_info()->preempt_count)
75744
75745 @@ -64,6 +69,12 @@ do { \
75746 barrier(); \
75747 } while (0)
75748
75749 +#define raw_preempt_disable() \
75750 +do { \
75751 + raw_inc_preempt_count(); \
75752 + barrier(); \
75753 +} while (0)
75754 +
75755 #define sched_preempt_enable_no_resched() \
75756 do { \
75757 barrier(); \
75758 @@ -72,6 +83,12 @@ do { \
75759
75760 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
75761
75762 +#define raw_preempt_enable_no_resched() \
75763 +do { \
75764 + barrier(); \
75765 + raw_dec_preempt_count(); \
75766 +} while (0)
75767 +
75768 #define preempt_enable() \
75769 do { \
75770 preempt_enable_no_resched(); \
75771 @@ -116,8 +133,10 @@ do { \
75772 * region.
75773 */
75774 #define preempt_disable() barrier()
75775 +#define raw_preempt_disable() barrier()
75776 #define sched_preempt_enable_no_resched() barrier()
75777 #define preempt_enable_no_resched() barrier()
75778 +#define raw_preempt_enable_no_resched() barrier()
75779 #define preempt_enable() barrier()
75780
75781 #define preempt_disable_notrace() barrier()
75782 diff --git a/include/linux/printk.h b/include/linux/printk.h
75783 index 22c7052..ad3fa0a 100644
75784 --- a/include/linux/printk.h
75785 +++ b/include/linux/printk.h
75786 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
75787 void early_printk(const char *s, ...) { }
75788 #endif
75789
75790 +extern int kptr_restrict;
75791 +
75792 #ifdef CONFIG_PRINTK
75793 asmlinkage __printf(5, 0)
75794 int vprintk_emit(int facility, int level,
75795 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
75796
75797 extern int printk_delay_msec;
75798 extern int dmesg_restrict;
75799 -extern int kptr_restrict;
75800
75801 extern void wake_up_klogd(void);
75802
75803 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
75804 index 608e60a..c26f864 100644
75805 --- a/include/linux/proc_fs.h
75806 +++ b/include/linux/proc_fs.h
75807 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
75808 return proc_create_data(name, mode, parent, proc_fops, NULL);
75809 }
75810
75811 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
75812 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
75813 +{
75814 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75815 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
75816 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75817 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
75818 +#else
75819 + return proc_create_data(name, mode, parent, proc_fops, NULL);
75820 +#endif
75821 +}
75822 +
75823 +
75824 extern void proc_set_size(struct proc_dir_entry *, loff_t);
75825 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
75826 extern void *PDE_DATA(const struct inode *);
75827 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
75828 index 34a1e10..03a6d03 100644
75829 --- a/include/linux/proc_ns.h
75830 +++ b/include/linux/proc_ns.h
75831 @@ -14,7 +14,7 @@ struct proc_ns_operations {
75832 void (*put)(void *ns);
75833 int (*install)(struct nsproxy *nsproxy, void *ns);
75834 unsigned int (*inum)(void *ns);
75835 -};
75836 +} __do_const;
75837
75838 struct proc_ns {
75839 void *ns;
75840 diff --git a/include/linux/random.h b/include/linux/random.h
75841 index 3b9377d..e418336 100644
75842 --- a/include/linux/random.h
75843 +++ b/include/linux/random.h
75844 @@ -10,9 +10,19 @@
75845
75846
75847 extern void add_device_randomness(const void *, unsigned int);
75848 +
75849 +static inline void add_latent_entropy(void)
75850 +{
75851 +
75852 +#ifdef LATENT_ENTROPY_PLUGIN
75853 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
75854 +#endif
75855 +
75856 +}
75857 +
75858 extern void add_input_randomness(unsigned int type, unsigned int code,
75859 - unsigned int value);
75860 -extern void add_interrupt_randomness(int irq, int irq_flags);
75861 + unsigned int value) __latent_entropy;
75862 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
75863
75864 extern void get_random_bytes(void *buf, int nbytes);
75865 extern void get_random_bytes_arch(void *buf, int nbytes);
75866 @@ -32,6 +42,11 @@ void prandom_seed(u32 seed);
75867 u32 prandom_u32_state(struct rnd_state *);
75868 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
75869
75870 +static inline unsigned long pax_get_random_long(void)
75871 +{
75872 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
75873 +}
75874 +
75875 /*
75876 * Handle minimum values for seeds
75877 */
75878 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
75879 index 4106721..132d42c 100644
75880 --- a/include/linux/rculist.h
75881 +++ b/include/linux/rculist.h
75882 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
75883 struct list_head *prev, struct list_head *next);
75884 #endif
75885
75886 +extern void __pax_list_add_rcu(struct list_head *new,
75887 + struct list_head *prev, struct list_head *next);
75888 +
75889 /**
75890 * list_add_rcu - add a new entry to rcu-protected list
75891 * @new: new entry to be added
75892 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
75893 __list_add_rcu(new, head, head->next);
75894 }
75895
75896 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
75897 +{
75898 + __pax_list_add_rcu(new, head, head->next);
75899 +}
75900 +
75901 /**
75902 * list_add_tail_rcu - add a new entry to rcu-protected list
75903 * @new: new entry to be added
75904 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
75905 __list_add_rcu(new, head->prev, head);
75906 }
75907
75908 +static inline void pax_list_add_tail_rcu(struct list_head *new,
75909 + struct list_head *head)
75910 +{
75911 + __pax_list_add_rcu(new, head->prev, head);
75912 +}
75913 +
75914 /**
75915 * list_del_rcu - deletes entry from list without re-initialization
75916 * @entry: the element to delete from the list.
75917 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
75918 entry->prev = LIST_POISON2;
75919 }
75920
75921 +extern void pax_list_del_rcu(struct list_head *entry);
75922 +
75923 /**
75924 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
75925 * @n: the element to delete from the hash list.
75926 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
75927 index 8e00f9f..9449b55 100644
75928 --- a/include/linux/reboot.h
75929 +++ b/include/linux/reboot.h
75930 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
75931 * Architecture-specific implementations of sys_reboot commands.
75932 */
75933
75934 -extern void machine_restart(char *cmd);
75935 -extern void machine_halt(void);
75936 -extern void machine_power_off(void);
75937 +extern void machine_restart(char *cmd) __noreturn;
75938 +extern void machine_halt(void) __noreturn;
75939 +extern void machine_power_off(void) __noreturn;
75940
75941 extern void machine_shutdown(void);
75942 struct pt_regs;
75943 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
75944 */
75945
75946 extern void kernel_restart_prepare(char *cmd);
75947 -extern void kernel_restart(char *cmd);
75948 -extern void kernel_halt(void);
75949 -extern void kernel_power_off(void);
75950 +extern void kernel_restart(char *cmd) __noreturn;
75951 +extern void kernel_halt(void) __noreturn;
75952 +extern void kernel_power_off(void) __noreturn;
75953
75954 extern int C_A_D; /* for sysctl */
75955 void ctrl_alt_del(void);
75956 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
75957 * Emergency restart, callable from an interrupt handler.
75958 */
75959
75960 -extern void emergency_restart(void);
75961 +extern void emergency_restart(void) __noreturn;
75962 #include <asm/emergency-restart.h>
75963
75964 #endif /* _LINUX_REBOOT_H */
75965 diff --git a/include/linux/regset.h b/include/linux/regset.h
75966 index 8e0c9fe..ac4d221 100644
75967 --- a/include/linux/regset.h
75968 +++ b/include/linux/regset.h
75969 @@ -161,7 +161,8 @@ struct user_regset {
75970 unsigned int align;
75971 unsigned int bias;
75972 unsigned int core_note_type;
75973 -};
75974 +} __do_const;
75975 +typedef struct user_regset __no_const user_regset_no_const;
75976
75977 /**
75978 * struct user_regset_view - available regsets
75979 diff --git a/include/linux/relay.h b/include/linux/relay.h
75980 index d7c8359..818daf5 100644
75981 --- a/include/linux/relay.h
75982 +++ b/include/linux/relay.h
75983 @@ -157,7 +157,7 @@ struct rchan_callbacks
75984 * The callback should return 0 if successful, negative if not.
75985 */
75986 int (*remove_buf_file)(struct dentry *dentry);
75987 -};
75988 +} __no_const;
75989
75990 /*
75991 * CONFIG_RELAY kernel API, kernel/relay.c
75992 diff --git a/include/linux/rio.h b/include/linux/rio.h
75993 index b71d573..2f940bd 100644
75994 --- a/include/linux/rio.h
75995 +++ b/include/linux/rio.h
75996 @@ -355,7 +355,7 @@ struct rio_ops {
75997 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
75998 u64 rstart, u32 size, u32 flags);
75999 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76000 -};
76001 +} __no_const;
76002
76003 #define RIO_RESOURCE_MEM 0x00000100
76004 #define RIO_RESOURCE_DOORBELL 0x00000200
76005 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76006 index 6dacb93..6174423 100644
76007 --- a/include/linux/rmap.h
76008 +++ b/include/linux/rmap.h
76009 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76010 void anon_vma_init(void); /* create anon_vma_cachep */
76011 int anon_vma_prepare(struct vm_area_struct *);
76012 void unlink_anon_vmas(struct vm_area_struct *);
76013 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76014 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76015 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76016 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76017
76018 static inline void anon_vma_merge(struct vm_area_struct *vma,
76019 struct vm_area_struct *next)
76020 diff --git a/include/linux/sched.h b/include/linux/sched.h
76021 index 078066d..4090b3b 100644
76022 --- a/include/linux/sched.h
76023 +++ b/include/linux/sched.h
76024 @@ -62,6 +62,7 @@ struct bio_list;
76025 struct fs_struct;
76026 struct perf_event_context;
76027 struct blk_plug;
76028 +struct linux_binprm;
76029
76030 /*
76031 * List of flags we want to share for kernel threads,
76032 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76033 extern int in_sched_functions(unsigned long addr);
76034
76035 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76036 -extern signed long schedule_timeout(signed long timeout);
76037 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76038 extern signed long schedule_timeout_interruptible(signed long timeout);
76039 extern signed long schedule_timeout_killable(signed long timeout);
76040 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76041 @@ -314,6 +315,19 @@ struct nsproxy;
76042 struct user_namespace;
76043
76044 #ifdef CONFIG_MMU
76045 +
76046 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76047 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76048 +#else
76049 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76050 +{
76051 + return 0;
76052 +}
76053 +#endif
76054 +
76055 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76056 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76057 +
76058 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76059 extern unsigned long
76060 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76061 @@ -589,6 +603,17 @@ struct signal_struct {
76062 #ifdef CONFIG_TASKSTATS
76063 struct taskstats *stats;
76064 #endif
76065 +
76066 +#ifdef CONFIG_GRKERNSEC
76067 + u32 curr_ip;
76068 + u32 saved_ip;
76069 + u32 gr_saddr;
76070 + u32 gr_daddr;
76071 + u16 gr_sport;
76072 + u16 gr_dport;
76073 + u8 used_accept:1;
76074 +#endif
76075 +
76076 #ifdef CONFIG_AUDIT
76077 unsigned audit_tty;
76078 unsigned audit_tty_log_passwd;
76079 @@ -669,6 +694,14 @@ struct user_struct {
76080 struct key *session_keyring; /* UID's default session keyring */
76081 #endif
76082
76083 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76084 + unsigned char kernel_banned;
76085 +#endif
76086 +#ifdef CONFIG_GRKERNSEC_BRUTE
76087 + unsigned char suid_banned;
76088 + unsigned long suid_ban_expires;
76089 +#endif
76090 +
76091 /* Hash table maintenance information */
76092 struct hlist_node uidhash_node;
76093 kuid_t uid;
76094 @@ -1151,8 +1184,8 @@ struct task_struct {
76095 struct list_head thread_group;
76096
76097 struct completion *vfork_done; /* for vfork() */
76098 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76099 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76100 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76101 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76102
76103 cputime_t utime, stime, utimescaled, stimescaled;
76104 cputime_t gtime;
76105 @@ -1177,11 +1210,6 @@ struct task_struct {
76106 struct task_cputime cputime_expires;
76107 struct list_head cpu_timers[3];
76108
76109 -/* process credentials */
76110 - const struct cred __rcu *real_cred; /* objective and real subjective task
76111 - * credentials (COW) */
76112 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76113 - * credentials (COW) */
76114 char comm[TASK_COMM_LEN]; /* executable name excluding path
76115 - access with [gs]et_task_comm (which lock
76116 it with task_lock())
76117 @@ -1198,6 +1226,10 @@ struct task_struct {
76118 #endif
76119 /* CPU-specific state of this task */
76120 struct thread_struct thread;
76121 +/* thread_info moved to task_struct */
76122 +#ifdef CONFIG_X86
76123 + struct thread_info tinfo;
76124 +#endif
76125 /* filesystem information */
76126 struct fs_struct *fs;
76127 /* open file information */
76128 @@ -1271,6 +1303,10 @@ struct task_struct {
76129 gfp_t lockdep_reclaim_gfp;
76130 #endif
76131
76132 +/* process credentials */
76133 + const struct cred __rcu *real_cred; /* objective and real subjective task
76134 + * credentials (COW) */
76135 +
76136 /* journalling filesystem info */
76137 void *journal_info;
76138
76139 @@ -1309,6 +1345,10 @@ struct task_struct {
76140 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76141 struct list_head cg_list;
76142 #endif
76143 +
76144 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76145 + * credentials (COW) */
76146 +
76147 #ifdef CONFIG_FUTEX
76148 struct robust_list_head __user *robust_list;
76149 #ifdef CONFIG_COMPAT
76150 @@ -1406,8 +1446,76 @@ struct task_struct {
76151 unsigned int sequential_io;
76152 unsigned int sequential_io_avg;
76153 #endif
76154 +
76155 +#ifdef CONFIG_GRKERNSEC
76156 + /* grsecurity */
76157 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76158 + u64 exec_id;
76159 +#endif
76160 +#ifdef CONFIG_GRKERNSEC_SETXID
76161 + const struct cred *delayed_cred;
76162 +#endif
76163 + struct dentry *gr_chroot_dentry;
76164 + struct acl_subject_label *acl;
76165 + struct acl_role_label *role;
76166 + struct file *exec_file;
76167 + unsigned long brute_expires;
76168 + u16 acl_role_id;
76169 + /* is this the task that authenticated to the special role */
76170 + u8 acl_sp_role;
76171 + u8 is_writable;
76172 + u8 brute;
76173 + u8 gr_is_chrooted;
76174 +#endif
76175 +
76176 };
76177
76178 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76179 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76180 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76181 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76182 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76183 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76184 +
76185 +#ifdef CONFIG_PAX_SOFTMODE
76186 +extern int pax_softmode;
76187 +#endif
76188 +
76189 +extern int pax_check_flags(unsigned long *);
76190 +
76191 +/* if tsk != current then task_lock must be held on it */
76192 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76193 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76194 +{
76195 + if (likely(tsk->mm))
76196 + return tsk->mm->pax_flags;
76197 + else
76198 + return 0UL;
76199 +}
76200 +
76201 +/* if tsk != current then task_lock must be held on it */
76202 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76203 +{
76204 + if (likely(tsk->mm)) {
76205 + tsk->mm->pax_flags = flags;
76206 + return 0;
76207 + }
76208 + return -EINVAL;
76209 +}
76210 +#endif
76211 +
76212 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76213 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76214 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76215 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76216 +#endif
76217 +
76218 +struct path;
76219 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76220 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76221 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76222 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76223 +
76224 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76225 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76226
76227 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76228 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76229 struct pid_namespace *ns);
76230
76231 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76232 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76233 {
76234 return tsk->pid;
76235 }
76236 @@ -1916,7 +2024,9 @@ void yield(void);
76237 extern struct exec_domain default_exec_domain;
76238
76239 union thread_union {
76240 +#ifndef CONFIG_X86
76241 struct thread_info thread_info;
76242 +#endif
76243 unsigned long stack[THREAD_SIZE/sizeof(long)];
76244 };
76245
76246 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76247 */
76248
76249 extern struct task_struct *find_task_by_vpid(pid_t nr);
76250 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76251 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76252 struct pid_namespace *ns);
76253
76254 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76255 extern void exit_itimers(struct signal_struct *);
76256 extern void flush_itimer_signals(void);
76257
76258 -extern void do_group_exit(int);
76259 +extern __noreturn void do_group_exit(int);
76260
76261 extern int allow_signal(int);
76262 extern int disallow_signal(int);
76263 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76264
76265 #endif
76266
76267 -static inline int object_is_on_stack(void *obj)
76268 +static inline int object_starts_on_stack(void *obj)
76269 {
76270 - void *stack = task_stack_page(current);
76271 + const void *stack = task_stack_page(current);
76272
76273 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76274 }
76275 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76276 index bf8086b..962b035 100644
76277 --- a/include/linux/sched/sysctl.h
76278 +++ b/include/linux/sched/sysctl.h
76279 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76280 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76281
76282 extern int sysctl_max_map_count;
76283 +extern unsigned long sysctl_heap_stack_gap;
76284
76285 extern unsigned int sysctl_sched_latency;
76286 extern unsigned int sysctl_sched_min_granularity;
76287 diff --git a/include/linux/security.h b/include/linux/security.h
76288 index 7ce53ae..8ee24a5 100644
76289 --- a/include/linux/security.h
76290 +++ b/include/linux/security.h
76291 @@ -27,6 +27,7 @@
76292 #include <linux/slab.h>
76293 #include <linux/err.h>
76294 #include <linux/string.h>
76295 +#include <linux/grsecurity.h>
76296
76297 struct linux_binprm;
76298 struct cred;
76299 @@ -116,8 +117,6 @@ struct seq_file;
76300
76301 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76302
76303 -void reset_security_ops(void);
76304 -
76305 #ifdef CONFIG_MMU
76306 extern unsigned long mmap_min_addr;
76307 extern unsigned long dac_mmap_min_addr;
76308 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76309 index 4e32edc..f8f2d18 100644
76310 --- a/include/linux/seq_file.h
76311 +++ b/include/linux/seq_file.h
76312 @@ -26,6 +26,9 @@ struct seq_file {
76313 struct mutex lock;
76314 const struct seq_operations *op;
76315 int poll_event;
76316 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76317 + u64 exec_id;
76318 +#endif
76319 #ifdef CONFIG_USER_NS
76320 struct user_namespace *user_ns;
76321 #endif
76322 @@ -38,6 +41,7 @@ struct seq_operations {
76323 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76324 int (*show) (struct seq_file *m, void *v);
76325 };
76326 +typedef struct seq_operations __no_const seq_operations_no_const;
76327
76328 #define SEQ_SKIP 1
76329
76330 diff --git a/include/linux/shm.h b/include/linux/shm.h
76331 index 429c199..4d42e38 100644
76332 --- a/include/linux/shm.h
76333 +++ b/include/linux/shm.h
76334 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76335
76336 /* The task created the shm object. NULL if the task is dead. */
76337 struct task_struct *shm_creator;
76338 +#ifdef CONFIG_GRKERNSEC
76339 + time_t shm_createtime;
76340 + pid_t shm_lapid;
76341 +#endif
76342 };
76343
76344 /* shm_mode upper byte flags */
76345 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76346 index 3b71a4e..5c9f309 100644
76347 --- a/include/linux/skbuff.h
76348 +++ b/include/linux/skbuff.h
76349 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76350 extern struct sk_buff *__alloc_skb(unsigned int size,
76351 gfp_t priority, int flags, int node);
76352 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76353 -static inline struct sk_buff *alloc_skb(unsigned int size,
76354 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76355 gfp_t priority)
76356 {
76357 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76358 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76359 */
76360 static inline int skb_queue_empty(const struct sk_buff_head *list)
76361 {
76362 - return list->next == (struct sk_buff *)list;
76363 + return list->next == (const struct sk_buff *)list;
76364 }
76365
76366 /**
76367 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76368 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76369 const struct sk_buff *skb)
76370 {
76371 - return skb->next == (struct sk_buff *)list;
76372 + return skb->next == (const struct sk_buff *)list;
76373 }
76374
76375 /**
76376 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76377 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76378 const struct sk_buff *skb)
76379 {
76380 - return skb->prev == (struct sk_buff *)list;
76381 + return skb->prev == (const struct sk_buff *)list;
76382 }
76383
76384 /**
76385 @@ -1750,7 +1750,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76386 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76387 */
76388 #ifndef NET_SKB_PAD
76389 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76390 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76391 #endif
76392
76393 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76394 @@ -2345,7 +2345,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76395 int noblock, int *err);
76396 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76397 struct poll_table_struct *wait);
76398 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76399 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76400 int offset, struct iovec *to,
76401 int size);
76402 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76403 @@ -2636,6 +2636,9 @@ static inline void nf_reset(struct sk_buff *skb)
76404 nf_bridge_put(skb->nf_bridge);
76405 skb->nf_bridge = NULL;
76406 #endif
76407 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76408 + skb->nf_trace = 0;
76409 +#endif
76410 }
76411
76412 static inline void nf_reset_trace(struct sk_buff *skb)
76413 diff --git a/include/linux/slab.h b/include/linux/slab.h
76414 index 6c5cc0e..9ca0fd6 100644
76415 --- a/include/linux/slab.h
76416 +++ b/include/linux/slab.h
76417 @@ -12,15 +12,29 @@
76418 #include <linux/gfp.h>
76419 #include <linux/types.h>
76420 #include <linux/workqueue.h>
76421 -
76422 +#include <linux/err.h>
76423
76424 /*
76425 * Flags to pass to kmem_cache_create().
76426 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76427 */
76428 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76429 +
76430 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76431 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76432 +#else
76433 +#define SLAB_USERCOPY 0x00000000UL
76434 +#endif
76435 +
76436 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76437 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76438 +
76439 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76440 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76441 +#else
76442 +#define SLAB_NO_SANITIZE 0x00000000UL
76443 +#endif
76444 +
76445 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76446 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76447 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76448 @@ -89,10 +103,13 @@
76449 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76450 * Both make kfree a no-op.
76451 */
76452 -#define ZERO_SIZE_PTR ((void *)16)
76453 +#define ZERO_SIZE_PTR \
76454 +({ \
76455 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76456 + (void *)(-MAX_ERRNO-1L); \
76457 +})
76458
76459 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76460 - (unsigned long)ZERO_SIZE_PTR)
76461 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76462
76463
76464 struct mem_cgroup;
76465 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76466 void kfree(const void *);
76467 void kzfree(const void *);
76468 size_t ksize(const void *);
76469 +const char *check_heap_object(const void *ptr, unsigned long n);
76470 +bool is_usercopy_object(const void *ptr);
76471
76472 /*
76473 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76474 @@ -164,7 +183,7 @@ struct kmem_cache {
76475 unsigned int align; /* Alignment as calculated */
76476 unsigned long flags; /* Active flags on the slab */
76477 const char *name; /* Slab name for sysfs */
76478 - int refcount; /* Use counter */
76479 + atomic_t refcount; /* Use counter */
76480 void (*ctor)(void *); /* Called on object slot creation */
76481 struct list_head list; /* List of all slab caches on the system */
76482 };
76483 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76484 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76485 #endif
76486
76487 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76488 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76489 +#endif
76490 +
76491 /*
76492 * Figure out which kmalloc slab an allocation of a certain size
76493 * belongs to.
76494 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76495 * 2 = 120 .. 192 bytes
76496 * n = 2^(n-1) .. 2^n -1
76497 */
76498 -static __always_inline int kmalloc_index(size_t size)
76499 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76500 {
76501 if (!size)
76502 return 0;
76503 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76504 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76505 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76506 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76507 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76508 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76509 #define kmalloc_track_caller(size, flags) \
76510 __kmalloc_track_caller(size, flags, _RET_IP_)
76511 #else
76512 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76513 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76514 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76515 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76516 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76517 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76518 #define kmalloc_node_track_caller(size, flags, node) \
76519 __kmalloc_node_track_caller(size, flags, node, \
76520 _RET_IP_)
76521 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76522 index cd40158..4e2f7af 100644
76523 --- a/include/linux/slab_def.h
76524 +++ b/include/linux/slab_def.h
76525 @@ -50,7 +50,7 @@ struct kmem_cache {
76526 /* 4) cache creation/removal */
76527 const char *name;
76528 struct list_head list;
76529 - int refcount;
76530 + atomic_t refcount;
76531 int object_size;
76532 int align;
76533
76534 @@ -66,10 +66,14 @@ struct kmem_cache {
76535 unsigned long node_allocs;
76536 unsigned long node_frees;
76537 unsigned long node_overflow;
76538 - atomic_t allochit;
76539 - atomic_t allocmiss;
76540 - atomic_t freehit;
76541 - atomic_t freemiss;
76542 + atomic_unchecked_t allochit;
76543 + atomic_unchecked_t allocmiss;
76544 + atomic_unchecked_t freehit;
76545 + atomic_unchecked_t freemiss;
76546 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76547 + atomic_unchecked_t sanitized;
76548 + atomic_unchecked_t not_sanitized;
76549 +#endif
76550
76551 /*
76552 * If debugging is enabled, then the allocator can add additional
76553 @@ -103,7 +107,7 @@ struct kmem_cache {
76554 };
76555
76556 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76557 -void *__kmalloc(size_t size, gfp_t flags);
76558 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76559
76560 #ifdef CONFIG_TRACING
76561 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76562 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76563 cachep = kmalloc_dma_caches[i];
76564 else
76565 #endif
76566 +
76567 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76568 + if (flags & GFP_USERCOPY)
76569 + cachep = kmalloc_usercopy_caches[i];
76570 + else
76571 +#endif
76572 +
76573 cachep = kmalloc_caches[i];
76574
76575 ret = kmem_cache_alloc_trace(cachep, flags, size);
76576 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76577 }
76578
76579 #ifdef CONFIG_NUMA
76580 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76581 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76582 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76583
76584 #ifdef CONFIG_TRACING
76585 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76586 cachep = kmalloc_dma_caches[i];
76587 else
76588 #endif
76589 +
76590 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76591 + if (flags & GFP_USERCOPY)
76592 + cachep = kmalloc_usercopy_caches[i];
76593 + else
76594 +#endif
76595 +
76596 cachep = kmalloc_caches[i];
76597
76598 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76599 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76600 index 095a5a4..4b82027 100644
76601 --- a/include/linux/slob_def.h
76602 +++ b/include/linux/slob_def.h
76603 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76604 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76605 }
76606
76607 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76608 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76609
76610 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76611 {
76612 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76613 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76614 }
76615
76616 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76617 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76618 {
76619 return kmalloc(size, flags);
76620 }
76621 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76622 index 027276f..092bfe8 100644
76623 --- a/include/linux/slub_def.h
76624 +++ b/include/linux/slub_def.h
76625 @@ -80,7 +80,7 @@ struct kmem_cache {
76626 struct kmem_cache_order_objects max;
76627 struct kmem_cache_order_objects min;
76628 gfp_t allocflags; /* gfp flags to use on each alloc */
76629 - int refcount; /* Refcount for slab cache destroy */
76630 + atomic_t refcount; /* Refcount for slab cache destroy */
76631 void (*ctor)(void *);
76632 int inuse; /* Offset to metadata */
76633 int align; /* Alignment */
76634 @@ -105,7 +105,7 @@ struct kmem_cache {
76635 };
76636
76637 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76638 -void *__kmalloc(size_t size, gfp_t flags);
76639 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76640
76641 static __always_inline void *
76642 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76643 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76644 }
76645 #endif
76646
76647 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76648 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76649 {
76650 unsigned int order = get_order(size);
76651 return kmalloc_order_trace(size, flags, order);
76652 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76653 }
76654
76655 #ifdef CONFIG_NUMA
76656 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76657 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76658 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76659
76660 #ifdef CONFIG_TRACING
76661 diff --git a/include/linux/smp.h b/include/linux/smp.h
76662 index c181399..09d7b92 100644
76663 --- a/include/linux/smp.h
76664 +++ b/include/linux/smp.h
76665 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
76666 #endif
76667
76668 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
76669 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
76670 #define put_cpu() preempt_enable()
76671 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
76672
76673 /*
76674 * Callback to arch code if there's nosmp or maxcpus=0 on the
76675 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
76676 index 54f91d3..be2c379 100644
76677 --- a/include/linux/sock_diag.h
76678 +++ b/include/linux/sock_diag.h
76679 @@ -11,7 +11,7 @@ struct sock;
76680 struct sock_diag_handler {
76681 __u8 family;
76682 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
76683 -};
76684 +} __do_const;
76685
76686 int sock_diag_register(const struct sock_diag_handler *h);
76687 void sock_diag_unregister(const struct sock_diag_handler *h);
76688 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
76689 index 680f9a3..f13aeb0 100644
76690 --- a/include/linux/sonet.h
76691 +++ b/include/linux/sonet.h
76692 @@ -7,7 +7,7 @@
76693 #include <uapi/linux/sonet.h>
76694
76695 struct k_sonet_stats {
76696 -#define __HANDLE_ITEM(i) atomic_t i
76697 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
76698 __SONET_ITEMS
76699 #undef __HANDLE_ITEM
76700 };
76701 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
76702 index 07d8e53..dc934c9 100644
76703 --- a/include/linux/sunrpc/addr.h
76704 +++ b/include/linux/sunrpc/addr.h
76705 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
76706 {
76707 switch (sap->sa_family) {
76708 case AF_INET:
76709 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
76710 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
76711 case AF_INET6:
76712 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
76713 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
76714 }
76715 return 0;
76716 }
76717 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
76718 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
76719 const struct sockaddr *src)
76720 {
76721 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
76722 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
76723 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
76724
76725 dsin->sin_family = ssin->sin_family;
76726 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
76727 if (sa->sa_family != AF_INET6)
76728 return 0;
76729
76730 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
76731 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
76732 }
76733
76734 #endif /* _LINUX_SUNRPC_ADDR_H */
76735 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
76736 index bfe11be..12bc8c4 100644
76737 --- a/include/linux/sunrpc/clnt.h
76738 +++ b/include/linux/sunrpc/clnt.h
76739 @@ -96,7 +96,7 @@ struct rpc_procinfo {
76740 unsigned int p_timer; /* Which RTT timer to use */
76741 u32 p_statidx; /* Which procedure to account */
76742 const char * p_name; /* name of procedure */
76743 -};
76744 +} __do_const;
76745
76746 #ifdef __KERNEL__
76747
76748 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
76749 index 1f0216b..6a4fa50 100644
76750 --- a/include/linux/sunrpc/svc.h
76751 +++ b/include/linux/sunrpc/svc.h
76752 @@ -411,7 +411,7 @@ struct svc_procedure {
76753 unsigned int pc_count; /* call count */
76754 unsigned int pc_cachetype; /* cache info (NFS) */
76755 unsigned int pc_xdrressize; /* maximum size of XDR reply */
76756 -};
76757 +} __do_const;
76758
76759 /*
76760 * Function prototypes.
76761 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
76762 index 0b8e3e6..33e0a01 100644
76763 --- a/include/linux/sunrpc/svc_rdma.h
76764 +++ b/include/linux/sunrpc/svc_rdma.h
76765 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
76766 extern unsigned int svcrdma_max_requests;
76767 extern unsigned int svcrdma_max_req_size;
76768
76769 -extern atomic_t rdma_stat_recv;
76770 -extern atomic_t rdma_stat_read;
76771 -extern atomic_t rdma_stat_write;
76772 -extern atomic_t rdma_stat_sq_starve;
76773 -extern atomic_t rdma_stat_rq_starve;
76774 -extern atomic_t rdma_stat_rq_poll;
76775 -extern atomic_t rdma_stat_rq_prod;
76776 -extern atomic_t rdma_stat_sq_poll;
76777 -extern atomic_t rdma_stat_sq_prod;
76778 +extern atomic_unchecked_t rdma_stat_recv;
76779 +extern atomic_unchecked_t rdma_stat_read;
76780 +extern atomic_unchecked_t rdma_stat_write;
76781 +extern atomic_unchecked_t rdma_stat_sq_starve;
76782 +extern atomic_unchecked_t rdma_stat_rq_starve;
76783 +extern atomic_unchecked_t rdma_stat_rq_poll;
76784 +extern atomic_unchecked_t rdma_stat_rq_prod;
76785 +extern atomic_unchecked_t rdma_stat_sq_poll;
76786 +extern atomic_unchecked_t rdma_stat_sq_prod;
76787
76788 #define RPCRDMA_VERSION 1
76789
76790 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
76791 index 8d71d65..f79586e 100644
76792 --- a/include/linux/sunrpc/svcauth.h
76793 +++ b/include/linux/sunrpc/svcauth.h
76794 @@ -120,7 +120,7 @@ struct auth_ops {
76795 int (*release)(struct svc_rqst *rq);
76796 void (*domain_release)(struct auth_domain *);
76797 int (*set_client)(struct svc_rqst *rq);
76798 -};
76799 +} __do_const;
76800
76801 #define SVC_GARBAGE 1
76802 #define SVC_SYSERR 2
76803 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
76804 index a5ffd32..0935dea 100644
76805 --- a/include/linux/swiotlb.h
76806 +++ b/include/linux/swiotlb.h
76807 @@ -60,7 +60,8 @@ extern void
76808
76809 extern void
76810 swiotlb_free_coherent(struct device *hwdev, size_t size,
76811 - void *vaddr, dma_addr_t dma_handle);
76812 + void *vaddr, dma_addr_t dma_handle,
76813 + struct dma_attrs *attrs);
76814
76815 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
76816 unsigned long offset, size_t size,
76817 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
76818 index 84662ec..5271947 100644
76819 --- a/include/linux/syscalls.h
76820 +++ b/include/linux/syscalls.h
76821 @@ -97,8 +97,14 @@ struct sigaltstack;
76822 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
76823
76824 #define __SC_DECL(t, a) t a
76825 +#define __TYPE_IS_U(t) (__same_type((t)0, 0UL) || __same_type((t)0, 0U) || __same_type((t)0, (unsigned short)0) || __same_type((t)0, (unsigned char)0))
76826 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
76827 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
76828 +#define __SC_LONG(t, a) __typeof( \
76829 + __builtin_choose_expr( \
76830 + sizeof(t) > sizeof(int), \
76831 + (t) 0, \
76832 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
76833 + )) a
76834 #define __SC_CAST(t, a) (t) a
76835 #define __SC_ARGS(t, a) a
76836 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
76837 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
76838 asmlinkage long sys_fsync(unsigned int fd);
76839 asmlinkage long sys_fdatasync(unsigned int fd);
76840 asmlinkage long sys_bdflush(int func, long data);
76841 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
76842 - char __user *type, unsigned long flags,
76843 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
76844 + const char __user *type, unsigned long flags,
76845 void __user *data);
76846 -asmlinkage long sys_umount(char __user *name, int flags);
76847 -asmlinkage long sys_oldumount(char __user *name);
76848 +asmlinkage long sys_umount(const char __user *name, int flags);
76849 +asmlinkage long sys_oldumount(const char __user *name);
76850 asmlinkage long sys_truncate(const char __user *path, long length);
76851 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
76852 asmlinkage long sys_stat(const char __user *filename,
76853 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
76854 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
76855 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
76856 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
76857 - struct sockaddr __user *, int);
76858 + struct sockaddr __user *, int) __intentional_overflow(0);
76859 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
76860 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
76861 unsigned int vlen, unsigned flags);
76862 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
76863 index 27b3b0b..e093dd9 100644
76864 --- a/include/linux/syscore_ops.h
76865 +++ b/include/linux/syscore_ops.h
76866 @@ -16,7 +16,7 @@ struct syscore_ops {
76867 int (*suspend)(void);
76868 void (*resume)(void);
76869 void (*shutdown)(void);
76870 -};
76871 +} __do_const;
76872
76873 extern void register_syscore_ops(struct syscore_ops *ops);
76874 extern void unregister_syscore_ops(struct syscore_ops *ops);
76875 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
76876 index 14a8ff2..af52bad 100644
76877 --- a/include/linux/sysctl.h
76878 +++ b/include/linux/sysctl.h
76879 @@ -34,13 +34,13 @@ struct ctl_table_root;
76880 struct ctl_table_header;
76881 struct ctl_dir;
76882
76883 -typedef struct ctl_table ctl_table;
76884 -
76885 typedef int proc_handler (struct ctl_table *ctl, int write,
76886 void __user *buffer, size_t *lenp, loff_t *ppos);
76887
76888 extern int proc_dostring(struct ctl_table *, int,
76889 void __user *, size_t *, loff_t *);
76890 +extern int proc_dostring_modpriv(struct ctl_table *, int,
76891 + void __user *, size_t *, loff_t *);
76892 extern int proc_dointvec(struct ctl_table *, int,
76893 void __user *, size_t *, loff_t *);
76894 extern int proc_dointvec_minmax(struct ctl_table *, int,
76895 @@ -115,7 +115,9 @@ struct ctl_table
76896 struct ctl_table_poll *poll;
76897 void *extra1;
76898 void *extra2;
76899 -};
76900 +} __do_const;
76901 +typedef struct ctl_table __no_const ctl_table_no_const;
76902 +typedef struct ctl_table ctl_table;
76903
76904 struct ctl_node {
76905 struct rb_node node;
76906 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
76907 index 9e8a9b5..753de68 100644
76908 --- a/include/linux/sysfs.h
76909 +++ b/include/linux/sysfs.h
76910 @@ -33,7 +33,8 @@ struct attribute {
76911 struct lock_class_key *key;
76912 struct lock_class_key skey;
76913 #endif
76914 -};
76915 +} __do_const;
76916 +typedef struct attribute __no_const attribute_no_const;
76917
76918 /**
76919 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
76920 @@ -62,7 +63,8 @@ struct attribute_group {
76921 struct attribute *, int);
76922 struct attribute **attrs;
76923 struct bin_attribute **bin_attrs;
76924 -};
76925 +} __do_const;
76926 +typedef struct attribute_group __no_const attribute_group_no_const;
76927
76928 /**
76929 * Use these macros to make defining attributes easier. See include/linux/device.h
76930 @@ -123,7 +125,8 @@ struct bin_attribute {
76931 char *, loff_t, size_t);
76932 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
76933 struct vm_area_struct *vma);
76934 -};
76935 +} __do_const;
76936 +typedef struct bin_attribute __no_const bin_attribute_no_const;
76937
76938 /**
76939 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
76940 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
76941 index 7faf933..9b85a0c 100644
76942 --- a/include/linux/sysrq.h
76943 +++ b/include/linux/sysrq.h
76944 @@ -16,6 +16,7 @@
76945
76946 #include <linux/errno.h>
76947 #include <linux/types.h>
76948 +#include <linux/compiler.h>
76949
76950 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
76951 #define SYSRQ_DEFAULT_ENABLE 1
76952 @@ -36,7 +37,7 @@ struct sysrq_key_op {
76953 char *help_msg;
76954 char *action_msg;
76955 int enable_mask;
76956 -};
76957 +} __do_const;
76958
76959 #ifdef CONFIG_MAGIC_SYSRQ
76960
76961 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
76962 index e7e0473..7989295 100644
76963 --- a/include/linux/thread_info.h
76964 +++ b/include/linux/thread_info.h
76965 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
76966 #error "no set_restore_sigmask() provided and default one won't work"
76967 #endif
76968
76969 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
76970 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
76971 +{
76972 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
76973 + if (!__builtin_constant_p(n))
76974 +#endif
76975 + __check_object_size(ptr, n, to_user);
76976 +}
76977 +
76978 #endif /* __KERNEL__ */
76979
76980 #endif /* _LINUX_THREAD_INFO_H */
76981 diff --git a/include/linux/tty.h b/include/linux/tty.h
76982 index 01ac30e..bf18a71 100644
76983 --- a/include/linux/tty.h
76984 +++ b/include/linux/tty.h
76985 @@ -194,7 +194,7 @@ struct tty_port {
76986 const struct tty_port_operations *ops; /* Port operations */
76987 spinlock_t lock; /* Lock protecting tty field */
76988 int blocked_open; /* Waiting to open */
76989 - int count; /* Usage count */
76990 + atomic_t count; /* Usage count */
76991 wait_queue_head_t open_wait; /* Open waiters */
76992 wait_queue_head_t close_wait; /* Close waiters */
76993 wait_queue_head_t delta_msr_wait; /* Modem status change */
76994 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
76995 struct tty_struct *tty, struct file *filp);
76996 static inline int tty_port_users(struct tty_port *port)
76997 {
76998 - return port->count + port->blocked_open;
76999 + return atomic_read(&port->count) + port->blocked_open;
77000 }
77001
77002 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77003 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77004 index 756a609..b302dd6 100644
77005 --- a/include/linux/tty_driver.h
77006 +++ b/include/linux/tty_driver.h
77007 @@ -285,7 +285,7 @@ struct tty_operations {
77008 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77009 #endif
77010 const struct file_operations *proc_fops;
77011 -};
77012 +} __do_const;
77013
77014 struct tty_driver {
77015 int magic; /* magic number for this structure */
77016 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77017 index a1b0489..f02e17c 100644
77018 --- a/include/linux/tty_ldisc.h
77019 +++ b/include/linux/tty_ldisc.h
77020 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77021
77022 struct module *owner;
77023
77024 - int refcount;
77025 + atomic_t refcount;
77026 };
77027
77028 struct tty_ldisc {
77029 diff --git a/include/linux/types.h b/include/linux/types.h
77030 index 4d118ba..c3ee9bf 100644
77031 --- a/include/linux/types.h
77032 +++ b/include/linux/types.h
77033 @@ -176,10 +176,26 @@ typedef struct {
77034 int counter;
77035 } atomic_t;
77036
77037 +#ifdef CONFIG_PAX_REFCOUNT
77038 +typedef struct {
77039 + int counter;
77040 +} atomic_unchecked_t;
77041 +#else
77042 +typedef atomic_t atomic_unchecked_t;
77043 +#endif
77044 +
77045 #ifdef CONFIG_64BIT
77046 typedef struct {
77047 long counter;
77048 } atomic64_t;
77049 +
77050 +#ifdef CONFIG_PAX_REFCOUNT
77051 +typedef struct {
77052 + long counter;
77053 +} atomic64_unchecked_t;
77054 +#else
77055 +typedef atomic64_t atomic64_unchecked_t;
77056 +#endif
77057 #endif
77058
77059 struct list_head {
77060 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77061 index 5ca0951..ab496a5 100644
77062 --- a/include/linux/uaccess.h
77063 +++ b/include/linux/uaccess.h
77064 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77065 long ret; \
77066 mm_segment_t old_fs = get_fs(); \
77067 \
77068 - set_fs(KERNEL_DS); \
77069 pagefault_disable(); \
77070 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77071 - pagefault_enable(); \
77072 + set_fs(KERNEL_DS); \
77073 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77074 set_fs(old_fs); \
77075 + pagefault_enable(); \
77076 ret; \
77077 })
77078
77079 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77080 index 8e522cbc..aa8572d 100644
77081 --- a/include/linux/uidgid.h
77082 +++ b/include/linux/uidgid.h
77083 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77084
77085 #endif /* CONFIG_USER_NS */
77086
77087 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77088 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77089 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77090 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77091 +
77092 #endif /* _LINUX_UIDGID_H */
77093 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77094 index 99c1b4d..562e6f3 100644
77095 --- a/include/linux/unaligned/access_ok.h
77096 +++ b/include/linux/unaligned/access_ok.h
77097 @@ -4,34 +4,34 @@
77098 #include <linux/kernel.h>
77099 #include <asm/byteorder.h>
77100
77101 -static inline u16 get_unaligned_le16(const void *p)
77102 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77103 {
77104 - return le16_to_cpup((__le16 *)p);
77105 + return le16_to_cpup((const __le16 *)p);
77106 }
77107
77108 -static inline u32 get_unaligned_le32(const void *p)
77109 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77110 {
77111 - return le32_to_cpup((__le32 *)p);
77112 + return le32_to_cpup((const __le32 *)p);
77113 }
77114
77115 -static inline u64 get_unaligned_le64(const void *p)
77116 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77117 {
77118 - return le64_to_cpup((__le64 *)p);
77119 + return le64_to_cpup((const __le64 *)p);
77120 }
77121
77122 -static inline u16 get_unaligned_be16(const void *p)
77123 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77124 {
77125 - return be16_to_cpup((__be16 *)p);
77126 + return be16_to_cpup((const __be16 *)p);
77127 }
77128
77129 -static inline u32 get_unaligned_be32(const void *p)
77130 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77131 {
77132 - return be32_to_cpup((__be32 *)p);
77133 + return be32_to_cpup((const __be32 *)p);
77134 }
77135
77136 -static inline u64 get_unaligned_be64(const void *p)
77137 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77138 {
77139 - return be64_to_cpup((__be64 *)p);
77140 + return be64_to_cpup((const __be64 *)p);
77141 }
77142
77143 static inline void put_unaligned_le16(u16 val, void *p)
77144 diff --git a/include/linux/usb.h b/include/linux/usb.h
77145 index 0eec268..4496526 100644
77146 --- a/include/linux/usb.h
77147 +++ b/include/linux/usb.h
77148 @@ -560,7 +560,7 @@ struct usb_device {
77149 int maxchild;
77150
77151 u32 quirks;
77152 - atomic_t urbnum;
77153 + atomic_unchecked_t urbnum;
77154
77155 unsigned long active_duration;
77156
77157 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77158
77159 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77160 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77161 - void *data, __u16 size, int timeout);
77162 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77163 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77164 void *data, int len, int *actual_length, int timeout);
77165 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77166 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77167 index e452ba6..78f8e80 100644
77168 --- a/include/linux/usb/renesas_usbhs.h
77169 +++ b/include/linux/usb/renesas_usbhs.h
77170 @@ -39,7 +39,7 @@ enum {
77171 */
77172 struct renesas_usbhs_driver_callback {
77173 int (*notify_hotplug)(struct platform_device *pdev);
77174 -};
77175 +} __no_const;
77176
77177 /*
77178 * callback functions for platform
77179 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77180 index 6f8fbcf..8259001 100644
77181 --- a/include/linux/vermagic.h
77182 +++ b/include/linux/vermagic.h
77183 @@ -25,9 +25,35 @@
77184 #define MODULE_ARCH_VERMAGIC ""
77185 #endif
77186
77187 +#ifdef CONFIG_PAX_REFCOUNT
77188 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77189 +#else
77190 +#define MODULE_PAX_REFCOUNT ""
77191 +#endif
77192 +
77193 +#ifdef CONSTIFY_PLUGIN
77194 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77195 +#else
77196 +#define MODULE_CONSTIFY_PLUGIN ""
77197 +#endif
77198 +
77199 +#ifdef STACKLEAK_PLUGIN
77200 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77201 +#else
77202 +#define MODULE_STACKLEAK_PLUGIN ""
77203 +#endif
77204 +
77205 +#ifdef CONFIG_GRKERNSEC
77206 +#define MODULE_GRSEC "GRSEC "
77207 +#else
77208 +#define MODULE_GRSEC ""
77209 +#endif
77210 +
77211 #define VERMAGIC_STRING \
77212 UTS_RELEASE " " \
77213 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77214 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77215 - MODULE_ARCH_VERMAGIC
77216 + MODULE_ARCH_VERMAGIC \
77217 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77218 + MODULE_GRSEC
77219
77220 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77221 index 4b8a891..c20e936 100644
77222 --- a/include/linux/vmalloc.h
77223 +++ b/include/linux/vmalloc.h
77224 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77225 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77226 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77227 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77228 +
77229 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77230 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77231 +#endif
77232 +
77233 /* bits [20..32] reserved for arch specific ioremap internals */
77234
77235 /*
77236 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77237 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77238 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77239 unsigned long start, unsigned long end, gfp_t gfp_mask,
77240 - pgprot_t prot, int node, const void *caller);
77241 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77242 extern void vfree(const void *addr);
77243
77244 extern void *vmap(struct page **pages, unsigned int count,
77245 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77246 extern void free_vm_area(struct vm_struct *area);
77247
77248 /* for /dev/kmem */
77249 -extern long vread(char *buf, char *addr, unsigned long count);
77250 -extern long vwrite(char *buf, char *addr, unsigned long count);
77251 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77252 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77253
77254 /*
77255 * Internals. Dont't use..
77256 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77257 index c586679..f06b389 100644
77258 --- a/include/linux/vmstat.h
77259 +++ b/include/linux/vmstat.h
77260 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77261 /*
77262 * Zone based page accounting with per cpu differentials.
77263 */
77264 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77265 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77266
77267 static inline void zone_page_state_add(long x, struct zone *zone,
77268 enum zone_stat_item item)
77269 {
77270 - atomic_long_add(x, &zone->vm_stat[item]);
77271 - atomic_long_add(x, &vm_stat[item]);
77272 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77273 + atomic_long_add_unchecked(x, &vm_stat[item]);
77274 }
77275
77276 static inline unsigned long global_page_state(enum zone_stat_item item)
77277 {
77278 - long x = atomic_long_read(&vm_stat[item]);
77279 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77280 #ifdef CONFIG_SMP
77281 if (x < 0)
77282 x = 0;
77283 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77284 static inline unsigned long zone_page_state(struct zone *zone,
77285 enum zone_stat_item item)
77286 {
77287 - long x = atomic_long_read(&zone->vm_stat[item]);
77288 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77289 #ifdef CONFIG_SMP
77290 if (x < 0)
77291 x = 0;
77292 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77293 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77294 enum zone_stat_item item)
77295 {
77296 - long x = atomic_long_read(&zone->vm_stat[item]);
77297 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77298
77299 #ifdef CONFIG_SMP
77300 int cpu;
77301 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77302
77303 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77304 {
77305 - atomic_long_inc(&zone->vm_stat[item]);
77306 - atomic_long_inc(&vm_stat[item]);
77307 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77308 + atomic_long_inc_unchecked(&vm_stat[item]);
77309 }
77310
77311 static inline void __inc_zone_page_state(struct page *page,
77312 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77313
77314 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77315 {
77316 - atomic_long_dec(&zone->vm_stat[item]);
77317 - atomic_long_dec(&vm_stat[item]);
77318 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77319 + atomic_long_dec_unchecked(&vm_stat[item]);
77320 }
77321
77322 static inline void __dec_zone_page_state(struct page *page,
77323 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77324 index fdbafc6..49dfe4f 100644
77325 --- a/include/linux/xattr.h
77326 +++ b/include/linux/xattr.h
77327 @@ -28,7 +28,7 @@ struct xattr_handler {
77328 size_t size, int handler_flags);
77329 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77330 size_t size, int flags, int handler_flags);
77331 -};
77332 +} __do_const;
77333
77334 struct xattr {
77335 char *name;
77336 @@ -37,6 +37,9 @@ struct xattr {
77337 };
77338
77339 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77340 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77341 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77342 +#endif
77343 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77344 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77345 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77346 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77347 index 9c5a6b4..09c9438 100644
77348 --- a/include/linux/zlib.h
77349 +++ b/include/linux/zlib.h
77350 @@ -31,6 +31,7 @@
77351 #define _ZLIB_H
77352
77353 #include <linux/zconf.h>
77354 +#include <linux/compiler.h>
77355
77356 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77357 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77358 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77359
77360 /* basic functions */
77361
77362 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77363 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77364 /*
77365 Returns the number of bytes that needs to be allocated for a per-
77366 stream workspace with the specified parameters. A pointer to this
77367 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77368 index c768c9f..bdcaa5a 100644
77369 --- a/include/media/v4l2-dev.h
77370 +++ b/include/media/v4l2-dev.h
77371 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77372 int (*mmap) (struct file *, struct vm_area_struct *);
77373 int (*open) (struct file *);
77374 int (*release) (struct file *);
77375 -};
77376 +} __do_const;
77377
77378 /*
77379 * Newer version of video_device, handled by videodev2.c
77380 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77381 index c9b1593..a572459 100644
77382 --- a/include/media/v4l2-device.h
77383 +++ b/include/media/v4l2-device.h
77384 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77385 this function returns 0. If the name ends with a digit (e.g. cx18),
77386 then the name will be set to cx18-0 since cx180 looks really odd. */
77387 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77388 - atomic_t *instance);
77389 + atomic_unchecked_t *instance);
77390
77391 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77392 Since the parent disappears this ensures that v4l2_dev doesn't have an
77393 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77394 index d9fa68f..45c88d1 100644
77395 --- a/include/net/9p/transport.h
77396 +++ b/include/net/9p/transport.h
77397 @@ -63,7 +63,7 @@ struct p9_trans_module {
77398 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77399 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77400 char *, char *, int , int, int, int);
77401 -};
77402 +} __do_const;
77403
77404 void v9fs_register_trans(struct p9_trans_module *m);
77405 void v9fs_unregister_trans(struct p9_trans_module *m);
77406 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77407 index 1a966af..2767cf6 100644
77408 --- a/include/net/bluetooth/l2cap.h
77409 +++ b/include/net/bluetooth/l2cap.h
77410 @@ -551,7 +551,7 @@ struct l2cap_ops {
77411 void (*defer) (struct l2cap_chan *chan);
77412 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77413 unsigned long len, int nb);
77414 -};
77415 +} __do_const;
77416
77417 struct l2cap_conn {
77418 struct hci_conn *hcon;
77419 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77420 index f2ae33d..c457cf0 100644
77421 --- a/include/net/caif/cfctrl.h
77422 +++ b/include/net/caif/cfctrl.h
77423 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77424 void (*radioset_rsp)(void);
77425 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77426 struct cflayer *client_layer);
77427 -};
77428 +} __no_const;
77429
77430 /* Link Setup Parameters for CAIF-Links. */
77431 struct cfctrl_link_param {
77432 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77433 struct cfctrl {
77434 struct cfsrvl serv;
77435 struct cfctrl_rsp res;
77436 - atomic_t req_seq_no;
77437 - atomic_t rsp_seq_no;
77438 + atomic_unchecked_t req_seq_no;
77439 + atomic_unchecked_t rsp_seq_no;
77440 struct list_head list;
77441 /* Protects from simultaneous access to first_req list */
77442 spinlock_t info_list_lock;
77443 diff --git a/include/net/flow.h b/include/net/flow.h
77444 index 628e11b..4c475df 100644
77445 --- a/include/net/flow.h
77446 +++ b/include/net/flow.h
77447 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77448
77449 extern void flow_cache_flush(void);
77450 extern void flow_cache_flush_deferred(void);
77451 -extern atomic_t flow_cache_genid;
77452 +extern atomic_unchecked_t flow_cache_genid;
77453
77454 #endif
77455 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77456 index 8e0b6c8..73cf605 100644
77457 --- a/include/net/genetlink.h
77458 +++ b/include/net/genetlink.h
77459 @@ -120,7 +120,7 @@ struct genl_ops {
77460 struct netlink_callback *cb);
77461 int (*done)(struct netlink_callback *cb);
77462 struct list_head ops_list;
77463 -};
77464 +} __do_const;
77465
77466 extern int __genl_register_family(struct genl_family *family);
77467
77468 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77469 index 734d9b5..48a9a4b 100644
77470 --- a/include/net/gro_cells.h
77471 +++ b/include/net/gro_cells.h
77472 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77473 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77474
77475 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77476 - atomic_long_inc(&dev->rx_dropped);
77477 + atomic_long_inc_unchecked(&dev->rx_dropped);
77478 kfree_skb(skb);
77479 return;
77480 }
77481 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77482 index de2c785..0588a6b 100644
77483 --- a/include/net/inet_connection_sock.h
77484 +++ b/include/net/inet_connection_sock.h
77485 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77486 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77487 int (*bind_conflict)(const struct sock *sk,
77488 const struct inet_bind_bucket *tb, bool relax);
77489 -};
77490 +} __do_const;
77491
77492 /** inet_connection_sock - INET connection oriented sock
77493 *
77494 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77495 index 53f464d..0bd0b49 100644
77496 --- a/include/net/inetpeer.h
77497 +++ b/include/net/inetpeer.h
77498 @@ -47,8 +47,8 @@ struct inet_peer {
77499 */
77500 union {
77501 struct {
77502 - atomic_t rid; /* Frag reception counter */
77503 - atomic_t ip_id_count; /* IP ID for the next packet */
77504 + atomic_unchecked_t rid; /* Frag reception counter */
77505 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77506 };
77507 struct rcu_head rcu;
77508 struct inet_peer *gc_next;
77509 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77510 /* can be called with or without local BH being disabled */
77511 static inline int inet_getid(struct inet_peer *p, int more)
77512 {
77513 - int old, new;
77514 + int id;
77515 more++;
77516 inet_peer_refcheck(p);
77517 - do {
77518 - old = atomic_read(&p->ip_id_count);
77519 - new = old + more;
77520 - if (!new)
77521 - new = 1;
77522 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77523 - return new;
77524 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77525 + if (!id)
77526 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77527 + return id;
77528 }
77529
77530 #endif /* _NET_INETPEER_H */
77531 diff --git a/include/net/ip.h b/include/net/ip.h
77532 index edfa591..a643b82 100644
77533 --- a/include/net/ip.h
77534 +++ b/include/net/ip.h
77535 @@ -202,7 +202,7 @@ extern struct local_ports {
77536 } sysctl_local_ports;
77537 extern void inet_get_local_port_range(int *low, int *high);
77538
77539 -extern unsigned long *sysctl_local_reserved_ports;
77540 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77541 static inline int inet_is_reserved_local_port(int port)
77542 {
77543 return test_bit(port, sysctl_local_reserved_ports);
77544 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77545 index cbf2be3..3683f6d 100644
77546 --- a/include/net/ip_fib.h
77547 +++ b/include/net/ip_fib.h
77548 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77549
77550 #define FIB_RES_SADDR(net, res) \
77551 ((FIB_RES_NH(res).nh_saddr_genid == \
77552 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77553 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77554 FIB_RES_NH(res).nh_saddr : \
77555 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77556 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77557 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77558 index f0d70f0..185f15b 100644
77559 --- a/include/net/ip_vs.h
77560 +++ b/include/net/ip_vs.h
77561 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77562 struct ip_vs_conn *control; /* Master control connection */
77563 atomic_t n_control; /* Number of controlled ones */
77564 struct ip_vs_dest *dest; /* real server */
77565 - atomic_t in_pkts; /* incoming packet counter */
77566 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77567
77568 /* packet transmitter for different forwarding methods. If it
77569 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77570 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77571 __be16 port; /* port number of the server */
77572 union nf_inet_addr addr; /* IP address of the server */
77573 volatile unsigned int flags; /* dest status flags */
77574 - atomic_t conn_flags; /* flags to copy to conn */
77575 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77576 atomic_t weight; /* server weight */
77577
77578 atomic_t refcnt; /* reference counter */
77579 @@ -993,11 +993,11 @@ struct netns_ipvs {
77580 /* ip_vs_lblc */
77581 int sysctl_lblc_expiration;
77582 struct ctl_table_header *lblc_ctl_header;
77583 - struct ctl_table *lblc_ctl_table;
77584 + ctl_table_no_const *lblc_ctl_table;
77585 /* ip_vs_lblcr */
77586 int sysctl_lblcr_expiration;
77587 struct ctl_table_header *lblcr_ctl_header;
77588 - struct ctl_table *lblcr_ctl_table;
77589 + ctl_table_no_const *lblcr_ctl_table;
77590 /* ip_vs_est */
77591 struct list_head est_list; /* estimator list */
77592 spinlock_t est_lock;
77593 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77594 index 80ffde3..968b0f4 100644
77595 --- a/include/net/irda/ircomm_tty.h
77596 +++ b/include/net/irda/ircomm_tty.h
77597 @@ -35,6 +35,7 @@
77598 #include <linux/termios.h>
77599 #include <linux/timer.h>
77600 #include <linux/tty.h> /* struct tty_struct */
77601 +#include <asm/local.h>
77602
77603 #include <net/irda/irias_object.h>
77604 #include <net/irda/ircomm_core.h>
77605 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77606 index 714cc9a..ea05f3e 100644
77607 --- a/include/net/iucv/af_iucv.h
77608 +++ b/include/net/iucv/af_iucv.h
77609 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77610 struct iucv_sock_list {
77611 struct hlist_head head;
77612 rwlock_t lock;
77613 - atomic_t autobind_name;
77614 + atomic_unchecked_t autobind_name;
77615 };
77616
77617 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77618 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77619 index df83f69..9b640b8 100644
77620 --- a/include/net/llc_c_ac.h
77621 +++ b/include/net/llc_c_ac.h
77622 @@ -87,7 +87,7 @@
77623 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77624 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77625
77626 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77627 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77628
77629 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77630 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77631 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77632 index 6ca3113..f8026dd 100644
77633 --- a/include/net/llc_c_ev.h
77634 +++ b/include/net/llc_c_ev.h
77635 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77636 return (struct llc_conn_state_ev *)skb->cb;
77637 }
77638
77639 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77640 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77641 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77642 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77643
77644 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77645 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77646 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77647 index 0e79cfb..f46db31 100644
77648 --- a/include/net/llc_c_st.h
77649 +++ b/include/net/llc_c_st.h
77650 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77651 u8 next_state;
77652 llc_conn_ev_qfyr_t *ev_qualifiers;
77653 llc_conn_action_t *ev_actions;
77654 -};
77655 +} __do_const;
77656
77657 struct llc_conn_state {
77658 u8 current_state;
77659 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
77660 index 37a3bbd..55a4241 100644
77661 --- a/include/net/llc_s_ac.h
77662 +++ b/include/net/llc_s_ac.h
77663 @@ -23,7 +23,7 @@
77664 #define SAP_ACT_TEST_IND 9
77665
77666 /* All action functions must look like this */
77667 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77668 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77669
77670 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
77671 struct sk_buff *skb);
77672 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
77673 index 567c681..cd73ac0 100644
77674 --- a/include/net/llc_s_st.h
77675 +++ b/include/net/llc_s_st.h
77676 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
77677 llc_sap_ev_t ev;
77678 u8 next_state;
77679 llc_sap_action_t *ev_actions;
77680 -};
77681 +} __do_const;
77682
77683 struct llc_sap_state {
77684 u8 curr_state;
77685 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
77686 index 551ba6a..11c99c1 100644
77687 --- a/include/net/mac80211.h
77688 +++ b/include/net/mac80211.h
77689 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
77690 void (*add_sta_debugfs)(void *priv, void *priv_sta,
77691 struct dentry *dir);
77692 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
77693 -};
77694 +} __do_const;
77695
77696 static inline int rate_supported(struct ieee80211_sta *sta,
77697 enum ieee80211_band band,
77698 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
77699 index 7e748ad..5c6229b 100644
77700 --- a/include/net/neighbour.h
77701 +++ b/include/net/neighbour.h
77702 @@ -123,7 +123,7 @@ struct neigh_ops {
77703 void (*error_report)(struct neighbour *, struct sk_buff *);
77704 int (*output)(struct neighbour *, struct sk_buff *);
77705 int (*connected_output)(struct neighbour *, struct sk_buff *);
77706 -};
77707 +} __do_const;
77708
77709 struct pneigh_entry {
77710 struct pneigh_entry *next;
77711 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
77712 index 84e37b1..8eba19a 100644
77713 --- a/include/net/net_namespace.h
77714 +++ b/include/net/net_namespace.h
77715 @@ -119,8 +119,8 @@ struct net {
77716 struct netns_ipvs *ipvs;
77717 #endif
77718 struct sock *diag_nlsk;
77719 - atomic_t rt_genid;
77720 - atomic_t fnhe_genid;
77721 + atomic_unchecked_t rt_genid;
77722 + atomic_unchecked_t fnhe_genid;
77723 };
77724
77725 /*
77726 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
77727 #define __net_init __init
77728 #define __net_exit __exit_refok
77729 #define __net_initdata __initdata
77730 +#ifdef CONSTIFY_PLUGIN
77731 #define __net_initconst __initconst
77732 +#else
77733 +#define __net_initconst __initdata
77734 +#endif
77735 #endif
77736
77737 struct pernet_operations {
77738 @@ -287,7 +291,7 @@ struct pernet_operations {
77739 void (*exit_batch)(struct list_head *net_exit_list);
77740 int *id;
77741 size_t size;
77742 -};
77743 +} __do_const;
77744
77745 /*
77746 * Use these carefully. If you implement a network device and it
77747 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
77748
77749 static inline int rt_genid(struct net *net)
77750 {
77751 - return atomic_read(&net->rt_genid);
77752 + return atomic_read_unchecked(&net->rt_genid);
77753 }
77754
77755 static inline void rt_genid_bump(struct net *net)
77756 {
77757 - atomic_inc(&net->rt_genid);
77758 + atomic_inc_unchecked(&net->rt_genid);
77759 }
77760
77761 static inline int fnhe_genid(struct net *net)
77762 {
77763 - return atomic_read(&net->fnhe_genid);
77764 + return atomic_read_unchecked(&net->fnhe_genid);
77765 }
77766
77767 static inline void fnhe_genid_bump(struct net *net)
77768 {
77769 - atomic_inc(&net->fnhe_genid);
77770 + atomic_inc_unchecked(&net->fnhe_genid);
77771 }
77772
77773 #endif /* __NET_NET_NAMESPACE_H */
77774 diff --git a/include/net/netdma.h b/include/net/netdma.h
77775 index 8ba8ce2..99b7fff 100644
77776 --- a/include/net/netdma.h
77777 +++ b/include/net/netdma.h
77778 @@ -24,7 +24,7 @@
77779 #include <linux/dmaengine.h>
77780 #include <linux/skbuff.h>
77781
77782 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77783 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77784 struct sk_buff *skb, int offset, struct iovec *to,
77785 size_t len, struct dma_pinned_list *pinned_list);
77786
77787 diff --git a/include/net/netlink.h b/include/net/netlink.h
77788 index 9690b0f..87aded7 100644
77789 --- a/include/net/netlink.h
77790 +++ b/include/net/netlink.h
77791 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
77792 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
77793 {
77794 if (mark)
77795 - skb_trim(skb, (unsigned char *) mark - skb->data);
77796 + skb_trim(skb, (const unsigned char *) mark - skb->data);
77797 }
77798
77799 /**
77800 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
77801 index c9c0c53..53f24c3 100644
77802 --- a/include/net/netns/conntrack.h
77803 +++ b/include/net/netns/conntrack.h
77804 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
77805 struct nf_proto_net {
77806 #ifdef CONFIG_SYSCTL
77807 struct ctl_table_header *ctl_table_header;
77808 - struct ctl_table *ctl_table;
77809 + ctl_table_no_const *ctl_table;
77810 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
77811 struct ctl_table_header *ctl_compat_header;
77812 - struct ctl_table *ctl_compat_table;
77813 + ctl_table_no_const *ctl_compat_table;
77814 #endif
77815 #endif
77816 unsigned int users;
77817 @@ -58,7 +58,7 @@ struct nf_ip_net {
77818 struct nf_icmp_net icmpv6;
77819 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
77820 struct ctl_table_header *ctl_table_header;
77821 - struct ctl_table *ctl_table;
77822 + ctl_table_no_const *ctl_table;
77823 #endif
77824 };
77825
77826 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
77827 index 2ba9de8..47bd6c7 100644
77828 --- a/include/net/netns/ipv4.h
77829 +++ b/include/net/netns/ipv4.h
77830 @@ -67,7 +67,7 @@ struct netns_ipv4 {
77831 kgid_t sysctl_ping_group_range[2];
77832 long sysctl_tcp_mem[3];
77833
77834 - atomic_t dev_addr_genid;
77835 + atomic_unchecked_t dev_addr_genid;
77836
77837 #ifdef CONFIG_IP_MROUTE
77838 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
77839 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
77840 index 005e2c2..023d340 100644
77841 --- a/include/net/netns/ipv6.h
77842 +++ b/include/net/netns/ipv6.h
77843 @@ -71,7 +71,7 @@ struct netns_ipv6 {
77844 struct fib_rules_ops *mr6_rules_ops;
77845 #endif
77846 #endif
77847 - atomic_t dev_addr_genid;
77848 + atomic_unchecked_t dev_addr_genid;
77849 };
77850
77851 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
77852 diff --git a/include/net/ping.h b/include/net/ping.h
77853 index 5db0224..0d65365 100644
77854 --- a/include/net/ping.h
77855 +++ b/include/net/ping.h
77856 @@ -55,7 +55,7 @@ struct ping_iter_state {
77857 extern struct proto ping_prot;
77858 extern struct ping_table ping_table;
77859 #if IS_ENABLED(CONFIG_IPV6)
77860 -extern struct pingv6_ops pingv6_ops;
77861 +extern struct pingv6_ops *pingv6_ops;
77862 #endif
77863
77864 struct pingfakehdr {
77865 diff --git a/include/net/protocol.h b/include/net/protocol.h
77866 index 047c047..b9dad15 100644
77867 --- a/include/net/protocol.h
77868 +++ b/include/net/protocol.h
77869 @@ -44,7 +44,7 @@ struct net_protocol {
77870 void (*err_handler)(struct sk_buff *skb, u32 info);
77871 unsigned int no_policy:1,
77872 netns_ok:1;
77873 -};
77874 +} __do_const;
77875
77876 #if IS_ENABLED(CONFIG_IPV6)
77877 struct inet6_protocol {
77878 @@ -57,7 +57,7 @@ struct inet6_protocol {
77879 u8 type, u8 code, int offset,
77880 __be32 info);
77881 unsigned int flags; /* INET6_PROTO_xxx */
77882 -};
77883 +} __do_const;
77884
77885 #define INET6_PROTO_NOPOLICY 0x1
77886 #define INET6_PROTO_FINAL 0x2
77887 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
77888 index 7026648..584cc8c 100644
77889 --- a/include/net/rtnetlink.h
77890 +++ b/include/net/rtnetlink.h
77891 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
77892 const struct net_device *dev);
77893 unsigned int (*get_num_tx_queues)(void);
77894 unsigned int (*get_num_rx_queues)(void);
77895 -};
77896 +} __do_const;
77897
77898 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
77899 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
77900 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
77901 index 2a82d13..62a31c2 100644
77902 --- a/include/net/sctp/sm.h
77903 +++ b/include/net/sctp/sm.h
77904 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
77905 typedef struct {
77906 sctp_state_fn_t *fn;
77907 const char *name;
77908 -} sctp_sm_table_entry_t;
77909 +} __do_const sctp_sm_table_entry_t;
77910
77911 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
77912 * currently in use.
77913 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
77914 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
77915
77916 /* Extern declarations for major data structures. */
77917 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
77918 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
77919
77920
77921 /* Get the size of a DATA chunk payload. */
77922 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
77923 index e745c92..3641448 100644
77924 --- a/include/net/sctp/structs.h
77925 +++ b/include/net/sctp/structs.h
77926 @@ -516,7 +516,7 @@ struct sctp_pf {
77927 struct sctp_association *asoc);
77928 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
77929 struct sctp_af *af;
77930 -};
77931 +} __do_const;
77932
77933
77934 /* Structure to track chunk fragments that have been acked, but peer
77935 diff --git a/include/net/sock.h b/include/net/sock.h
77936 index 31d5cfb..9ee0602 100644
77937 --- a/include/net/sock.h
77938 +++ b/include/net/sock.h
77939 @@ -331,7 +331,7 @@ struct sock {
77940 unsigned int sk_napi_id;
77941 unsigned int sk_ll_usec;
77942 #endif
77943 - atomic_t sk_drops;
77944 + atomic_unchecked_t sk_drops;
77945 int sk_rcvbuf;
77946
77947 struct sk_filter __rcu *sk_filter;
77948 @@ -1803,7 +1803,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
77949 }
77950
77951 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
77952 - char __user *from, char *to,
77953 + char __user *from, unsigned char *to,
77954 int copy, int offset)
77955 {
77956 if (skb->ip_summed == CHECKSUM_NONE) {
77957 @@ -2065,7 +2065,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
77958 }
77959 }
77960
77961 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
77962 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
77963
77964 /**
77965 * sk_page_frag - return an appropriate page_frag
77966 diff --git a/include/net/tcp.h b/include/net/tcp.h
77967 index d198005..c974a393 100644
77968 --- a/include/net/tcp.h
77969 +++ b/include/net/tcp.h
77970 @@ -521,7 +521,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
77971 extern void tcp_xmit_retransmit_queue(struct sock *);
77972 extern void tcp_simple_retransmit(struct sock *);
77973 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
77974 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
77975 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
77976
77977 extern void tcp_send_probe0(struct sock *);
77978 extern void tcp_send_partial(struct sock *);
77979 @@ -694,8 +694,8 @@ struct tcp_skb_cb {
77980 struct inet6_skb_parm h6;
77981 #endif
77982 } header; /* For incoming frames */
77983 - __u32 seq; /* Starting sequence number */
77984 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
77985 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
77986 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
77987 __u32 when; /* used to compute rtt's */
77988 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
77989
77990 @@ -709,7 +709,7 @@ struct tcp_skb_cb {
77991
77992 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
77993 /* 1 byte hole */
77994 - __u32 ack_seq; /* Sequence number ACK'd */
77995 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
77996 };
77997
77998 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
77999 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78000 index e823786..53b0608 100644
78001 --- a/include/net/xfrm.h
78002 +++ b/include/net/xfrm.h
78003 @@ -287,7 +287,6 @@ struct xfrm_dst;
78004 struct xfrm_policy_afinfo {
78005 unsigned short family;
78006 struct dst_ops *dst_ops;
78007 - void (*garbage_collect)(struct net *net);
78008 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78009 const xfrm_address_t *saddr,
78010 const xfrm_address_t *daddr);
78011 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78012 struct net_device *dev,
78013 const struct flowi *fl);
78014 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78015 -};
78016 +} __do_const;
78017
78018 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78019 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78020 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78021 int (*transport_finish)(struct sk_buff *skb,
78022 int async);
78023 void (*local_error)(struct sk_buff *skb, u32 mtu);
78024 -};
78025 +} __do_const;
78026
78027 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78028 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78029 @@ -427,7 +426,7 @@ struct xfrm_mode {
78030 struct module *owner;
78031 unsigned int encap;
78032 int flags;
78033 -};
78034 +} __do_const;
78035
78036 /* Flags for xfrm_mode. */
78037 enum {
78038 @@ -524,7 +523,7 @@ struct xfrm_policy {
78039 struct timer_list timer;
78040
78041 struct flow_cache_object flo;
78042 - atomic_t genid;
78043 + atomic_unchecked_t genid;
78044 u32 priority;
78045 u32 index;
78046 struct xfrm_mark mark;
78047 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78048 }
78049
78050 extern void xfrm_garbage_collect(struct net *net);
78051 +extern void xfrm_garbage_collect_deferred(struct net *net);
78052
78053 #else
78054
78055 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78056 static inline void xfrm_garbage_collect(struct net *net)
78057 {
78058 }
78059 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78060 +{
78061 +}
78062 #endif
78063
78064 static __inline__
78065 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78066 index 1a046b1..ee0bef0 100644
78067 --- a/include/rdma/iw_cm.h
78068 +++ b/include/rdma/iw_cm.h
78069 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78070 int backlog);
78071
78072 int (*destroy_listen)(struct iw_cm_id *cm_id);
78073 -};
78074 +} __no_const;
78075
78076 /**
78077 * iw_create_cm_id - Create an IW CM identifier.
78078 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78079 index e1379b4..67eafbe 100644
78080 --- a/include/scsi/libfc.h
78081 +++ b/include/scsi/libfc.h
78082 @@ -762,6 +762,7 @@ struct libfc_function_template {
78083 */
78084 void (*disc_stop_final) (struct fc_lport *);
78085 };
78086 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78087
78088 /**
78089 * struct fc_disc - Discovery context
78090 @@ -866,7 +867,7 @@ struct fc_lport {
78091 struct fc_vport *vport;
78092
78093 /* Operational Information */
78094 - struct libfc_function_template tt;
78095 + libfc_function_template_no_const tt;
78096 u8 link_up;
78097 u8 qfull;
78098 enum fc_lport_state state;
78099 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78100 index a44954c..5da04b2 100644
78101 --- a/include/scsi/scsi_device.h
78102 +++ b/include/scsi/scsi_device.h
78103 @@ -172,9 +172,9 @@ struct scsi_device {
78104 unsigned int max_device_blocked; /* what device_blocked counts down from */
78105 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78106
78107 - atomic_t iorequest_cnt;
78108 - atomic_t iodone_cnt;
78109 - atomic_t ioerr_cnt;
78110 + atomic_unchecked_t iorequest_cnt;
78111 + atomic_unchecked_t iodone_cnt;
78112 + atomic_unchecked_t ioerr_cnt;
78113
78114 struct device sdev_gendev,
78115 sdev_dev;
78116 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78117 index b797e8f..8e2c3aa 100644
78118 --- a/include/scsi/scsi_transport_fc.h
78119 +++ b/include/scsi/scsi_transport_fc.h
78120 @@ -751,7 +751,8 @@ struct fc_function_template {
78121 unsigned long show_host_system_hostname:1;
78122
78123 unsigned long disable_target_scan:1;
78124 -};
78125 +} __do_const;
78126 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78127
78128
78129 /**
78130 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78131 index 9031a26..750d592 100644
78132 --- a/include/sound/compress_driver.h
78133 +++ b/include/sound/compress_driver.h
78134 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78135 struct snd_compr_caps *caps);
78136 int (*get_codec_caps) (struct snd_compr_stream *stream,
78137 struct snd_compr_codec_caps *codec);
78138 -};
78139 +} __no_const;
78140
78141 /**
78142 * struct snd_compr: Compressed device
78143 diff --git a/include/sound/soc.h b/include/sound/soc.h
78144 index 6eabee7..58afb50 100644
78145 --- a/include/sound/soc.h
78146 +++ b/include/sound/soc.h
78147 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78148 /* probe ordering - for components with runtime dependencies */
78149 int probe_order;
78150 int remove_order;
78151 -};
78152 +} __do_const;
78153
78154 /* SoC platform interface */
78155 struct snd_soc_platform_driver {
78156 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78157 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78158 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78159 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78160 -};
78161 +} __do_const;
78162
78163 struct snd_soc_platform {
78164 const char *name;
78165 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78166 index e34fc90..ecefa2c 100644
78167 --- a/include/target/target_core_base.h
78168 +++ b/include/target/target_core_base.h
78169 @@ -643,7 +643,7 @@ struct se_device {
78170 spinlock_t stats_lock;
78171 /* Active commands on this virtual SE device */
78172 atomic_t simple_cmds;
78173 - atomic_t dev_ordered_id;
78174 + atomic_unchecked_t dev_ordered_id;
78175 atomic_t dev_ordered_sync;
78176 atomic_t dev_qf_count;
78177 int export_count;
78178 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78179 new file mode 100644
78180 index 0000000..fb634b7
78181 --- /dev/null
78182 +++ b/include/trace/events/fs.h
78183 @@ -0,0 +1,53 @@
78184 +#undef TRACE_SYSTEM
78185 +#define TRACE_SYSTEM fs
78186 +
78187 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78188 +#define _TRACE_FS_H
78189 +
78190 +#include <linux/fs.h>
78191 +#include <linux/tracepoint.h>
78192 +
78193 +TRACE_EVENT(do_sys_open,
78194 +
78195 + TP_PROTO(const char *filename, int flags, int mode),
78196 +
78197 + TP_ARGS(filename, flags, mode),
78198 +
78199 + TP_STRUCT__entry(
78200 + __string( filename, filename )
78201 + __field( int, flags )
78202 + __field( int, mode )
78203 + ),
78204 +
78205 + TP_fast_assign(
78206 + __assign_str(filename, filename);
78207 + __entry->flags = flags;
78208 + __entry->mode = mode;
78209 + ),
78210 +
78211 + TP_printk("\"%s\" %x %o",
78212 + __get_str(filename), __entry->flags, __entry->mode)
78213 +);
78214 +
78215 +TRACE_EVENT(open_exec,
78216 +
78217 + TP_PROTO(const char *filename),
78218 +
78219 + TP_ARGS(filename),
78220 +
78221 + TP_STRUCT__entry(
78222 + __string( filename, filename )
78223 + ),
78224 +
78225 + TP_fast_assign(
78226 + __assign_str(filename, filename);
78227 + ),
78228 +
78229 + TP_printk("\"%s\"",
78230 + __get_str(filename))
78231 +);
78232 +
78233 +#endif /* _TRACE_FS_H */
78234 +
78235 +/* This part must be outside protection */
78236 +#include <trace/define_trace.h>
78237 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78238 index 1c09820..7f5ec79 100644
78239 --- a/include/trace/events/irq.h
78240 +++ b/include/trace/events/irq.h
78241 @@ -36,7 +36,7 @@ struct softirq_action;
78242 */
78243 TRACE_EVENT(irq_handler_entry,
78244
78245 - TP_PROTO(int irq, struct irqaction *action),
78246 + TP_PROTO(int irq, const struct irqaction *action),
78247
78248 TP_ARGS(irq, action),
78249
78250 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78251 */
78252 TRACE_EVENT(irq_handler_exit,
78253
78254 - TP_PROTO(int irq, struct irqaction *action, int ret),
78255 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78256
78257 TP_ARGS(irq, action, ret),
78258
78259 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78260 index 7caf44c..23c6f27 100644
78261 --- a/include/uapi/linux/a.out.h
78262 +++ b/include/uapi/linux/a.out.h
78263 @@ -39,6 +39,14 @@ enum machine_type {
78264 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78265 };
78266
78267 +/* Constants for the N_FLAGS field */
78268 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78269 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78270 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78271 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78272 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78273 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78274 +
78275 #if !defined (N_MAGIC)
78276 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78277 #endif
78278 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78279 index d876736..ccce5c0 100644
78280 --- a/include/uapi/linux/byteorder/little_endian.h
78281 +++ b/include/uapi/linux/byteorder/little_endian.h
78282 @@ -42,51 +42,51 @@
78283
78284 static inline __le64 __cpu_to_le64p(const __u64 *p)
78285 {
78286 - return (__force __le64)*p;
78287 + return (__force const __le64)*p;
78288 }
78289 -static inline __u64 __le64_to_cpup(const __le64 *p)
78290 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78291 {
78292 - return (__force __u64)*p;
78293 + return (__force const __u64)*p;
78294 }
78295 static inline __le32 __cpu_to_le32p(const __u32 *p)
78296 {
78297 - return (__force __le32)*p;
78298 + return (__force const __le32)*p;
78299 }
78300 static inline __u32 __le32_to_cpup(const __le32 *p)
78301 {
78302 - return (__force __u32)*p;
78303 + return (__force const __u32)*p;
78304 }
78305 static inline __le16 __cpu_to_le16p(const __u16 *p)
78306 {
78307 - return (__force __le16)*p;
78308 + return (__force const __le16)*p;
78309 }
78310 static inline __u16 __le16_to_cpup(const __le16 *p)
78311 {
78312 - return (__force __u16)*p;
78313 + return (__force const __u16)*p;
78314 }
78315 static inline __be64 __cpu_to_be64p(const __u64 *p)
78316 {
78317 - return (__force __be64)__swab64p(p);
78318 + return (__force const __be64)__swab64p(p);
78319 }
78320 static inline __u64 __be64_to_cpup(const __be64 *p)
78321 {
78322 - return __swab64p((__u64 *)p);
78323 + return __swab64p((const __u64 *)p);
78324 }
78325 static inline __be32 __cpu_to_be32p(const __u32 *p)
78326 {
78327 - return (__force __be32)__swab32p(p);
78328 + return (__force const __be32)__swab32p(p);
78329 }
78330 -static inline __u32 __be32_to_cpup(const __be32 *p)
78331 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78332 {
78333 - return __swab32p((__u32 *)p);
78334 + return __swab32p((const __u32 *)p);
78335 }
78336 static inline __be16 __cpu_to_be16p(const __u16 *p)
78337 {
78338 - return (__force __be16)__swab16p(p);
78339 + return (__force const __be16)__swab16p(p);
78340 }
78341 static inline __u16 __be16_to_cpup(const __be16 *p)
78342 {
78343 - return __swab16p((__u16 *)p);
78344 + return __swab16p((const __u16 *)p);
78345 }
78346 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78347 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78348 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78349 index ef6103b..d4e65dd 100644
78350 --- a/include/uapi/linux/elf.h
78351 +++ b/include/uapi/linux/elf.h
78352 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78353 #define PT_GNU_EH_FRAME 0x6474e550
78354
78355 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78356 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78357 +
78358 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78359 +
78360 +/* Constants for the e_flags field */
78361 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78362 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78363 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78364 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78365 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78366 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78367
78368 /*
78369 * Extended Numbering
78370 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78371 #define DT_DEBUG 21
78372 #define DT_TEXTREL 22
78373 #define DT_JMPREL 23
78374 +#define DT_FLAGS 30
78375 + #define DF_TEXTREL 0x00000004
78376 #define DT_ENCODING 32
78377 #define OLD_DT_LOOS 0x60000000
78378 #define DT_LOOS 0x6000000d
78379 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78380 #define PF_W 0x2
78381 #define PF_X 0x1
78382
78383 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78384 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78385 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78386 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78387 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78388 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78389 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78390 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78391 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78392 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78393 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78394 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78395 +
78396 typedef struct elf32_phdr{
78397 Elf32_Word p_type;
78398 Elf32_Off p_offset;
78399 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78400 #define EI_OSABI 7
78401 #define EI_PAD 8
78402
78403 +#define EI_PAX 14
78404 +
78405 #define ELFMAG0 0x7f /* EI_MAG */
78406 #define ELFMAG1 'E'
78407 #define ELFMAG2 'L'
78408 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78409 index aa169c4..6a2771d 100644
78410 --- a/include/uapi/linux/personality.h
78411 +++ b/include/uapi/linux/personality.h
78412 @@ -30,6 +30,7 @@ enum {
78413 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78414 ADDR_NO_RANDOMIZE | \
78415 ADDR_COMPAT_LAYOUT | \
78416 + ADDR_LIMIT_3GB | \
78417 MMAP_PAGE_ZERO)
78418
78419 /*
78420 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78421 index 7530e74..e714828 100644
78422 --- a/include/uapi/linux/screen_info.h
78423 +++ b/include/uapi/linux/screen_info.h
78424 @@ -43,7 +43,8 @@ struct screen_info {
78425 __u16 pages; /* 0x32 */
78426 __u16 vesa_attributes; /* 0x34 */
78427 __u32 capabilities; /* 0x36 */
78428 - __u8 _reserved[6]; /* 0x3a */
78429 + __u16 vesapm_size; /* 0x3a */
78430 + __u8 _reserved[4]; /* 0x3c */
78431 } __attribute__((packed));
78432
78433 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78434 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78435 index 0e011eb..82681b1 100644
78436 --- a/include/uapi/linux/swab.h
78437 +++ b/include/uapi/linux/swab.h
78438 @@ -43,7 +43,7 @@
78439 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78440 */
78441
78442 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78443 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78444 {
78445 #ifdef __HAVE_BUILTIN_BSWAP16__
78446 return __builtin_bswap16(val);
78447 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78448 #endif
78449 }
78450
78451 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78452 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78453 {
78454 #ifdef __HAVE_BUILTIN_BSWAP32__
78455 return __builtin_bswap32(val);
78456 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78457 #endif
78458 }
78459
78460 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78461 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78462 {
78463 #ifdef __HAVE_BUILTIN_BSWAP64__
78464 return __builtin_bswap64(val);
78465 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78466 index 6d67213..8dab561 100644
78467 --- a/include/uapi/linux/sysctl.h
78468 +++ b/include/uapi/linux/sysctl.h
78469 @@ -155,7 +155,11 @@ enum
78470 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78471 };
78472
78473 -
78474 +#ifdef CONFIG_PAX_SOFTMODE
78475 +enum {
78476 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78477 +};
78478 +#endif
78479
78480 /* CTL_VM names: */
78481 enum
78482 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78483 index e4629b9..6958086 100644
78484 --- a/include/uapi/linux/xattr.h
78485 +++ b/include/uapi/linux/xattr.h
78486 @@ -63,5 +63,9 @@
78487 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78488 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78489
78490 +/* User namespace */
78491 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78492 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78493 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78494
78495 #endif /* _UAPI_LINUX_XATTR_H */
78496 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78497 index f9466fa..f4e2b81 100644
78498 --- a/include/video/udlfb.h
78499 +++ b/include/video/udlfb.h
78500 @@ -53,10 +53,10 @@ struct dlfb_data {
78501 u32 pseudo_palette[256];
78502 int blank_mode; /*one of FB_BLANK_ */
78503 /* blit-only rendering path metrics, exposed through sysfs */
78504 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78505 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78506 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78507 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78508 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78509 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78510 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78511 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78512 };
78513
78514 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78515 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78516 index 30f5362..8ed8ac9 100644
78517 --- a/include/video/uvesafb.h
78518 +++ b/include/video/uvesafb.h
78519 @@ -122,6 +122,7 @@ struct uvesafb_par {
78520 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78521 u8 pmi_setpal; /* PMI for palette changes */
78522 u16 *pmi_base; /* protected mode interface location */
78523 + u8 *pmi_code; /* protected mode code location */
78524 void *pmi_start;
78525 void *pmi_pal;
78526 u8 *vbe_state_orig; /*
78527 diff --git a/init/Kconfig b/init/Kconfig
78528 index fed81b5..0d3b964 100644
78529 --- a/init/Kconfig
78530 +++ b/init/Kconfig
78531 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78532
78533 config CHECKPOINT_RESTORE
78534 bool "Checkpoint/restore support" if EXPERT
78535 + depends on !GRKERNSEC
78536 default n
78537 help
78538 Enables additional kernel features in a sake of checkpoint/restore.
78539 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78540
78541 config COMPAT_BRK
78542 bool "Disable heap randomization"
78543 - default y
78544 + default n
78545 help
78546 Randomizing heap placement makes heap exploits harder, but it
78547 also breaks ancient binaries (including anything libc5 based).
78548 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78549 config STOP_MACHINE
78550 bool
78551 default y
78552 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78553 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78554 help
78555 Need stop_machine() primitive.
78556
78557 diff --git a/init/Makefile b/init/Makefile
78558 index 7bc47ee..6da2dc7 100644
78559 --- a/init/Makefile
78560 +++ b/init/Makefile
78561 @@ -2,6 +2,9 @@
78562 # Makefile for the linux kernel.
78563 #
78564
78565 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78566 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78567 +
78568 obj-y := main.o version.o mounts.o
78569 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78570 obj-y += noinitramfs.o
78571 diff --git a/init/do_mounts.c b/init/do_mounts.c
78572 index 816014c..c2054db 100644
78573 --- a/init/do_mounts.c
78574 +++ b/init/do_mounts.c
78575 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78576 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78577 {
78578 struct super_block *s;
78579 - int err = sys_mount(name, "/root", fs, flags, data);
78580 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78581 if (err)
78582 return err;
78583
78584 - sys_chdir("/root");
78585 + sys_chdir((const char __force_user *)"/root");
78586 s = current->fs->pwd.dentry->d_sb;
78587 ROOT_DEV = s->s_dev;
78588 printk(KERN_INFO
78589 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78590 va_start(args, fmt);
78591 vsprintf(buf, fmt, args);
78592 va_end(args);
78593 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78594 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78595 if (fd >= 0) {
78596 sys_ioctl(fd, FDEJECT, 0);
78597 sys_close(fd);
78598 }
78599 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78600 - fd = sys_open("/dev/console", O_RDWR, 0);
78601 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78602 if (fd >= 0) {
78603 sys_ioctl(fd, TCGETS, (long)&termios);
78604 termios.c_lflag &= ~ICANON;
78605 sys_ioctl(fd, TCSETSF, (long)&termios);
78606 - sys_read(fd, &c, 1);
78607 + sys_read(fd, (char __user *)&c, 1);
78608 termios.c_lflag |= ICANON;
78609 sys_ioctl(fd, TCSETSF, (long)&termios);
78610 sys_close(fd);
78611 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78612 mount_root();
78613 out:
78614 devtmpfs_mount("dev");
78615 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78616 - sys_chroot(".");
78617 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78618 + sys_chroot((const char __force_user *)".");
78619 }
78620 diff --git a/init/do_mounts.h b/init/do_mounts.h
78621 index f5b978a..69dbfe8 100644
78622 --- a/init/do_mounts.h
78623 +++ b/init/do_mounts.h
78624 @@ -15,15 +15,15 @@ extern int root_mountflags;
78625
78626 static inline int create_dev(char *name, dev_t dev)
78627 {
78628 - sys_unlink(name);
78629 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78630 + sys_unlink((char __force_user *)name);
78631 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78632 }
78633
78634 #if BITS_PER_LONG == 32
78635 static inline u32 bstat(char *name)
78636 {
78637 struct stat64 stat;
78638 - if (sys_stat64(name, &stat) != 0)
78639 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78640 return 0;
78641 if (!S_ISBLK(stat.st_mode))
78642 return 0;
78643 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78644 static inline u32 bstat(char *name)
78645 {
78646 struct stat stat;
78647 - if (sys_newstat(name, &stat) != 0)
78648 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78649 return 0;
78650 if (!S_ISBLK(stat.st_mode))
78651 return 0;
78652 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
78653 index 3e0878e..8a9d7a0 100644
78654 --- a/init/do_mounts_initrd.c
78655 +++ b/init/do_mounts_initrd.c
78656 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
78657 {
78658 sys_unshare(CLONE_FS | CLONE_FILES);
78659 /* stdin/stdout/stderr for /linuxrc */
78660 - sys_open("/dev/console", O_RDWR, 0);
78661 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
78662 sys_dup(0);
78663 sys_dup(0);
78664 /* move initrd over / and chdir/chroot in initrd root */
78665 - sys_chdir("/root");
78666 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78667 - sys_chroot(".");
78668 + sys_chdir((const char __force_user *)"/root");
78669 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78670 + sys_chroot((const char __force_user *)".");
78671 sys_setsid();
78672 return 0;
78673 }
78674 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
78675 create_dev("/dev/root.old", Root_RAM0);
78676 /* mount initrd on rootfs' /root */
78677 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
78678 - sys_mkdir("/old", 0700);
78679 - sys_chdir("/old");
78680 + sys_mkdir((const char __force_user *)"/old", 0700);
78681 + sys_chdir((const char __force_user *)"/old");
78682
78683 /* try loading default modules from initrd */
78684 load_default_modules();
78685 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
78686 current->flags &= ~PF_FREEZER_SKIP;
78687
78688 /* move initrd to rootfs' /old */
78689 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
78690 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
78691 /* switch root and cwd back to / of rootfs */
78692 - sys_chroot("..");
78693 + sys_chroot((const char __force_user *)"..");
78694
78695 if (new_decode_dev(real_root_dev) == Root_RAM0) {
78696 - sys_chdir("/old");
78697 + sys_chdir((const char __force_user *)"/old");
78698 return;
78699 }
78700
78701 - sys_chdir("/");
78702 + sys_chdir((const char __force_user *)"/");
78703 ROOT_DEV = new_decode_dev(real_root_dev);
78704 mount_root();
78705
78706 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
78707 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
78708 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
78709 if (!error)
78710 printk("okay\n");
78711 else {
78712 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
78713 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
78714 if (error == -ENOENT)
78715 printk("/initrd does not exist. Ignored.\n");
78716 else
78717 printk("failed\n");
78718 printk(KERN_NOTICE "Unmounting old root\n");
78719 - sys_umount("/old", MNT_DETACH);
78720 + sys_umount((char __force_user *)"/old", MNT_DETACH);
78721 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
78722 if (fd < 0) {
78723 error = fd;
78724 @@ -127,11 +127,11 @@ int __init initrd_load(void)
78725 * mounted in the normal path.
78726 */
78727 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
78728 - sys_unlink("/initrd.image");
78729 + sys_unlink((const char __force_user *)"/initrd.image");
78730 handle_initrd();
78731 return 1;
78732 }
78733 }
78734 - sys_unlink("/initrd.image");
78735 + sys_unlink((const char __force_user *)"/initrd.image");
78736 return 0;
78737 }
78738 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
78739 index 8cb6db5..d729f50 100644
78740 --- a/init/do_mounts_md.c
78741 +++ b/init/do_mounts_md.c
78742 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
78743 partitioned ? "_d" : "", minor,
78744 md_setup_args[ent].device_names);
78745
78746 - fd = sys_open(name, 0, 0);
78747 + fd = sys_open((char __force_user *)name, 0, 0);
78748 if (fd < 0) {
78749 printk(KERN_ERR "md: open failed - cannot start "
78750 "array %s\n", name);
78751 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
78752 * array without it
78753 */
78754 sys_close(fd);
78755 - fd = sys_open(name, 0, 0);
78756 + fd = sys_open((char __force_user *)name, 0, 0);
78757 sys_ioctl(fd, BLKRRPART, 0);
78758 }
78759 sys_close(fd);
78760 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
78761
78762 wait_for_device_probe();
78763
78764 - fd = sys_open("/dev/md0", 0, 0);
78765 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
78766 if (fd >= 0) {
78767 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
78768 sys_close(fd);
78769 diff --git a/init/init_task.c b/init/init_task.c
78770 index ba0a7f36..2bcf1d5 100644
78771 --- a/init/init_task.c
78772 +++ b/init/init_task.c
78773 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
78774 * Initial thread structure. Alignment of this is handled by a special
78775 * linker map entry.
78776 */
78777 +#ifdef CONFIG_X86
78778 +union thread_union init_thread_union __init_task_data;
78779 +#else
78780 union thread_union init_thread_union __init_task_data =
78781 { INIT_THREAD_INFO(init_task) };
78782 +#endif
78783 diff --git a/init/initramfs.c b/init/initramfs.c
78784 index a67ef9d..2d17ed9 100644
78785 --- a/init/initramfs.c
78786 +++ b/init/initramfs.c
78787 @@ -84,7 +84,7 @@ static void __init free_hash(void)
78788 }
78789 }
78790
78791 -static long __init do_utime(char *filename, time_t mtime)
78792 +static long __init do_utime(char __force_user *filename, time_t mtime)
78793 {
78794 struct timespec t[2];
78795
78796 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
78797 struct dir_entry *de, *tmp;
78798 list_for_each_entry_safe(de, tmp, &dir_list, list) {
78799 list_del(&de->list);
78800 - do_utime(de->name, de->mtime);
78801 + do_utime((char __force_user *)de->name, de->mtime);
78802 kfree(de->name);
78803 kfree(de);
78804 }
78805 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
78806 if (nlink >= 2) {
78807 char *old = find_link(major, minor, ino, mode, collected);
78808 if (old)
78809 - return (sys_link(old, collected) < 0) ? -1 : 1;
78810 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
78811 }
78812 return 0;
78813 }
78814 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
78815 {
78816 struct stat st;
78817
78818 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
78819 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
78820 if (S_ISDIR(st.st_mode))
78821 - sys_rmdir(path);
78822 + sys_rmdir((char __force_user *)path);
78823 else
78824 - sys_unlink(path);
78825 + sys_unlink((char __force_user *)path);
78826 }
78827 }
78828
78829 @@ -315,7 +315,7 @@ static int __init do_name(void)
78830 int openflags = O_WRONLY|O_CREAT;
78831 if (ml != 1)
78832 openflags |= O_TRUNC;
78833 - wfd = sys_open(collected, openflags, mode);
78834 + wfd = sys_open((char __force_user *)collected, openflags, mode);
78835
78836 if (wfd >= 0) {
78837 sys_fchown(wfd, uid, gid);
78838 @@ -327,17 +327,17 @@ static int __init do_name(void)
78839 }
78840 }
78841 } else if (S_ISDIR(mode)) {
78842 - sys_mkdir(collected, mode);
78843 - sys_chown(collected, uid, gid);
78844 - sys_chmod(collected, mode);
78845 + sys_mkdir((char __force_user *)collected, mode);
78846 + sys_chown((char __force_user *)collected, uid, gid);
78847 + sys_chmod((char __force_user *)collected, mode);
78848 dir_add(collected, mtime);
78849 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
78850 S_ISFIFO(mode) || S_ISSOCK(mode)) {
78851 if (maybe_link() == 0) {
78852 - sys_mknod(collected, mode, rdev);
78853 - sys_chown(collected, uid, gid);
78854 - sys_chmod(collected, mode);
78855 - do_utime(collected, mtime);
78856 + sys_mknod((char __force_user *)collected, mode, rdev);
78857 + sys_chown((char __force_user *)collected, uid, gid);
78858 + sys_chmod((char __force_user *)collected, mode);
78859 + do_utime((char __force_user *)collected, mtime);
78860 }
78861 }
78862 return 0;
78863 @@ -346,15 +346,15 @@ static int __init do_name(void)
78864 static int __init do_copy(void)
78865 {
78866 if (count >= body_len) {
78867 - sys_write(wfd, victim, body_len);
78868 + sys_write(wfd, (char __force_user *)victim, body_len);
78869 sys_close(wfd);
78870 - do_utime(vcollected, mtime);
78871 + do_utime((char __force_user *)vcollected, mtime);
78872 kfree(vcollected);
78873 eat(body_len);
78874 state = SkipIt;
78875 return 0;
78876 } else {
78877 - sys_write(wfd, victim, count);
78878 + sys_write(wfd, (char __force_user *)victim, count);
78879 body_len -= count;
78880 eat(count);
78881 return 1;
78882 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
78883 {
78884 collected[N_ALIGN(name_len) + body_len] = '\0';
78885 clean_path(collected, 0);
78886 - sys_symlink(collected + N_ALIGN(name_len), collected);
78887 - sys_lchown(collected, uid, gid);
78888 - do_utime(collected, mtime);
78889 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
78890 + sys_lchown((char __force_user *)collected, uid, gid);
78891 + do_utime((char __force_user *)collected, mtime);
78892 state = SkipIt;
78893 next_state = Reset;
78894 return 0;
78895 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
78896 {
78897 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
78898 if (err)
78899 - panic(err); /* Failed to decompress INTERNAL initramfs */
78900 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
78901 if (initrd_start) {
78902 #ifdef CONFIG_BLK_DEV_RAM
78903 int fd;
78904 diff --git a/init/main.c b/init/main.c
78905 index d03d2ec..9fc4737 100644
78906 --- a/init/main.c
78907 +++ b/init/main.c
78908 @@ -101,6 +101,8 @@ static inline void mark_rodata_ro(void) { }
78909 extern void tc_init(void);
78910 #endif
78911
78912 +extern void grsecurity_init(void);
78913 +
78914 /*
78915 * Debug helper: via this flag we know that we are in 'early bootup code'
78916 * where only the boot processor is running with IRQ disabled. This means
78917 @@ -154,6 +156,74 @@ static int __init set_reset_devices(char *str)
78918
78919 __setup("reset_devices", set_reset_devices);
78920
78921 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
78922 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
78923 +static int __init setup_grsec_proc_gid(char *str)
78924 +{
78925 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
78926 + return 1;
78927 +}
78928 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
78929 +#endif
78930 +
78931 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
78932 +unsigned long pax_user_shadow_base __read_only;
78933 +EXPORT_SYMBOL(pax_user_shadow_base);
78934 +extern char pax_enter_kernel_user[];
78935 +extern char pax_exit_kernel_user[];
78936 +#endif
78937 +
78938 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
78939 +static int __init setup_pax_nouderef(char *str)
78940 +{
78941 +#ifdef CONFIG_X86_32
78942 + unsigned int cpu;
78943 + struct desc_struct *gdt;
78944 +
78945 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
78946 + gdt = get_cpu_gdt_table(cpu);
78947 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
78948 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
78949 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
78950 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
78951 + }
78952 + loadsegment(ds, __KERNEL_DS);
78953 + loadsegment(es, __KERNEL_DS);
78954 + loadsegment(ss, __KERNEL_DS);
78955 +#else
78956 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
78957 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
78958 + clone_pgd_mask = ~(pgdval_t)0UL;
78959 + pax_user_shadow_base = 0UL;
78960 + setup_clear_cpu_cap(X86_FEATURE_PCID);
78961 +#endif
78962 +
78963 + return 0;
78964 +}
78965 +early_param("pax_nouderef", setup_pax_nouderef);
78966 +
78967 +#ifdef CONFIG_X86_64
78968 +static int __init setup_pax_weakuderef(char *str)
78969 +{
78970 + if (clone_pgd_mask != ~(pgdval_t)0UL)
78971 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
78972 + return 1;
78973 +}
78974 +__setup("pax_weakuderef", setup_pax_weakuderef);
78975 +#endif
78976 +#endif
78977 +
78978 +#ifdef CONFIG_PAX_SOFTMODE
78979 +int pax_softmode;
78980 +
78981 +static int __init setup_pax_softmode(char *str)
78982 +{
78983 + get_option(&str, &pax_softmode);
78984 + return 1;
78985 +}
78986 +__setup("pax_softmode=", setup_pax_softmode);
78987 +#endif
78988 +
78989 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
78990 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
78991 static const char *panic_later, *panic_param;
78992 @@ -679,25 +749,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
78993 {
78994 int count = preempt_count();
78995 int ret;
78996 - char msgbuf[64];
78997 + const char *msg1 = "", *msg2 = "";
78998
78999 if (initcall_debug)
79000 ret = do_one_initcall_debug(fn);
79001 else
79002 ret = fn();
79003
79004 - msgbuf[0] = 0;
79005 -
79006 if (preempt_count() != count) {
79007 - sprintf(msgbuf, "preemption imbalance ");
79008 + msg1 = " preemption imbalance";
79009 preempt_count() = count;
79010 }
79011 if (irqs_disabled()) {
79012 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79013 + msg2 = " disabled interrupts";
79014 local_irq_enable();
79015 }
79016 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79017 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79018
79019 + add_latent_entropy();
79020 return ret;
79021 }
79022
79023 @@ -803,8 +872,8 @@ static int run_init_process(const char *init_filename)
79024 {
79025 argv_init[0] = init_filename;
79026 return do_execve(init_filename,
79027 - (const char __user *const __user *)argv_init,
79028 - (const char __user *const __user *)envp_init);
79029 + (const char __user *const __force_user *)argv_init,
79030 + (const char __user *const __force_user *)envp_init);
79031 }
79032
79033 static noinline void __init kernel_init_freeable(void);
79034 @@ -881,7 +950,7 @@ static noinline void __init kernel_init_freeable(void)
79035 do_basic_setup();
79036
79037 /* Open the /dev/console on the rootfs, this should never fail */
79038 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79039 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79040 pr_err("Warning: unable to open an initial console.\n");
79041
79042 (void) sys_dup(0);
79043 @@ -894,11 +963,13 @@ static noinline void __init kernel_init_freeable(void)
79044 if (!ramdisk_execute_command)
79045 ramdisk_execute_command = "/init";
79046
79047 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79048 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79049 ramdisk_execute_command = NULL;
79050 prepare_namespace();
79051 }
79052
79053 + grsecurity_init();
79054 +
79055 /*
79056 * Ok, we have completed the initial bootup, and
79057 * we're essentially up and running. Get rid of the
79058 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79059 index 130dfec..cc88451 100644
79060 --- a/ipc/ipc_sysctl.c
79061 +++ b/ipc/ipc_sysctl.c
79062 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79063 static int proc_ipc_dointvec(ctl_table *table, int write,
79064 void __user *buffer, size_t *lenp, loff_t *ppos)
79065 {
79066 - struct ctl_table ipc_table;
79067 + ctl_table_no_const ipc_table;
79068
79069 memcpy(&ipc_table, table, sizeof(ipc_table));
79070 ipc_table.data = get_ipc(table);
79071 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79072 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79073 void __user *buffer, size_t *lenp, loff_t *ppos)
79074 {
79075 - struct ctl_table ipc_table;
79076 + ctl_table_no_const ipc_table;
79077
79078 memcpy(&ipc_table, table, sizeof(ipc_table));
79079 ipc_table.data = get_ipc(table);
79080 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79081 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79082 void __user *buffer, size_t *lenp, loff_t *ppos)
79083 {
79084 - struct ctl_table ipc_table;
79085 + ctl_table_no_const ipc_table;
79086 size_t lenp_bef = *lenp;
79087 int rc;
79088
79089 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79090 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79091 void __user *buffer, size_t *lenp, loff_t *ppos)
79092 {
79093 - struct ctl_table ipc_table;
79094 + ctl_table_no_const ipc_table;
79095 memcpy(&ipc_table, table, sizeof(ipc_table));
79096 ipc_table.data = get_ipc(table);
79097
79098 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79099 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79100 void __user *buffer, size_t *lenp, loff_t *ppos)
79101 {
79102 - struct ctl_table ipc_table;
79103 + ctl_table_no_const ipc_table;
79104 size_t lenp_bef = *lenp;
79105 int oldval;
79106 int rc;
79107 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79108 index 383d638..943fdbb 100644
79109 --- a/ipc/mq_sysctl.c
79110 +++ b/ipc/mq_sysctl.c
79111 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79112 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79113 void __user *buffer, size_t *lenp, loff_t *ppos)
79114 {
79115 - struct ctl_table mq_table;
79116 + ctl_table_no_const mq_table;
79117 memcpy(&mq_table, table, sizeof(mq_table));
79118 mq_table.data = get_mq(table);
79119
79120 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79121 index ae1996d..a35f2cc 100644
79122 --- a/ipc/mqueue.c
79123 +++ b/ipc/mqueue.c
79124 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79125 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79126 info->attr.mq_msgsize);
79127
79128 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79129 spin_lock(&mq_lock);
79130 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79131 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79132 diff --git a/ipc/msg.c b/ipc/msg.c
79133 index a877c16..b632025 100644
79134 --- a/ipc/msg.c
79135 +++ b/ipc/msg.c
79136 @@ -298,18 +298,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79137 return security_msg_queue_associate(msq, msgflg);
79138 }
79139
79140 +static struct ipc_ops msg_ops = {
79141 + .getnew = newque,
79142 + .associate = msg_security,
79143 + .more_checks = NULL
79144 +};
79145 +
79146 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79147 {
79148 struct ipc_namespace *ns;
79149 - struct ipc_ops msg_ops;
79150 struct ipc_params msg_params;
79151
79152 ns = current->nsproxy->ipc_ns;
79153
79154 - msg_ops.getnew = newque;
79155 - msg_ops.associate = msg_security;
79156 - msg_ops.more_checks = NULL;
79157 -
79158 msg_params.key = key;
79159 msg_params.flg = msgflg;
79160
79161 diff --git a/ipc/sem.c b/ipc/sem.c
79162 index 87614511..c715d03 100644
79163 --- a/ipc/sem.c
79164 +++ b/ipc/sem.c
79165 @@ -554,10 +554,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79166 return 0;
79167 }
79168
79169 +static struct ipc_ops sem_ops = {
79170 + .getnew = newary,
79171 + .associate = sem_security,
79172 + .more_checks = sem_more_checks
79173 +};
79174 +
79175 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79176 {
79177 struct ipc_namespace *ns;
79178 - struct ipc_ops sem_ops;
79179 struct ipc_params sem_params;
79180
79181 ns = current->nsproxy->ipc_ns;
79182 @@ -565,10 +570,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79183 if (nsems < 0 || nsems > ns->sc_semmsl)
79184 return -EINVAL;
79185
79186 - sem_ops.getnew = newary;
79187 - sem_ops.associate = sem_security;
79188 - sem_ops.more_checks = sem_more_checks;
79189 -
79190 sem_params.key = key;
79191 sem_params.flg = semflg;
79192 sem_params.u.nsems = nsems;
79193 diff --git a/ipc/shm.c b/ipc/shm.c
79194 index 2d6833d..855bf81 100644
79195 --- a/ipc/shm.c
79196 +++ b/ipc/shm.c
79197 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79198 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79199 #endif
79200
79201 +#ifdef CONFIG_GRKERNSEC
79202 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79203 + const time_t shm_createtime, const kuid_t cuid,
79204 + const int shmid);
79205 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79206 + const time_t shm_createtime);
79207 +#endif
79208 +
79209 void shm_init_ns(struct ipc_namespace *ns)
79210 {
79211 ns->shm_ctlmax = SHMMAX;
79212 @@ -539,6 +547,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79213 shp->shm_lprid = 0;
79214 shp->shm_atim = shp->shm_dtim = 0;
79215 shp->shm_ctim = get_seconds();
79216 +#ifdef CONFIG_GRKERNSEC
79217 + {
79218 + struct timespec timeval;
79219 + do_posix_clock_monotonic_gettime(&timeval);
79220 +
79221 + shp->shm_createtime = timeval.tv_sec;
79222 + }
79223 +#endif
79224 shp->shm_segsz = size;
79225 shp->shm_nattch = 0;
79226 shp->shm_file = file;
79227 @@ -592,18 +608,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79228 return 0;
79229 }
79230
79231 +static struct ipc_ops shm_ops = {
79232 + .getnew = newseg,
79233 + .associate = shm_security,
79234 + .more_checks = shm_more_checks
79235 +};
79236 +
79237 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79238 {
79239 struct ipc_namespace *ns;
79240 - struct ipc_ops shm_ops;
79241 struct ipc_params shm_params;
79242
79243 ns = current->nsproxy->ipc_ns;
79244
79245 - shm_ops.getnew = newseg;
79246 - shm_ops.associate = shm_security;
79247 - shm_ops.more_checks = shm_more_checks;
79248 -
79249 shm_params.key = key;
79250 shm_params.flg = shmflg;
79251 shm_params.u.size = size;
79252 @@ -1035,6 +1052,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79253 f_mode = FMODE_READ | FMODE_WRITE;
79254 }
79255 if (shmflg & SHM_EXEC) {
79256 +
79257 +#ifdef CONFIG_PAX_MPROTECT
79258 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79259 + goto out;
79260 +#endif
79261 +
79262 prot |= PROT_EXEC;
79263 acc_mode |= S_IXUGO;
79264 }
79265 @@ -1058,9 +1081,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79266 if (err)
79267 goto out_unlock;
79268
79269 +#ifdef CONFIG_GRKERNSEC
79270 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79271 + shp->shm_perm.cuid, shmid) ||
79272 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79273 + err = -EACCES;
79274 + goto out_unlock;
79275 + }
79276 +#endif
79277 +
79278 path = shp->shm_file->f_path;
79279 path_get(&path);
79280 shp->shm_nattch++;
79281 +#ifdef CONFIG_GRKERNSEC
79282 + shp->shm_lapid = current->pid;
79283 +#endif
79284 size = i_size_read(path.dentry->d_inode);
79285 shm_unlock(shp);
79286
79287 diff --git a/kernel/acct.c b/kernel/acct.c
79288 index 8d6e145..33e0b1e 100644
79289 --- a/kernel/acct.c
79290 +++ b/kernel/acct.c
79291 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79292 */
79293 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79294 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79295 - file->f_op->write(file, (char *)&ac,
79296 + file->f_op->write(file, (char __force_user *)&ac,
79297 sizeof(acct_t), &file->f_pos);
79298 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79299 set_fs(fs);
79300 diff --git a/kernel/audit.c b/kernel/audit.c
79301 index 7b0e23a..5b27ab9 100644
79302 --- a/kernel/audit.c
79303 +++ b/kernel/audit.c
79304 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79305 3) suppressed due to audit_rate_limit
79306 4) suppressed due to audit_backlog_limit
79307 */
79308 -static atomic_t audit_lost = ATOMIC_INIT(0);
79309 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79310
79311 /* The netlink socket. */
79312 static struct sock *audit_sock;
79313 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79314 unsigned long now;
79315 int print;
79316
79317 - atomic_inc(&audit_lost);
79318 + atomic_inc_unchecked(&audit_lost);
79319
79320 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79321
79322 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79323 printk(KERN_WARNING
79324 "audit: audit_lost=%d audit_rate_limit=%d "
79325 "audit_backlog_limit=%d\n",
79326 - atomic_read(&audit_lost),
79327 + atomic_read_unchecked(&audit_lost),
79328 audit_rate_limit,
79329 audit_backlog_limit);
79330 audit_panic(message);
79331 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79332
79333 switch (msg_type) {
79334 case AUDIT_GET:
79335 + status_set.mask = 0;
79336 status_set.enabled = audit_enabled;
79337 status_set.failure = audit_failure;
79338 status_set.pid = audit_pid;
79339 status_set.rate_limit = audit_rate_limit;
79340 status_set.backlog_limit = audit_backlog_limit;
79341 - status_set.lost = atomic_read(&audit_lost);
79342 + status_set.lost = atomic_read_unchecked(&audit_lost);
79343 status_set.backlog = skb_queue_len(&audit_skb_queue);
79344 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79345 &status_set, sizeof(status_set));
79346 break;
79347 case AUDIT_SET:
79348 - if (nlh->nlmsg_len < sizeof(struct audit_status))
79349 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
79350 return -EINVAL;
79351 status_get = (struct audit_status *)data;
79352 if (status_get->mask & AUDIT_STATUS_ENABLED) {
79353 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79354
79355 memset(&s, 0, sizeof(s));
79356 /* guard against past and future API changes */
79357 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
79358 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
79359 if ((s.enabled != 0 && s.enabled != 1) ||
79360 (s.log_passwd != 0 && s.log_passwd != 1))
79361 return -EINVAL;
79362 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79363 index 9845cb3..3ec9369 100644
79364 --- a/kernel/auditsc.c
79365 +++ b/kernel/auditsc.c
79366 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79367 }
79368
79369 /* global counter which is incremented every time something logs in */
79370 -static atomic_t session_id = ATOMIC_INIT(0);
79371 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79372
79373 /**
79374 * audit_set_loginuid - set current task's audit_context loginuid
79375 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79376 return -EPERM;
79377 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79378
79379 - sessionid = atomic_inc_return(&session_id);
79380 + sessionid = atomic_inc_return_unchecked(&session_id);
79381 if (context && context->in_syscall) {
79382 struct audit_buffer *ab;
79383
79384 diff --git a/kernel/capability.c b/kernel/capability.c
79385 index f6c2ce5..982c0f9 100644
79386 --- a/kernel/capability.c
79387 +++ b/kernel/capability.c
79388 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79389 * before modification is attempted and the application
79390 * fails.
79391 */
79392 + if (tocopy > ARRAY_SIZE(kdata))
79393 + return -EFAULT;
79394 +
79395 if (copy_to_user(dataptr, kdata, tocopy
79396 * sizeof(struct __user_cap_data_struct))) {
79397 return -EFAULT;
79398 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79399 int ret;
79400
79401 rcu_read_lock();
79402 - ret = security_capable(__task_cred(t), ns, cap);
79403 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79404 + gr_task_is_capable(t, __task_cred(t), cap);
79405 rcu_read_unlock();
79406
79407 - return (ret == 0);
79408 + return ret;
79409 }
79410
79411 /**
79412 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79413 int ret;
79414
79415 rcu_read_lock();
79416 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79417 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79418 rcu_read_unlock();
79419
79420 - return (ret == 0);
79421 + return ret;
79422 }
79423
79424 /**
79425 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79426 BUG();
79427 }
79428
79429 - if (security_capable(current_cred(), ns, cap) == 0) {
79430 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79431 current->flags |= PF_SUPERPRIV;
79432 return true;
79433 }
79434 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79435 }
79436 EXPORT_SYMBOL(ns_capable);
79437
79438 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79439 +{
79440 + if (unlikely(!cap_valid(cap))) {
79441 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79442 + BUG();
79443 + }
79444 +
79445 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79446 + current->flags |= PF_SUPERPRIV;
79447 + return true;
79448 + }
79449 + return false;
79450 +}
79451 +EXPORT_SYMBOL(ns_capable_nolog);
79452 +
79453 /**
79454 * file_ns_capable - Determine if the file's opener had a capability in effect
79455 * @file: The file we want to check
79456 @@ -432,6 +451,12 @@ bool capable(int cap)
79457 }
79458 EXPORT_SYMBOL(capable);
79459
79460 +bool capable_nolog(int cap)
79461 +{
79462 + return ns_capable_nolog(&init_user_ns, cap);
79463 +}
79464 +EXPORT_SYMBOL(capable_nolog);
79465 +
79466 /**
79467 * nsown_capable - Check superior capability to one's own user_ns
79468 * @cap: The capability in question
79469 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79470
79471 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79472 }
79473 +
79474 +bool inode_capable_nolog(const struct inode *inode, int cap)
79475 +{
79476 + struct user_namespace *ns = current_user_ns();
79477 +
79478 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79479 +}
79480 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79481 index e919633..f46b08f 100644
79482 --- a/kernel/cgroup.c
79483 +++ b/kernel/cgroup.c
79484 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79485 struct css_set *cset = link->cset;
79486 struct task_struct *task;
79487 int count = 0;
79488 - seq_printf(seq, "css_set %p\n", cset);
79489 + seq_printf(seq, "css_set %pK\n", cset);
79490 list_for_each_entry(task, &cset->tasks, cg_list) {
79491 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79492 seq_puts(seq, " ...\n");
79493 diff --git a/kernel/compat.c b/kernel/compat.c
79494 index 0a09e48..f44f3f0 100644
79495 --- a/kernel/compat.c
79496 +++ b/kernel/compat.c
79497 @@ -13,6 +13,7 @@
79498
79499 #include <linux/linkage.h>
79500 #include <linux/compat.h>
79501 +#include <linux/module.h>
79502 #include <linux/errno.h>
79503 #include <linux/time.h>
79504 #include <linux/signal.h>
79505 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79506 mm_segment_t oldfs;
79507 long ret;
79508
79509 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79510 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79511 oldfs = get_fs();
79512 set_fs(KERNEL_DS);
79513 ret = hrtimer_nanosleep_restart(restart);
79514 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79515 oldfs = get_fs();
79516 set_fs(KERNEL_DS);
79517 ret = hrtimer_nanosleep(&tu,
79518 - rmtp ? (struct timespec __user *)&rmt : NULL,
79519 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79520 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79521 set_fs(oldfs);
79522
79523 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79524 mm_segment_t old_fs = get_fs();
79525
79526 set_fs(KERNEL_DS);
79527 - ret = sys_sigpending((old_sigset_t __user *) &s);
79528 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79529 set_fs(old_fs);
79530 if (ret == 0)
79531 ret = put_user(s, set);
79532 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79533 mm_segment_t old_fs = get_fs();
79534
79535 set_fs(KERNEL_DS);
79536 - ret = sys_old_getrlimit(resource, &r);
79537 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79538 set_fs(old_fs);
79539
79540 if (!ret) {
79541 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79542 set_fs (KERNEL_DS);
79543 ret = sys_wait4(pid,
79544 (stat_addr ?
79545 - (unsigned int __user *) &status : NULL),
79546 - options, (struct rusage __user *) &r);
79547 + (unsigned int __force_user *) &status : NULL),
79548 + options, (struct rusage __force_user *) &r);
79549 set_fs (old_fs);
79550
79551 if (ret > 0) {
79552 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79553 memset(&info, 0, sizeof(info));
79554
79555 set_fs(KERNEL_DS);
79556 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79557 - uru ? (struct rusage __user *)&ru : NULL);
79558 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79559 + uru ? (struct rusage __force_user *)&ru : NULL);
79560 set_fs(old_fs);
79561
79562 if ((ret < 0) || (info.si_signo == 0))
79563 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79564 oldfs = get_fs();
79565 set_fs(KERNEL_DS);
79566 err = sys_timer_settime(timer_id, flags,
79567 - (struct itimerspec __user *) &newts,
79568 - (struct itimerspec __user *) &oldts);
79569 + (struct itimerspec __force_user *) &newts,
79570 + (struct itimerspec __force_user *) &oldts);
79571 set_fs(oldfs);
79572 if (!err && old && put_compat_itimerspec(old, &oldts))
79573 return -EFAULT;
79574 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79575 oldfs = get_fs();
79576 set_fs(KERNEL_DS);
79577 err = sys_timer_gettime(timer_id,
79578 - (struct itimerspec __user *) &ts);
79579 + (struct itimerspec __force_user *) &ts);
79580 set_fs(oldfs);
79581 if (!err && put_compat_itimerspec(setting, &ts))
79582 return -EFAULT;
79583 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79584 oldfs = get_fs();
79585 set_fs(KERNEL_DS);
79586 err = sys_clock_settime(which_clock,
79587 - (struct timespec __user *) &ts);
79588 + (struct timespec __force_user *) &ts);
79589 set_fs(oldfs);
79590 return err;
79591 }
79592 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79593 oldfs = get_fs();
79594 set_fs(KERNEL_DS);
79595 err = sys_clock_gettime(which_clock,
79596 - (struct timespec __user *) &ts);
79597 + (struct timespec __force_user *) &ts);
79598 set_fs(oldfs);
79599 if (!err && put_compat_timespec(&ts, tp))
79600 return -EFAULT;
79601 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79602
79603 oldfs = get_fs();
79604 set_fs(KERNEL_DS);
79605 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79606 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79607 set_fs(oldfs);
79608
79609 err = compat_put_timex(utp, &txc);
79610 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79611 oldfs = get_fs();
79612 set_fs(KERNEL_DS);
79613 err = sys_clock_getres(which_clock,
79614 - (struct timespec __user *) &ts);
79615 + (struct timespec __force_user *) &ts);
79616 set_fs(oldfs);
79617 if (!err && tp && put_compat_timespec(&ts, tp))
79618 return -EFAULT;
79619 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79620 long err;
79621 mm_segment_t oldfs;
79622 struct timespec tu;
79623 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79624 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79625
79626 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79627 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79628 oldfs = get_fs();
79629 set_fs(KERNEL_DS);
79630 err = clock_nanosleep_restart(restart);
79631 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79632 oldfs = get_fs();
79633 set_fs(KERNEL_DS);
79634 err = sys_clock_nanosleep(which_clock, flags,
79635 - (struct timespec __user *) &in,
79636 - (struct timespec __user *) &out);
79637 + (struct timespec __force_user *) &in,
79638 + (struct timespec __force_user *) &out);
79639 set_fs(oldfs);
79640
79641 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79642 diff --git a/kernel/configs.c b/kernel/configs.c
79643 index c18b1f1..b9a0132 100644
79644 --- a/kernel/configs.c
79645 +++ b/kernel/configs.c
79646 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79647 struct proc_dir_entry *entry;
79648
79649 /* create the current config file */
79650 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79651 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
79652 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
79653 + &ikconfig_file_ops);
79654 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79655 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
79656 + &ikconfig_file_ops);
79657 +#endif
79658 +#else
79659 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
79660 &ikconfig_file_ops);
79661 +#endif
79662 +
79663 if (!entry)
79664 return -ENOMEM;
79665
79666 diff --git a/kernel/cred.c b/kernel/cred.c
79667 index e0573a4..3874e41 100644
79668 --- a/kernel/cred.c
79669 +++ b/kernel/cred.c
79670 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
79671 validate_creds(cred);
79672 alter_cred_subscribers(cred, -1);
79673 put_cred(cred);
79674 +
79675 +#ifdef CONFIG_GRKERNSEC_SETXID
79676 + cred = (struct cred *) tsk->delayed_cred;
79677 + if (cred != NULL) {
79678 + tsk->delayed_cred = NULL;
79679 + validate_creds(cred);
79680 + alter_cred_subscribers(cred, -1);
79681 + put_cred(cred);
79682 + }
79683 +#endif
79684 }
79685
79686 /**
79687 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
79688 * Always returns 0 thus allowing this function to be tail-called at the end
79689 * of, say, sys_setgid().
79690 */
79691 -int commit_creds(struct cred *new)
79692 +static int __commit_creds(struct cred *new)
79693 {
79694 struct task_struct *task = current;
79695 const struct cred *old = task->real_cred;
79696 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
79697
79698 get_cred(new); /* we will require a ref for the subj creds too */
79699
79700 + gr_set_role_label(task, new->uid, new->gid);
79701 +
79702 /* dumpability changes */
79703 if (!uid_eq(old->euid, new->euid) ||
79704 !gid_eq(old->egid, new->egid) ||
79705 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
79706 put_cred(old);
79707 return 0;
79708 }
79709 +#ifdef CONFIG_GRKERNSEC_SETXID
79710 +extern int set_user(struct cred *new);
79711 +
79712 +void gr_delayed_cred_worker(void)
79713 +{
79714 + const struct cred *new = current->delayed_cred;
79715 + struct cred *ncred;
79716 +
79717 + current->delayed_cred = NULL;
79718 +
79719 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
79720 + // from doing get_cred on it when queueing this
79721 + put_cred(new);
79722 + return;
79723 + } else if (new == NULL)
79724 + return;
79725 +
79726 + ncred = prepare_creds();
79727 + if (!ncred)
79728 + goto die;
79729 + // uids
79730 + ncred->uid = new->uid;
79731 + ncred->euid = new->euid;
79732 + ncred->suid = new->suid;
79733 + ncred->fsuid = new->fsuid;
79734 + // gids
79735 + ncred->gid = new->gid;
79736 + ncred->egid = new->egid;
79737 + ncred->sgid = new->sgid;
79738 + ncred->fsgid = new->fsgid;
79739 + // groups
79740 + if (set_groups(ncred, new->group_info) < 0) {
79741 + abort_creds(ncred);
79742 + goto die;
79743 + }
79744 + // caps
79745 + ncred->securebits = new->securebits;
79746 + ncred->cap_inheritable = new->cap_inheritable;
79747 + ncred->cap_permitted = new->cap_permitted;
79748 + ncred->cap_effective = new->cap_effective;
79749 + ncred->cap_bset = new->cap_bset;
79750 +
79751 + if (set_user(ncred)) {
79752 + abort_creds(ncred);
79753 + goto die;
79754 + }
79755 +
79756 + // from doing get_cred on it when queueing this
79757 + put_cred(new);
79758 +
79759 + __commit_creds(ncred);
79760 + return;
79761 +die:
79762 + // from doing get_cred on it when queueing this
79763 + put_cred(new);
79764 + do_group_exit(SIGKILL);
79765 +}
79766 +#endif
79767 +
79768 +int commit_creds(struct cred *new)
79769 +{
79770 +#ifdef CONFIG_GRKERNSEC_SETXID
79771 + int ret;
79772 + int schedule_it = 0;
79773 + struct task_struct *t;
79774 +
79775 + /* we won't get called with tasklist_lock held for writing
79776 + and interrupts disabled as the cred struct in that case is
79777 + init_cred
79778 + */
79779 + if (grsec_enable_setxid && !current_is_single_threaded() &&
79780 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
79781 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
79782 + schedule_it = 1;
79783 + }
79784 + ret = __commit_creds(new);
79785 + if (schedule_it) {
79786 + rcu_read_lock();
79787 + read_lock(&tasklist_lock);
79788 + for (t = next_thread(current); t != current;
79789 + t = next_thread(t)) {
79790 + if (t->delayed_cred == NULL) {
79791 + t->delayed_cred = get_cred(new);
79792 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
79793 + set_tsk_need_resched(t);
79794 + }
79795 + }
79796 + read_unlock(&tasklist_lock);
79797 + rcu_read_unlock();
79798 + }
79799 + return ret;
79800 +#else
79801 + return __commit_creds(new);
79802 +#endif
79803 +}
79804 +
79805 EXPORT_SYMBOL(commit_creds);
79806
79807 /**
79808 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
79809 index 0506d44..2c20034 100644
79810 --- a/kernel/debug/debug_core.c
79811 +++ b/kernel/debug/debug_core.c
79812 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
79813 */
79814 static atomic_t masters_in_kgdb;
79815 static atomic_t slaves_in_kgdb;
79816 -static atomic_t kgdb_break_tasklet_var;
79817 +static atomic_unchecked_t kgdb_break_tasklet_var;
79818 atomic_t kgdb_setting_breakpoint;
79819
79820 struct task_struct *kgdb_usethread;
79821 @@ -133,7 +133,7 @@ int kgdb_single_step;
79822 static pid_t kgdb_sstep_pid;
79823
79824 /* to keep track of the CPU which is doing the single stepping*/
79825 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
79826 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
79827
79828 /*
79829 * If you are debugging a problem where roundup (the collection of
79830 @@ -541,7 +541,7 @@ return_normal:
79831 * kernel will only try for the value of sstep_tries before
79832 * giving up and continuing on.
79833 */
79834 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
79835 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
79836 (kgdb_info[cpu].task &&
79837 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
79838 atomic_set(&kgdb_active, -1);
79839 @@ -635,8 +635,8 @@ cpu_master_loop:
79840 }
79841
79842 kgdb_restore:
79843 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
79844 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
79845 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
79846 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
79847 if (kgdb_info[sstep_cpu].task)
79848 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
79849 else
79850 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
79851 static void kgdb_tasklet_bpt(unsigned long ing)
79852 {
79853 kgdb_breakpoint();
79854 - atomic_set(&kgdb_break_tasklet_var, 0);
79855 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
79856 }
79857
79858 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
79859
79860 void kgdb_schedule_breakpoint(void)
79861 {
79862 - if (atomic_read(&kgdb_break_tasklet_var) ||
79863 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
79864 atomic_read(&kgdb_active) != -1 ||
79865 atomic_read(&kgdb_setting_breakpoint))
79866 return;
79867 - atomic_inc(&kgdb_break_tasklet_var);
79868 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
79869 tasklet_schedule(&kgdb_tasklet_breakpoint);
79870 }
79871 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
79872 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
79873 index 00eb8f7..d7e3244 100644
79874 --- a/kernel/debug/kdb/kdb_main.c
79875 +++ b/kernel/debug/kdb/kdb_main.c
79876 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
79877 continue;
79878
79879 kdb_printf("%-20s%8u 0x%p ", mod->name,
79880 - mod->core_size, (void *)mod);
79881 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
79882 #ifdef CONFIG_MODULE_UNLOAD
79883 kdb_printf("%4ld ", module_refcount(mod));
79884 #endif
79885 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
79886 kdb_printf(" (Loading)");
79887 else
79888 kdb_printf(" (Live)");
79889 - kdb_printf(" 0x%p", mod->module_core);
79890 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
79891
79892 #ifdef CONFIG_MODULE_UNLOAD
79893 {
79894 diff --git a/kernel/events/core.c b/kernel/events/core.c
79895 index f86599e..b18b180 100644
79896 --- a/kernel/events/core.c
79897 +++ b/kernel/events/core.c
79898 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
79899 * 0 - disallow raw tracepoint access for unpriv
79900 * 1 - disallow cpu events for unpriv
79901 * 2 - disallow kernel profiling for unpriv
79902 + * 3 - disallow all unpriv perf event use
79903 */
79904 -int sysctl_perf_event_paranoid __read_mostly = 1;
79905 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
79906 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
79907 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
79908 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
79909 +#else
79910 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
79911 +#endif
79912
79913 /* Minimum for 512 kiB + 1 user control page */
79914 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
79915 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
79916 update_perf_cpu_limits();
79917 }
79918
79919 -static atomic64_t perf_event_id;
79920 +static atomic64_unchecked_t perf_event_id;
79921
79922 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
79923 enum event_type_t event_type);
79924 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
79925
79926 static inline u64 perf_event_count(struct perf_event *event)
79927 {
79928 - return local64_read(&event->count) + atomic64_read(&event->child_count);
79929 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
79930 }
79931
79932 static u64 perf_event_read(struct perf_event *event)
79933 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
79934 mutex_lock(&event->child_mutex);
79935 total += perf_event_read(event);
79936 *enabled += event->total_time_enabled +
79937 - atomic64_read(&event->child_total_time_enabled);
79938 + atomic64_read_unchecked(&event->child_total_time_enabled);
79939 *running += event->total_time_running +
79940 - atomic64_read(&event->child_total_time_running);
79941 + atomic64_read_unchecked(&event->child_total_time_running);
79942
79943 list_for_each_entry(child, &event->child_list, child_list) {
79944 total += perf_event_read(child);
79945 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
79946 userpg->offset -= local64_read(&event->hw.prev_count);
79947
79948 userpg->time_enabled = enabled +
79949 - atomic64_read(&event->child_total_time_enabled);
79950 + atomic64_read_unchecked(&event->child_total_time_enabled);
79951
79952 userpg->time_running = running +
79953 - atomic64_read(&event->child_total_time_running);
79954 + atomic64_read_unchecked(&event->child_total_time_running);
79955
79956 arch_perf_update_userpage(userpg, now);
79957
79958 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
79959
79960 /* Data. */
79961 sp = perf_user_stack_pointer(regs);
79962 - rem = __output_copy_user(handle, (void *) sp, dump_size);
79963 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
79964 dyn_size = dump_size - rem;
79965
79966 perf_output_skip(handle, rem);
79967 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
79968 values[n++] = perf_event_count(event);
79969 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
79970 values[n++] = enabled +
79971 - atomic64_read(&event->child_total_time_enabled);
79972 + atomic64_read_unchecked(&event->child_total_time_enabled);
79973 }
79974 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
79975 values[n++] = running +
79976 - atomic64_read(&event->child_total_time_running);
79977 + atomic64_read_unchecked(&event->child_total_time_running);
79978 }
79979 if (read_format & PERF_FORMAT_ID)
79980 values[n++] = primary_event_id(event);
79981 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
79982 * need to add enough zero bytes after the string to handle
79983 * the 64bit alignment we do later.
79984 */
79985 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
79986 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
79987 if (!buf) {
79988 name = strncpy(tmp, "//enomem", sizeof(tmp));
79989 goto got_name;
79990 }
79991 - name = d_path(&file->f_path, buf, PATH_MAX);
79992 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
79993 if (IS_ERR(name)) {
79994 name = strncpy(tmp, "//toolong", sizeof(tmp));
79995 goto got_name;
79996 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
79997 event->parent = parent_event;
79998
79999 event->ns = get_pid_ns(task_active_pid_ns(current));
80000 - event->id = atomic64_inc_return(&perf_event_id);
80001 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80002
80003 event->state = PERF_EVENT_STATE_INACTIVE;
80004
80005 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80006 if (flags & ~PERF_FLAG_ALL)
80007 return -EINVAL;
80008
80009 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80010 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80011 + return -EACCES;
80012 +#endif
80013 +
80014 err = perf_copy_attr(attr_uptr, &attr);
80015 if (err)
80016 return err;
80017 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80018 /*
80019 * Add back the child's count to the parent's count:
80020 */
80021 - atomic64_add(child_val, &parent_event->child_count);
80022 - atomic64_add(child_event->total_time_enabled,
80023 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80024 + atomic64_add_unchecked(child_event->total_time_enabled,
80025 &parent_event->child_total_time_enabled);
80026 - atomic64_add(child_event->total_time_running,
80027 + atomic64_add_unchecked(child_event->total_time_running,
80028 &parent_event->child_total_time_running);
80029
80030 /*
80031 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80032 index ca65997..60df03d 100644
80033 --- a/kernel/events/internal.h
80034 +++ b/kernel/events/internal.h
80035 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80036 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80037 }
80038
80039 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80040 -static inline unsigned int \
80041 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80042 +static inline unsigned long \
80043 func_name(struct perf_output_handle *handle, \
80044 - const void *buf, unsigned int len) \
80045 + const void user *buf, unsigned long len) \
80046 { \
80047 unsigned long size, written; \
80048 \
80049 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80050 return n;
80051 }
80052
80053 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80054 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80055
80056 #define MEMCPY_SKIP(dst, src, n) (n)
80057
80058 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80059 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80060
80061 #ifndef arch_perf_out_copy_user
80062 #define arch_perf_out_copy_user __copy_from_user_inatomic
80063 #endif
80064
80065 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80066 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80067
80068 /* Callchain handling */
80069 extern struct perf_callchain_entry *
80070 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80071 index ad8e1bd..fed7ba9 100644
80072 --- a/kernel/events/uprobes.c
80073 +++ b/kernel/events/uprobes.c
80074 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80075 {
80076 struct page *page;
80077 uprobe_opcode_t opcode;
80078 - int result;
80079 + long result;
80080
80081 pagefault_disable();
80082 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80083 diff --git a/kernel/exit.c b/kernel/exit.c
80084 index a949819..a5f127d 100644
80085 --- a/kernel/exit.c
80086 +++ b/kernel/exit.c
80087 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80088 struct task_struct *leader;
80089 int zap_leader;
80090 repeat:
80091 +#ifdef CONFIG_NET
80092 + gr_del_task_from_ip_table(p);
80093 +#endif
80094 +
80095 /* don't need to get the RCU readlock here - the process is dead and
80096 * can't be modifying its own credentials. But shut RCU-lockdep up */
80097 rcu_read_lock();
80098 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80099 * know it'll be handled, so that they don't get converted to
80100 * SIGKILL or just silently dropped.
80101 */
80102 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80103 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80104 recalc_sigpending();
80105 spin_unlock_irq(&current->sighand->siglock);
80106 return 0;
80107 @@ -698,6 +702,8 @@ void do_exit(long code)
80108 struct task_struct *tsk = current;
80109 int group_dead;
80110
80111 + set_fs(USER_DS);
80112 +
80113 profile_task_exit(tsk);
80114
80115 WARN_ON(blk_needs_flush_plug(tsk));
80116 @@ -714,7 +720,6 @@ void do_exit(long code)
80117 * mm_release()->clear_child_tid() from writing to a user-controlled
80118 * kernel address.
80119 */
80120 - set_fs(USER_DS);
80121
80122 ptrace_event(PTRACE_EVENT_EXIT, code);
80123
80124 @@ -773,6 +778,9 @@ void do_exit(long code)
80125 tsk->exit_code = code;
80126 taskstats_exit(tsk, group_dead);
80127
80128 + gr_acl_handle_psacct(tsk, code);
80129 + gr_acl_handle_exit();
80130 +
80131 exit_mm(tsk);
80132
80133 if (group_dead)
80134 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80135 * Take down every thread in the group. This is called by fatal signals
80136 * as well as by sys_exit_group (below).
80137 */
80138 -void
80139 +__noreturn void
80140 do_group_exit(int exit_code)
80141 {
80142 struct signal_struct *sig = current->signal;
80143 diff --git a/kernel/fork.c b/kernel/fork.c
80144 index 200a7a2..43e52da 100644
80145 --- a/kernel/fork.c
80146 +++ b/kernel/fork.c
80147 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80148 *stackend = STACK_END_MAGIC; /* for overflow detection */
80149
80150 #ifdef CONFIG_CC_STACKPROTECTOR
80151 - tsk->stack_canary = get_random_int();
80152 + tsk->stack_canary = pax_get_random_long();
80153 #endif
80154
80155 /*
80156 @@ -345,13 +345,81 @@ free_tsk:
80157 }
80158
80159 #ifdef CONFIG_MMU
80160 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80161 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80162 {
80163 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80164 - struct rb_node **rb_link, *rb_parent;
80165 - int retval;
80166 + struct vm_area_struct *tmp;
80167 unsigned long charge;
80168 struct mempolicy *pol;
80169 + struct file *file;
80170 +
80171 + charge = 0;
80172 + if (mpnt->vm_flags & VM_ACCOUNT) {
80173 + unsigned long len = vma_pages(mpnt);
80174 +
80175 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80176 + goto fail_nomem;
80177 + charge = len;
80178 + }
80179 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80180 + if (!tmp)
80181 + goto fail_nomem;
80182 + *tmp = *mpnt;
80183 + tmp->vm_mm = mm;
80184 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80185 + pol = mpol_dup(vma_policy(mpnt));
80186 + if (IS_ERR(pol))
80187 + goto fail_nomem_policy;
80188 + vma_set_policy(tmp, pol);
80189 + if (anon_vma_fork(tmp, mpnt))
80190 + goto fail_nomem_anon_vma_fork;
80191 + tmp->vm_flags &= ~VM_LOCKED;
80192 + tmp->vm_next = tmp->vm_prev = NULL;
80193 + tmp->vm_mirror = NULL;
80194 + file = tmp->vm_file;
80195 + if (file) {
80196 + struct inode *inode = file_inode(file);
80197 + struct address_space *mapping = file->f_mapping;
80198 +
80199 + get_file(file);
80200 + if (tmp->vm_flags & VM_DENYWRITE)
80201 + atomic_dec(&inode->i_writecount);
80202 + mutex_lock(&mapping->i_mmap_mutex);
80203 + if (tmp->vm_flags & VM_SHARED)
80204 + mapping->i_mmap_writable++;
80205 + flush_dcache_mmap_lock(mapping);
80206 + /* insert tmp into the share list, just after mpnt */
80207 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80208 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80209 + else
80210 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80211 + flush_dcache_mmap_unlock(mapping);
80212 + mutex_unlock(&mapping->i_mmap_mutex);
80213 + }
80214 +
80215 + /*
80216 + * Clear hugetlb-related page reserves for children. This only
80217 + * affects MAP_PRIVATE mappings. Faults generated by the child
80218 + * are not guaranteed to succeed, even if read-only
80219 + */
80220 + if (is_vm_hugetlb_page(tmp))
80221 + reset_vma_resv_huge_pages(tmp);
80222 +
80223 + return tmp;
80224 +
80225 +fail_nomem_anon_vma_fork:
80226 + mpol_put(pol);
80227 +fail_nomem_policy:
80228 + kmem_cache_free(vm_area_cachep, tmp);
80229 +fail_nomem:
80230 + vm_unacct_memory(charge);
80231 + return NULL;
80232 +}
80233 +
80234 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80235 +{
80236 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80237 + struct rb_node **rb_link, *rb_parent;
80238 + int retval;
80239
80240 uprobe_start_dup_mmap();
80241 down_write(&oldmm->mmap_sem);
80242 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80243
80244 prev = NULL;
80245 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80246 - struct file *file;
80247 -
80248 if (mpnt->vm_flags & VM_DONTCOPY) {
80249 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80250 -vma_pages(mpnt));
80251 continue;
80252 }
80253 - charge = 0;
80254 - if (mpnt->vm_flags & VM_ACCOUNT) {
80255 - unsigned long len = vma_pages(mpnt);
80256 -
80257 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80258 - goto fail_nomem;
80259 - charge = len;
80260 - }
80261 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80262 - if (!tmp)
80263 - goto fail_nomem;
80264 - *tmp = *mpnt;
80265 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80266 - pol = mpol_dup(vma_policy(mpnt));
80267 - retval = PTR_ERR(pol);
80268 - if (IS_ERR(pol))
80269 - goto fail_nomem_policy;
80270 - vma_set_policy(tmp, pol);
80271 - tmp->vm_mm = mm;
80272 - if (anon_vma_fork(tmp, mpnt))
80273 - goto fail_nomem_anon_vma_fork;
80274 - tmp->vm_flags &= ~VM_LOCKED;
80275 - tmp->vm_next = tmp->vm_prev = NULL;
80276 - file = tmp->vm_file;
80277 - if (file) {
80278 - struct inode *inode = file_inode(file);
80279 - struct address_space *mapping = file->f_mapping;
80280 -
80281 - get_file(file);
80282 - if (tmp->vm_flags & VM_DENYWRITE)
80283 - atomic_dec(&inode->i_writecount);
80284 - mutex_lock(&mapping->i_mmap_mutex);
80285 - if (tmp->vm_flags & VM_SHARED)
80286 - mapping->i_mmap_writable++;
80287 - flush_dcache_mmap_lock(mapping);
80288 - /* insert tmp into the share list, just after mpnt */
80289 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80290 - vma_nonlinear_insert(tmp,
80291 - &mapping->i_mmap_nonlinear);
80292 - else
80293 - vma_interval_tree_insert_after(tmp, mpnt,
80294 - &mapping->i_mmap);
80295 - flush_dcache_mmap_unlock(mapping);
80296 - mutex_unlock(&mapping->i_mmap_mutex);
80297 + tmp = dup_vma(mm, oldmm, mpnt);
80298 + if (!tmp) {
80299 + retval = -ENOMEM;
80300 + goto out;
80301 }
80302
80303 /*
80304 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80305 if (retval)
80306 goto out;
80307 }
80308 +
80309 +#ifdef CONFIG_PAX_SEGMEXEC
80310 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80311 + struct vm_area_struct *mpnt_m;
80312 +
80313 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80314 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80315 +
80316 + if (!mpnt->vm_mirror)
80317 + continue;
80318 +
80319 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80320 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80321 + mpnt->vm_mirror = mpnt_m;
80322 + } else {
80323 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80324 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80325 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80326 + mpnt->vm_mirror->vm_mirror = mpnt;
80327 + }
80328 + }
80329 + BUG_ON(mpnt_m);
80330 + }
80331 +#endif
80332 +
80333 /* a new mm has just been created */
80334 arch_dup_mmap(oldmm, mm);
80335 retval = 0;
80336 @@ -471,14 +522,6 @@ out:
80337 up_write(&oldmm->mmap_sem);
80338 uprobe_end_dup_mmap();
80339 return retval;
80340 -fail_nomem_anon_vma_fork:
80341 - mpol_put(pol);
80342 -fail_nomem_policy:
80343 - kmem_cache_free(vm_area_cachep, tmp);
80344 -fail_nomem:
80345 - retval = -ENOMEM;
80346 - vm_unacct_memory(charge);
80347 - goto out;
80348 }
80349
80350 static inline int mm_alloc_pgd(struct mm_struct *mm)
80351 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80352 return ERR_PTR(err);
80353
80354 mm = get_task_mm(task);
80355 - if (mm && mm != current->mm &&
80356 - !ptrace_may_access(task, mode)) {
80357 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80358 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80359 mmput(mm);
80360 mm = ERR_PTR(-EACCES);
80361 }
80362 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80363 spin_unlock(&fs->lock);
80364 return -EAGAIN;
80365 }
80366 - fs->users++;
80367 + atomic_inc(&fs->users);
80368 spin_unlock(&fs->lock);
80369 return 0;
80370 }
80371 tsk->fs = copy_fs_struct(fs);
80372 if (!tsk->fs)
80373 return -ENOMEM;
80374 + /* Carry through gr_chroot_dentry and is_chrooted instead
80375 + of recomputing it here. Already copied when the task struct
80376 + is duplicated. This allows pivot_root to not be treated as
80377 + a chroot
80378 + */
80379 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80380 +
80381 return 0;
80382 }
80383
80384 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80385 * parts of the process environment (as per the clone
80386 * flags). The actual kick-off is left to the caller.
80387 */
80388 -static struct task_struct *copy_process(unsigned long clone_flags,
80389 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80390 unsigned long stack_start,
80391 unsigned long stack_size,
80392 int __user *child_tidptr,
80393 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80394 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80395 #endif
80396 retval = -EAGAIN;
80397 +
80398 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80399 +
80400 if (atomic_read(&p->real_cred->user->processes) >=
80401 task_rlimit(p, RLIMIT_NPROC)) {
80402 if (p->real_cred->user != INIT_USER &&
80403 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80404 goto bad_fork_free_pid;
80405 }
80406
80407 + /* synchronizes with gr_set_acls()
80408 + we need to call this past the point of no return for fork()
80409 + */
80410 + gr_copy_label(p);
80411 +
80412 if (likely(p->pid)) {
80413 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80414
80415 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80416 bad_fork_free:
80417 free_task(p);
80418 fork_out:
80419 + gr_log_forkfail(retval);
80420 +
80421 return ERR_PTR(retval);
80422 }
80423
80424 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
80425
80426 p = copy_process(clone_flags, stack_start, stack_size,
80427 child_tidptr, NULL, trace);
80428 + add_latent_entropy();
80429 /*
80430 * Do this prior waking up the new thread - the thread pointer
80431 * might get invalid after that point, if the thread exits quickly.
80432 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
80433 if (clone_flags & CLONE_PARENT_SETTID)
80434 put_user(nr, parent_tidptr);
80435
80436 + gr_handle_brute_check();
80437 +
80438 if (clone_flags & CLONE_VFORK) {
80439 p->vfork_done = &vfork;
80440 init_completion(&vfork);
80441 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
80442 mm_cachep = kmem_cache_create("mm_struct",
80443 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80444 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80445 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80446 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80447 mmap_init();
80448 nsproxy_cache_init();
80449 }
80450 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80451 return 0;
80452
80453 /* don't need lock here; in the worst case we'll do useless copy */
80454 - if (fs->users == 1)
80455 + if (atomic_read(&fs->users) == 1)
80456 return 0;
80457
80458 *new_fsp = copy_fs_struct(fs);
80459 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80460 fs = current->fs;
80461 spin_lock(&fs->lock);
80462 current->fs = new_fs;
80463 - if (--fs->users)
80464 + gr_set_chroot_entries(current, &current->fs->root);
80465 + if (atomic_dec_return(&fs->users))
80466 new_fs = NULL;
80467 else
80468 new_fs = fs;
80469 diff --git a/kernel/futex.c b/kernel/futex.c
80470 index c3a1a55..e32b4a98 100644
80471 --- a/kernel/futex.c
80472 +++ b/kernel/futex.c
80473 @@ -54,6 +54,7 @@
80474 #include <linux/mount.h>
80475 #include <linux/pagemap.h>
80476 #include <linux/syscalls.h>
80477 +#include <linux/ptrace.h>
80478 #include <linux/signal.h>
80479 #include <linux/export.h>
80480 #include <linux/magic.h>
80481 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80482 struct page *page, *page_head;
80483 int err, ro = 0;
80484
80485 +#ifdef CONFIG_PAX_SEGMEXEC
80486 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80487 + return -EFAULT;
80488 +#endif
80489 +
80490 /*
80491 * The futex address must be "naturally" aligned.
80492 */
80493 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80494
80495 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80496 {
80497 - int ret;
80498 + unsigned long ret;
80499
80500 pagefault_disable();
80501 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80502 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80503 {
80504 u32 curval;
80505 int i;
80506 + mm_segment_t oldfs;
80507
80508 /*
80509 * This will fail and we want it. Some arch implementations do
80510 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80511 * implementation, the non-functional ones will return
80512 * -ENOSYS.
80513 */
80514 + oldfs = get_fs();
80515 + set_fs(USER_DS);
80516 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80517 futex_cmpxchg_enabled = 1;
80518 + set_fs(oldfs);
80519
80520 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80521 plist_head_init(&futex_queues[i].chain);
80522 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80523 index f9f44fd..29885e4 100644
80524 --- a/kernel/futex_compat.c
80525 +++ b/kernel/futex_compat.c
80526 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80527 return 0;
80528 }
80529
80530 -static void __user *futex_uaddr(struct robust_list __user *entry,
80531 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80532 compat_long_t futex_offset)
80533 {
80534 compat_uptr_t base = ptr_to_compat(entry);
80535 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80536 index 9b22d03..6295b62 100644
80537 --- a/kernel/gcov/base.c
80538 +++ b/kernel/gcov/base.c
80539 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80540 }
80541
80542 #ifdef CONFIG_MODULES
80543 -static inline int within(void *addr, void *start, unsigned long size)
80544 -{
80545 - return ((addr >= start) && (addr < start + size));
80546 -}
80547 -
80548 /* Update list and generate events when modules are unloaded. */
80549 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80550 void *data)
80551 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80552 prev = NULL;
80553 /* Remove entries located in module from linked list. */
80554 for (info = gcov_info_head; info; info = info->next) {
80555 - if (within(info, mod->module_core, mod->core_size)) {
80556 + if (within_module_core_rw((unsigned long)info, mod)) {
80557 if (prev)
80558 prev->next = info->next;
80559 else
80560 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80561 index 383319b..56ebb13 100644
80562 --- a/kernel/hrtimer.c
80563 +++ b/kernel/hrtimer.c
80564 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80565 local_irq_restore(flags);
80566 }
80567
80568 -static void run_hrtimer_softirq(struct softirq_action *h)
80569 +static __latent_entropy void run_hrtimer_softirq(void)
80570 {
80571 hrtimer_peek_ahead_timers();
80572 }
80573 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80574 index 55fcce6..0e4cf34 100644
80575 --- a/kernel/irq_work.c
80576 +++ b/kernel/irq_work.c
80577 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80578 return NOTIFY_OK;
80579 }
80580
80581 -static struct notifier_block cpu_notify;
80582 +static struct notifier_block cpu_notify = {
80583 + .notifier_call = irq_work_cpu_notify,
80584 + .priority = 0,
80585 +};
80586
80587 static __init int irq_work_init_cpu_notifier(void)
80588 {
80589 - cpu_notify.notifier_call = irq_work_cpu_notify;
80590 - cpu_notify.priority = 0;
80591 register_cpu_notifier(&cpu_notify);
80592 return 0;
80593 }
80594 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80595 index 60f48fa..7f3a770 100644
80596 --- a/kernel/jump_label.c
80597 +++ b/kernel/jump_label.c
80598 @@ -13,6 +13,7 @@
80599 #include <linux/sort.h>
80600 #include <linux/err.h>
80601 #include <linux/static_key.h>
80602 +#include <linux/mm.h>
80603
80604 #ifdef HAVE_JUMP_LABEL
80605
80606 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80607
80608 size = (((unsigned long)stop - (unsigned long)start)
80609 / sizeof(struct jump_entry));
80610 + pax_open_kernel();
80611 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80612 + pax_close_kernel();
80613 }
80614
80615 static void jump_label_update(struct static_key *key, int enable);
80616 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80617 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80618 struct jump_entry *iter;
80619
80620 + pax_open_kernel();
80621 for (iter = iter_start; iter < iter_stop; iter++) {
80622 if (within_module_init(iter->code, mod))
80623 iter->code = 0;
80624 }
80625 + pax_close_kernel();
80626 }
80627
80628 static int
80629 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80630 index 3127ad5..159d880 100644
80631 --- a/kernel/kallsyms.c
80632 +++ b/kernel/kallsyms.c
80633 @@ -11,6 +11,9 @@
80634 * Changed the compression method from stem compression to "table lookup"
80635 * compression (see scripts/kallsyms.c for a more complete description)
80636 */
80637 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80638 +#define __INCLUDED_BY_HIDESYM 1
80639 +#endif
80640 #include <linux/kallsyms.h>
80641 #include <linux/module.h>
80642 #include <linux/init.h>
80643 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80644
80645 static inline int is_kernel_inittext(unsigned long addr)
80646 {
80647 + if (system_state != SYSTEM_BOOTING)
80648 + return 0;
80649 +
80650 if (addr >= (unsigned long)_sinittext
80651 && addr <= (unsigned long)_einittext)
80652 return 1;
80653 return 0;
80654 }
80655
80656 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80657 +#ifdef CONFIG_MODULES
80658 +static inline int is_module_text(unsigned long addr)
80659 +{
80660 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
80661 + return 1;
80662 +
80663 + addr = ktla_ktva(addr);
80664 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
80665 +}
80666 +#else
80667 +static inline int is_module_text(unsigned long addr)
80668 +{
80669 + return 0;
80670 +}
80671 +#endif
80672 +#endif
80673 +
80674 static inline int is_kernel_text(unsigned long addr)
80675 {
80676 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
80677 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
80678
80679 static inline int is_kernel(unsigned long addr)
80680 {
80681 +
80682 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80683 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
80684 + return 1;
80685 +
80686 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
80687 +#else
80688 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
80689 +#endif
80690 +
80691 return 1;
80692 return in_gate_area_no_mm(addr);
80693 }
80694
80695 static int is_ksym_addr(unsigned long addr)
80696 {
80697 +
80698 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80699 + if (is_module_text(addr))
80700 + return 0;
80701 +#endif
80702 +
80703 if (all_var)
80704 return is_kernel(addr);
80705
80706 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
80707
80708 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
80709 {
80710 - iter->name[0] = '\0';
80711 iter->nameoff = get_symbol_offset(new_pos);
80712 iter->pos = new_pos;
80713 }
80714 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
80715 {
80716 struct kallsym_iter *iter = m->private;
80717
80718 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80719 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
80720 + return 0;
80721 +#endif
80722 +
80723 /* Some debugging symbols have no name. Ignore them. */
80724 if (!iter->name[0])
80725 return 0;
80726 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
80727 */
80728 type = iter->exported ? toupper(iter->type) :
80729 tolower(iter->type);
80730 +
80731 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
80732 type, iter->name, iter->module_name);
80733 } else
80734 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
80735 struct kallsym_iter *iter;
80736 int ret;
80737
80738 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
80739 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
80740 if (!iter)
80741 return -ENOMEM;
80742 reset_iter(iter, 0);
80743 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
80744 index e30ac0f..3528cac 100644
80745 --- a/kernel/kcmp.c
80746 +++ b/kernel/kcmp.c
80747 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
80748 struct task_struct *task1, *task2;
80749 int ret;
80750
80751 +#ifdef CONFIG_GRKERNSEC
80752 + return -ENOSYS;
80753 +#endif
80754 +
80755 rcu_read_lock();
80756
80757 /*
80758 diff --git a/kernel/kexec.c b/kernel/kexec.c
80759 index 59f7b55..4022f65 100644
80760 --- a/kernel/kexec.c
80761 +++ b/kernel/kexec.c
80762 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
80763 unsigned long flags)
80764 {
80765 struct compat_kexec_segment in;
80766 - struct kexec_segment out, __user *ksegments;
80767 + struct kexec_segment out;
80768 + struct kexec_segment __user *ksegments;
80769 unsigned long i, result;
80770
80771 /* Don't allow clients that don't understand the native
80772 diff --git a/kernel/kmod.c b/kernel/kmod.c
80773 index b086006..a27913b 100644
80774 --- a/kernel/kmod.c
80775 +++ b/kernel/kmod.c
80776 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
80777 kfree(info->argv);
80778 }
80779
80780 -static int call_modprobe(char *module_name, int wait)
80781 +static int call_modprobe(char *module_name, char *module_param, int wait)
80782 {
80783 struct subprocess_info *info;
80784 static char *envp[] = {
80785 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
80786 NULL
80787 };
80788
80789 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
80790 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
80791 if (!argv)
80792 goto out;
80793
80794 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
80795 argv[1] = "-q";
80796 argv[2] = "--";
80797 argv[3] = module_name; /* check free_modprobe_argv() */
80798 - argv[4] = NULL;
80799 + argv[4] = module_param;
80800 + argv[5] = NULL;
80801
80802 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
80803 NULL, free_modprobe_argv, NULL);
80804 @@ -129,9 +130,8 @@ out:
80805 * If module auto-loading support is disabled then this function
80806 * becomes a no-operation.
80807 */
80808 -int __request_module(bool wait, const char *fmt, ...)
80809 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
80810 {
80811 - va_list args;
80812 char module_name[MODULE_NAME_LEN];
80813 unsigned int max_modprobes;
80814 int ret;
80815 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
80816 if (!modprobe_path[0])
80817 return 0;
80818
80819 - va_start(args, fmt);
80820 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
80821 - va_end(args);
80822 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
80823 if (ret >= MODULE_NAME_LEN)
80824 return -ENAMETOOLONG;
80825
80826 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
80827 if (ret)
80828 return ret;
80829
80830 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
80831 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
80832 + /* hack to workaround consolekit/udisks stupidity */
80833 + read_lock(&tasklist_lock);
80834 + if (!strcmp(current->comm, "mount") &&
80835 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
80836 + read_unlock(&tasklist_lock);
80837 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
80838 + return -EPERM;
80839 + }
80840 + read_unlock(&tasklist_lock);
80841 + }
80842 +#endif
80843 +
80844 /* If modprobe needs a service that is in a module, we get a recursive
80845 * loop. Limit the number of running kmod threads to max_threads/2 or
80846 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
80847 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
80848
80849 trace_module_request(module_name, wait, _RET_IP_);
80850
80851 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
80852 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
80853
80854 atomic_dec(&kmod_concurrent);
80855 return ret;
80856 }
80857 +
80858 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
80859 +{
80860 + va_list args;
80861 + int ret;
80862 +
80863 + va_start(args, fmt);
80864 + ret = ____request_module(wait, module_param, fmt, args);
80865 + va_end(args);
80866 +
80867 + return ret;
80868 +}
80869 +
80870 +int __request_module(bool wait, const char *fmt, ...)
80871 +{
80872 + va_list args;
80873 + int ret;
80874 +
80875 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
80876 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
80877 + char module_param[MODULE_NAME_LEN];
80878 +
80879 + memset(module_param, 0, sizeof(module_param));
80880 +
80881 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
80882 +
80883 + va_start(args, fmt);
80884 + ret = ____request_module(wait, module_param, fmt, args);
80885 + va_end(args);
80886 +
80887 + return ret;
80888 + }
80889 +#endif
80890 +
80891 + va_start(args, fmt);
80892 + ret = ____request_module(wait, NULL, fmt, args);
80893 + va_end(args);
80894 +
80895 + return ret;
80896 +}
80897 +
80898 EXPORT_SYMBOL(__request_module);
80899 #endif /* CONFIG_MODULES */
80900
80901 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
80902 *
80903 * Thus the __user pointer cast is valid here.
80904 */
80905 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
80906 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
80907
80908 /*
80909 * If ret is 0, either ____call_usermodehelper failed and the
80910 @@ -650,7 +703,7 @@ EXPORT_SYMBOL(call_usermodehelper);
80911 static int proc_cap_handler(struct ctl_table *table, int write,
80912 void __user *buffer, size_t *lenp, loff_t *ppos)
80913 {
80914 - struct ctl_table t;
80915 + ctl_table_no_const t;
80916 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
80917 kernel_cap_t new_cap;
80918 int err, i;
80919 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
80920 index 6e33498..3133bd3 100644
80921 --- a/kernel/kprobes.c
80922 +++ b/kernel/kprobes.c
80923 @@ -31,6 +31,9 @@
80924 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
80925 * <prasanna@in.ibm.com> added function-return probes.
80926 */
80927 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80928 +#define __INCLUDED_BY_HIDESYM 1
80929 +#endif
80930 #include <linux/kprobes.h>
80931 #include <linux/hash.h>
80932 #include <linux/init.h>
80933 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
80934 * kernel image and loaded module images reside. This is required
80935 * so x86_64 can correctly handle the %rip-relative fixups.
80936 */
80937 - kip->insns = module_alloc(PAGE_SIZE);
80938 + kip->insns = module_alloc_exec(PAGE_SIZE);
80939 if (!kip->insns) {
80940 kfree(kip);
80941 return NULL;
80942 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
80943 */
80944 if (!list_is_singular(&kip->list)) {
80945 list_del(&kip->list);
80946 - module_free(NULL, kip->insns);
80947 + module_free_exec(NULL, kip->insns);
80948 kfree(kip);
80949 }
80950 return 1;
80951 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
80952 {
80953 int i, err = 0;
80954 unsigned long offset = 0, size = 0;
80955 - char *modname, namebuf[128];
80956 + char *modname, namebuf[KSYM_NAME_LEN];
80957 const char *symbol_name;
80958 void *addr;
80959 struct kprobe_blackpoint *kb;
80960 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
80961 kprobe_type = "k";
80962
80963 if (sym)
80964 - seq_printf(pi, "%p %s %s+0x%x %s ",
80965 + seq_printf(pi, "%pK %s %s+0x%x %s ",
80966 p->addr, kprobe_type, sym, offset,
80967 (modname ? modname : " "));
80968 else
80969 - seq_printf(pi, "%p %s %p ",
80970 + seq_printf(pi, "%pK %s %pK ",
80971 p->addr, kprobe_type, p->addr);
80972
80973 if (!pp)
80974 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
80975 const char *sym = NULL;
80976 unsigned int i = *(loff_t *) v;
80977 unsigned long offset = 0;
80978 - char *modname, namebuf[128];
80979 + char *modname, namebuf[KSYM_NAME_LEN];
80980
80981 head = &kprobe_table[i];
80982 preempt_disable();
80983 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
80984 index 6ada93c..dce7d5d 100644
80985 --- a/kernel/ksysfs.c
80986 +++ b/kernel/ksysfs.c
80987 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
80988 {
80989 if (count+1 > UEVENT_HELPER_PATH_LEN)
80990 return -ENOENT;
80991 + if (!capable(CAP_SYS_ADMIN))
80992 + return -EPERM;
80993 memcpy(uevent_helper, buf, count);
80994 uevent_helper[count] = '\0';
80995 if (count && uevent_helper[count-1] == '\n')
80996 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
80997 return count;
80998 }
80999
81000 -static struct bin_attribute notes_attr = {
81001 +static bin_attribute_no_const notes_attr __read_only = {
81002 .attr = {
81003 .name = "notes",
81004 .mode = S_IRUGO,
81005 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81006 index e16c45b..6f49c48 100644
81007 --- a/kernel/lockdep.c
81008 +++ b/kernel/lockdep.c
81009 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81010 end = (unsigned long) &_end,
81011 addr = (unsigned long) obj;
81012
81013 +#ifdef CONFIG_PAX_KERNEXEC
81014 + start = ktla_ktva(start);
81015 +#endif
81016 +
81017 /*
81018 * static variable?
81019 */
81020 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81021 if (!static_obj(lock->key)) {
81022 debug_locks_off();
81023 printk("INFO: trying to register non-static key.\n");
81024 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81025 printk("the code is fine but needs lockdep annotation.\n");
81026 printk("turning off the locking correctness validator.\n");
81027 dump_stack();
81028 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81029 if (!class)
81030 return 0;
81031 }
81032 - atomic_inc((atomic_t *)&class->ops);
81033 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81034 if (very_verbose(class)) {
81035 printk("\nacquire class [%p] %s", class->key, class->name);
81036 if (class->name_version > 1)
81037 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81038 index b2c71c5..7b88d63 100644
81039 --- a/kernel/lockdep_proc.c
81040 +++ b/kernel/lockdep_proc.c
81041 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81042 return 0;
81043 }
81044
81045 - seq_printf(m, "%p", class->key);
81046 + seq_printf(m, "%pK", class->key);
81047 #ifdef CONFIG_DEBUG_LOCKDEP
81048 seq_printf(m, " OPS:%8ld", class->ops);
81049 #endif
81050 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81051
81052 list_for_each_entry(entry, &class->locks_after, entry) {
81053 if (entry->distance == 1) {
81054 - seq_printf(m, " -> [%p] ", entry->class->key);
81055 + seq_printf(m, " -> [%pK] ", entry->class->key);
81056 print_name(m, entry->class);
81057 seq_puts(m, "\n");
81058 }
81059 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81060 if (!class->key)
81061 continue;
81062
81063 - seq_printf(m, "[%p] ", class->key);
81064 + seq_printf(m, "[%pK] ", class->key);
81065 print_name(m, class);
81066 seq_puts(m, "\n");
81067 }
81068 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81069 if (!i)
81070 seq_line(m, '-', 40-namelen, namelen);
81071
81072 - snprintf(ip, sizeof(ip), "[<%p>]",
81073 + snprintf(ip, sizeof(ip), "[<%pK>]",
81074 (void *)class->contention_point[i]);
81075 seq_printf(m, "%40s %14lu %29s %pS\n",
81076 name, stats->contention_point[i],
81077 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81078 if (!i)
81079 seq_line(m, '-', 40-namelen, namelen);
81080
81081 - snprintf(ip, sizeof(ip), "[<%p>]",
81082 + snprintf(ip, sizeof(ip), "[<%pK>]",
81083 (void *)class->contending_point[i]);
81084 seq_printf(m, "%40s %14lu %29s %pS\n",
81085 name, stats->contending_point[i],
81086 diff --git a/kernel/module.c b/kernel/module.c
81087 index 2069158..71101bb 100644
81088 --- a/kernel/module.c
81089 +++ b/kernel/module.c
81090 @@ -61,6 +61,7 @@
81091 #include <linux/pfn.h>
81092 #include <linux/bsearch.h>
81093 #include <linux/fips.h>
81094 +#include <linux/grsecurity.h>
81095 #include <uapi/linux/module.h>
81096 #include "module-internal.h"
81097
81098 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81099
81100 /* Bounds of module allocation, for speeding __module_address.
81101 * Protected by module_mutex. */
81102 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81103 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81104 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81105
81106 int register_module_notifier(struct notifier_block * nb)
81107 {
81108 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81109 return true;
81110
81111 list_for_each_entry_rcu(mod, &modules, list) {
81112 - struct symsearch arr[] = {
81113 + struct symsearch modarr[] = {
81114 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81115 NOT_GPL_ONLY, false },
81116 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81117 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81118 if (mod->state == MODULE_STATE_UNFORMED)
81119 continue;
81120
81121 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81122 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81123 return true;
81124 }
81125 return false;
81126 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81127 if (!pcpusec->sh_size)
81128 return 0;
81129
81130 - if (align > PAGE_SIZE) {
81131 + if (align-1 >= PAGE_SIZE) {
81132 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81133 mod->name, align, PAGE_SIZE);
81134 align = PAGE_SIZE;
81135 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81136 static ssize_t show_coresize(struct module_attribute *mattr,
81137 struct module_kobject *mk, char *buffer)
81138 {
81139 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81140 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81141 }
81142
81143 static struct module_attribute modinfo_coresize =
81144 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81145 static ssize_t show_initsize(struct module_attribute *mattr,
81146 struct module_kobject *mk, char *buffer)
81147 {
81148 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81149 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81150 }
81151
81152 static struct module_attribute modinfo_initsize =
81153 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81154 */
81155 #ifdef CONFIG_SYSFS
81156
81157 -#ifdef CONFIG_KALLSYMS
81158 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81159 static inline bool sect_empty(const Elf_Shdr *sect)
81160 {
81161 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81162 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81163 {
81164 unsigned int notes, loaded, i;
81165 struct module_notes_attrs *notes_attrs;
81166 - struct bin_attribute *nattr;
81167 + bin_attribute_no_const *nattr;
81168
81169 /* failed to create section attributes, so can't create notes */
81170 if (!mod->sect_attrs)
81171 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81172 static int module_add_modinfo_attrs(struct module *mod)
81173 {
81174 struct module_attribute *attr;
81175 - struct module_attribute *temp_attr;
81176 + module_attribute_no_const *temp_attr;
81177 int error = 0;
81178 int i;
81179
81180 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81181
81182 static void unset_module_core_ro_nx(struct module *mod)
81183 {
81184 - set_page_attributes(mod->module_core + mod->core_text_size,
81185 - mod->module_core + mod->core_size,
81186 + set_page_attributes(mod->module_core_rw,
81187 + mod->module_core_rw + mod->core_size_rw,
81188 set_memory_x);
81189 - set_page_attributes(mod->module_core,
81190 - mod->module_core + mod->core_ro_size,
81191 + set_page_attributes(mod->module_core_rx,
81192 + mod->module_core_rx + mod->core_size_rx,
81193 set_memory_rw);
81194 }
81195
81196 static void unset_module_init_ro_nx(struct module *mod)
81197 {
81198 - set_page_attributes(mod->module_init + mod->init_text_size,
81199 - mod->module_init + mod->init_size,
81200 + set_page_attributes(mod->module_init_rw,
81201 + mod->module_init_rw + mod->init_size_rw,
81202 set_memory_x);
81203 - set_page_attributes(mod->module_init,
81204 - mod->module_init + mod->init_ro_size,
81205 + set_page_attributes(mod->module_init_rx,
81206 + mod->module_init_rx + mod->init_size_rx,
81207 set_memory_rw);
81208 }
81209
81210 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81211 list_for_each_entry_rcu(mod, &modules, list) {
81212 if (mod->state == MODULE_STATE_UNFORMED)
81213 continue;
81214 - if ((mod->module_core) && (mod->core_text_size)) {
81215 - set_page_attributes(mod->module_core,
81216 - mod->module_core + mod->core_text_size,
81217 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81218 + set_page_attributes(mod->module_core_rx,
81219 + mod->module_core_rx + mod->core_size_rx,
81220 set_memory_rw);
81221 }
81222 - if ((mod->module_init) && (mod->init_text_size)) {
81223 - set_page_attributes(mod->module_init,
81224 - mod->module_init + mod->init_text_size,
81225 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81226 + set_page_attributes(mod->module_init_rx,
81227 + mod->module_init_rx + mod->init_size_rx,
81228 set_memory_rw);
81229 }
81230 }
81231 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81232 list_for_each_entry_rcu(mod, &modules, list) {
81233 if (mod->state == MODULE_STATE_UNFORMED)
81234 continue;
81235 - if ((mod->module_core) && (mod->core_text_size)) {
81236 - set_page_attributes(mod->module_core,
81237 - mod->module_core + mod->core_text_size,
81238 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81239 + set_page_attributes(mod->module_core_rx,
81240 + mod->module_core_rx + mod->core_size_rx,
81241 set_memory_ro);
81242 }
81243 - if ((mod->module_init) && (mod->init_text_size)) {
81244 - set_page_attributes(mod->module_init,
81245 - mod->module_init + mod->init_text_size,
81246 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81247 + set_page_attributes(mod->module_init_rx,
81248 + mod->module_init_rx + mod->init_size_rx,
81249 set_memory_ro);
81250 }
81251 }
81252 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81253
81254 /* This may be NULL, but that's OK */
81255 unset_module_init_ro_nx(mod);
81256 - module_free(mod, mod->module_init);
81257 + module_free(mod, mod->module_init_rw);
81258 + module_free_exec(mod, mod->module_init_rx);
81259 kfree(mod->args);
81260 percpu_modfree(mod);
81261
81262 /* Free lock-classes: */
81263 - lockdep_free_key_range(mod->module_core, mod->core_size);
81264 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81265 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81266
81267 /* Finally, free the core (containing the module structure) */
81268 unset_module_core_ro_nx(mod);
81269 - module_free(mod, mod->module_core);
81270 + module_free_exec(mod, mod->module_core_rx);
81271 + module_free(mod, mod->module_core_rw);
81272
81273 #ifdef CONFIG_MPU
81274 update_protections(current->mm);
81275 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81276 int ret = 0;
81277 const struct kernel_symbol *ksym;
81278
81279 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81280 + int is_fs_load = 0;
81281 + int register_filesystem_found = 0;
81282 + char *p;
81283 +
81284 + p = strstr(mod->args, "grsec_modharden_fs");
81285 + if (p) {
81286 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81287 + /* copy \0 as well */
81288 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81289 + is_fs_load = 1;
81290 + }
81291 +#endif
81292 +
81293 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81294 const char *name = info->strtab + sym[i].st_name;
81295
81296 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81297 + /* it's a real shame this will never get ripped and copied
81298 + upstream! ;(
81299 + */
81300 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81301 + register_filesystem_found = 1;
81302 +#endif
81303 +
81304 switch (sym[i].st_shndx) {
81305 case SHN_COMMON:
81306 /* We compiled with -fno-common. These are not
81307 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81308 ksym = resolve_symbol_wait(mod, info, name);
81309 /* Ok if resolved. */
81310 if (ksym && !IS_ERR(ksym)) {
81311 + pax_open_kernel();
81312 sym[i].st_value = ksym->value;
81313 + pax_close_kernel();
81314 break;
81315 }
81316
81317 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81318 secbase = (unsigned long)mod_percpu(mod);
81319 else
81320 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81321 + pax_open_kernel();
81322 sym[i].st_value += secbase;
81323 + pax_close_kernel();
81324 break;
81325 }
81326 }
81327
81328 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81329 + if (is_fs_load && !register_filesystem_found) {
81330 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81331 + ret = -EPERM;
81332 + }
81333 +#endif
81334 +
81335 return ret;
81336 }
81337
81338 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81339 || s->sh_entsize != ~0UL
81340 || strstarts(sname, ".init"))
81341 continue;
81342 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81343 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81344 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81345 + else
81346 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81347 pr_debug("\t%s\n", sname);
81348 }
81349 - switch (m) {
81350 - case 0: /* executable */
81351 - mod->core_size = debug_align(mod->core_size);
81352 - mod->core_text_size = mod->core_size;
81353 - break;
81354 - case 1: /* RO: text and ro-data */
81355 - mod->core_size = debug_align(mod->core_size);
81356 - mod->core_ro_size = mod->core_size;
81357 - break;
81358 - case 3: /* whole core */
81359 - mod->core_size = debug_align(mod->core_size);
81360 - break;
81361 - }
81362 }
81363
81364 pr_debug("Init section allocation order:\n");
81365 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81366 || s->sh_entsize != ~0UL
81367 || !strstarts(sname, ".init"))
81368 continue;
81369 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81370 - | INIT_OFFSET_MASK);
81371 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81372 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81373 + else
81374 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81375 + s->sh_entsize |= INIT_OFFSET_MASK;
81376 pr_debug("\t%s\n", sname);
81377 }
81378 - switch (m) {
81379 - case 0: /* executable */
81380 - mod->init_size = debug_align(mod->init_size);
81381 - mod->init_text_size = mod->init_size;
81382 - break;
81383 - case 1: /* RO: text and ro-data */
81384 - mod->init_size = debug_align(mod->init_size);
81385 - mod->init_ro_size = mod->init_size;
81386 - break;
81387 - case 3: /* whole init */
81388 - mod->init_size = debug_align(mod->init_size);
81389 - break;
81390 - }
81391 }
81392 }
81393
81394 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81395
81396 /* Put symbol section at end of init part of module. */
81397 symsect->sh_flags |= SHF_ALLOC;
81398 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81399 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81400 info->index.sym) | INIT_OFFSET_MASK;
81401 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81402
81403 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81404 }
81405
81406 /* Append room for core symbols at end of core part. */
81407 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81408 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81409 - mod->core_size += strtab_size;
81410 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81411 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81412 + mod->core_size_rx += strtab_size;
81413
81414 /* Put string table section at end of init part of module. */
81415 strsect->sh_flags |= SHF_ALLOC;
81416 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81417 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81418 info->index.str) | INIT_OFFSET_MASK;
81419 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81420 }
81421 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81422 /* Make sure we get permanent strtab: don't use info->strtab. */
81423 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81424
81425 + pax_open_kernel();
81426 +
81427 /* Set types up while we still have access to sections. */
81428 for (i = 0; i < mod->num_symtab; i++)
81429 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81430
81431 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81432 - mod->core_strtab = s = mod->module_core + info->stroffs;
81433 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81434 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81435 src = mod->symtab;
81436 for (ndst = i = 0; i < mod->num_symtab; i++) {
81437 if (i == 0 ||
81438 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81439 }
81440 }
81441 mod->core_num_syms = ndst;
81442 +
81443 + pax_close_kernel();
81444 }
81445 #else
81446 static inline void layout_symtab(struct module *mod, struct load_info *info)
81447 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81448 return vmalloc_exec(size);
81449 }
81450
81451 -static void *module_alloc_update_bounds(unsigned long size)
81452 +static void *module_alloc_update_bounds_rw(unsigned long size)
81453 {
81454 void *ret = module_alloc(size);
81455
81456 if (ret) {
81457 mutex_lock(&module_mutex);
81458 /* Update module bounds. */
81459 - if ((unsigned long)ret < module_addr_min)
81460 - module_addr_min = (unsigned long)ret;
81461 - if ((unsigned long)ret + size > module_addr_max)
81462 - module_addr_max = (unsigned long)ret + size;
81463 + if ((unsigned long)ret < module_addr_min_rw)
81464 + module_addr_min_rw = (unsigned long)ret;
81465 + if ((unsigned long)ret + size > module_addr_max_rw)
81466 + module_addr_max_rw = (unsigned long)ret + size;
81467 + mutex_unlock(&module_mutex);
81468 + }
81469 + return ret;
81470 +}
81471 +
81472 +static void *module_alloc_update_bounds_rx(unsigned long size)
81473 +{
81474 + void *ret = module_alloc_exec(size);
81475 +
81476 + if (ret) {
81477 + mutex_lock(&module_mutex);
81478 + /* Update module bounds. */
81479 + if ((unsigned long)ret < module_addr_min_rx)
81480 + module_addr_min_rx = (unsigned long)ret;
81481 + if ((unsigned long)ret + size > module_addr_max_rx)
81482 + module_addr_max_rx = (unsigned long)ret + size;
81483 mutex_unlock(&module_mutex);
81484 }
81485 return ret;
81486 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81487 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81488 {
81489 const char *modmagic = get_modinfo(info, "vermagic");
81490 + const char *license = get_modinfo(info, "license");
81491 int err;
81492
81493 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81494 + if (!license || !license_is_gpl_compatible(license))
81495 + return -ENOEXEC;
81496 +#endif
81497 +
81498 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81499 modmagic = NULL;
81500
81501 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81502 }
81503
81504 /* Set up license info based on the info section */
81505 - set_license(mod, get_modinfo(info, "license"));
81506 + set_license(mod, license);
81507
81508 return 0;
81509 }
81510 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81511 void *ptr;
81512
81513 /* Do the allocs. */
81514 - ptr = module_alloc_update_bounds(mod->core_size);
81515 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81516 /*
81517 * The pointer to this block is stored in the module structure
81518 * which is inside the block. Just mark it as not being a
81519 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81520 if (!ptr)
81521 return -ENOMEM;
81522
81523 - memset(ptr, 0, mod->core_size);
81524 - mod->module_core = ptr;
81525 + memset(ptr, 0, mod->core_size_rw);
81526 + mod->module_core_rw = ptr;
81527
81528 - if (mod->init_size) {
81529 - ptr = module_alloc_update_bounds(mod->init_size);
81530 + if (mod->init_size_rw) {
81531 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81532 /*
81533 * The pointer to this block is stored in the module structure
81534 * which is inside the block. This block doesn't need to be
81535 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81536 */
81537 kmemleak_ignore(ptr);
81538 if (!ptr) {
81539 - module_free(mod, mod->module_core);
81540 + module_free(mod, mod->module_core_rw);
81541 return -ENOMEM;
81542 }
81543 - memset(ptr, 0, mod->init_size);
81544 - mod->module_init = ptr;
81545 + memset(ptr, 0, mod->init_size_rw);
81546 + mod->module_init_rw = ptr;
81547 } else
81548 - mod->module_init = NULL;
81549 + mod->module_init_rw = NULL;
81550 +
81551 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81552 + kmemleak_not_leak(ptr);
81553 + if (!ptr) {
81554 + if (mod->module_init_rw)
81555 + module_free(mod, mod->module_init_rw);
81556 + module_free(mod, mod->module_core_rw);
81557 + return -ENOMEM;
81558 + }
81559 +
81560 + pax_open_kernel();
81561 + memset(ptr, 0, mod->core_size_rx);
81562 + pax_close_kernel();
81563 + mod->module_core_rx = ptr;
81564 +
81565 + if (mod->init_size_rx) {
81566 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81567 + kmemleak_ignore(ptr);
81568 + if (!ptr && mod->init_size_rx) {
81569 + module_free_exec(mod, mod->module_core_rx);
81570 + if (mod->module_init_rw)
81571 + module_free(mod, mod->module_init_rw);
81572 + module_free(mod, mod->module_core_rw);
81573 + return -ENOMEM;
81574 + }
81575 +
81576 + pax_open_kernel();
81577 + memset(ptr, 0, mod->init_size_rx);
81578 + pax_close_kernel();
81579 + mod->module_init_rx = ptr;
81580 + } else
81581 + mod->module_init_rx = NULL;
81582
81583 /* Transfer each section which specifies SHF_ALLOC */
81584 pr_debug("final section addresses:\n");
81585 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81586 if (!(shdr->sh_flags & SHF_ALLOC))
81587 continue;
81588
81589 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81590 - dest = mod->module_init
81591 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81592 - else
81593 - dest = mod->module_core + shdr->sh_entsize;
81594 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81595 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81596 + dest = mod->module_init_rw
81597 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81598 + else
81599 + dest = mod->module_init_rx
81600 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81601 + } else {
81602 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81603 + dest = mod->module_core_rw + shdr->sh_entsize;
81604 + else
81605 + dest = mod->module_core_rx + shdr->sh_entsize;
81606 + }
81607 +
81608 + if (shdr->sh_type != SHT_NOBITS) {
81609 +
81610 +#ifdef CONFIG_PAX_KERNEXEC
81611 +#ifdef CONFIG_X86_64
81612 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81613 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81614 +#endif
81615 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81616 + pax_open_kernel();
81617 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81618 + pax_close_kernel();
81619 + } else
81620 +#endif
81621
81622 - if (shdr->sh_type != SHT_NOBITS)
81623 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81624 + }
81625 /* Update sh_addr to point to copy in image. */
81626 - shdr->sh_addr = (unsigned long)dest;
81627 +
81628 +#ifdef CONFIG_PAX_KERNEXEC
81629 + if (shdr->sh_flags & SHF_EXECINSTR)
81630 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81631 + else
81632 +#endif
81633 +
81634 + shdr->sh_addr = (unsigned long)dest;
81635 pr_debug("\t0x%lx %s\n",
81636 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81637 }
81638 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81639 * Do it before processing of module parameters, so the module
81640 * can provide parameter accessor functions of its own.
81641 */
81642 - if (mod->module_init)
81643 - flush_icache_range((unsigned long)mod->module_init,
81644 - (unsigned long)mod->module_init
81645 - + mod->init_size);
81646 - flush_icache_range((unsigned long)mod->module_core,
81647 - (unsigned long)mod->module_core + mod->core_size);
81648 + if (mod->module_init_rx)
81649 + flush_icache_range((unsigned long)mod->module_init_rx,
81650 + (unsigned long)mod->module_init_rx
81651 + + mod->init_size_rx);
81652 + flush_icache_range((unsigned long)mod->module_core_rx,
81653 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
81654
81655 set_fs(old_fs);
81656 }
81657 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
81658 static void module_deallocate(struct module *mod, struct load_info *info)
81659 {
81660 percpu_modfree(mod);
81661 - module_free(mod, mod->module_init);
81662 - module_free(mod, mod->module_core);
81663 + module_free_exec(mod, mod->module_init_rx);
81664 + module_free_exec(mod, mod->module_core_rx);
81665 + module_free(mod, mod->module_init_rw);
81666 + module_free(mod, mod->module_core_rw);
81667 }
81668
81669 int __weak module_finalize(const Elf_Ehdr *hdr,
81670 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
81671 static int post_relocation(struct module *mod, const struct load_info *info)
81672 {
81673 /* Sort exception table now relocations are done. */
81674 + pax_open_kernel();
81675 sort_extable(mod->extable, mod->extable + mod->num_exentries);
81676 + pax_close_kernel();
81677
81678 /* Copy relocated percpu area over. */
81679 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
81680 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
81681 MODULE_STATE_COMING, mod);
81682
81683 /* Set RO and NX regions for core */
81684 - set_section_ro_nx(mod->module_core,
81685 - mod->core_text_size,
81686 - mod->core_ro_size,
81687 - mod->core_size);
81688 + set_section_ro_nx(mod->module_core_rx,
81689 + mod->core_size_rx,
81690 + mod->core_size_rx,
81691 + mod->core_size_rx);
81692
81693 /* Set RO and NX regions for init */
81694 - set_section_ro_nx(mod->module_init,
81695 - mod->init_text_size,
81696 - mod->init_ro_size,
81697 - mod->init_size);
81698 + set_section_ro_nx(mod->module_init_rx,
81699 + mod->init_size_rx,
81700 + mod->init_size_rx,
81701 + mod->init_size_rx);
81702
81703 do_mod_ctors(mod);
81704 /* Start the module */
81705 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
81706 mod->strtab = mod->core_strtab;
81707 #endif
81708 unset_module_init_ro_nx(mod);
81709 - module_free(mod, mod->module_init);
81710 - mod->module_init = NULL;
81711 - mod->init_size = 0;
81712 - mod->init_ro_size = 0;
81713 - mod->init_text_size = 0;
81714 + module_free(mod, mod->module_init_rw);
81715 + module_free_exec(mod, mod->module_init_rx);
81716 + mod->module_init_rw = NULL;
81717 + mod->module_init_rx = NULL;
81718 + mod->init_size_rw = 0;
81719 + mod->init_size_rx = 0;
81720 mutex_unlock(&module_mutex);
81721 wake_up_all(&module_wq);
81722
81723 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
81724 if (err)
81725 goto free_unload;
81726
81727 + /* Now copy in args */
81728 + mod->args = strndup_user(uargs, ~0UL >> 1);
81729 + if (IS_ERR(mod->args)) {
81730 + err = PTR_ERR(mod->args);
81731 + goto free_unload;
81732 + }
81733 +
81734 /* Set up MODINFO_ATTR fields */
81735 setup_modinfo(mod, info);
81736
81737 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81738 + {
81739 + char *p, *p2;
81740 +
81741 + if (strstr(mod->args, "grsec_modharden_netdev")) {
81742 + 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);
81743 + err = -EPERM;
81744 + goto free_modinfo;
81745 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
81746 + p += sizeof("grsec_modharden_normal") - 1;
81747 + p2 = strstr(p, "_");
81748 + if (p2) {
81749 + *p2 = '\0';
81750 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
81751 + *p2 = '_';
81752 + }
81753 + err = -EPERM;
81754 + goto free_modinfo;
81755 + }
81756 + }
81757 +#endif
81758 +
81759 /* Fix up syms, so that st_value is a pointer to location. */
81760 err = simplify_symbols(mod, info);
81761 if (err < 0)
81762 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
81763
81764 flush_module_icache(mod);
81765
81766 - /* Now copy in args */
81767 - mod->args = strndup_user(uargs, ~0UL >> 1);
81768 - if (IS_ERR(mod->args)) {
81769 - err = PTR_ERR(mod->args);
81770 - goto free_arch_cleanup;
81771 - }
81772 -
81773 dynamic_debug_setup(info->debug, info->num_debug);
81774
81775 /* Finally it's fully formed, ready to start executing. */
81776 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
81777 ddebug_cleanup:
81778 dynamic_debug_remove(info->debug);
81779 synchronize_sched();
81780 - kfree(mod->args);
81781 - free_arch_cleanup:
81782 module_arch_cleanup(mod);
81783 free_modinfo:
81784 free_modinfo(mod);
81785 + kfree(mod->args);
81786 free_unload:
81787 module_unload_free(mod);
81788 unlink_mod:
81789 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
81790 unsigned long nextval;
81791
81792 /* At worse, next value is at end of module */
81793 - if (within_module_init(addr, mod))
81794 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
81795 + if (within_module_init_rx(addr, mod))
81796 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
81797 + else if (within_module_init_rw(addr, mod))
81798 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
81799 + else if (within_module_core_rx(addr, mod))
81800 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
81801 + else if (within_module_core_rw(addr, mod))
81802 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
81803 else
81804 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
81805 + return NULL;
81806
81807 /* Scan for closest preceding symbol, and next symbol. (ELF
81808 starts real symbols at 1). */
81809 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
81810 return 0;
81811
81812 seq_printf(m, "%s %u",
81813 - mod->name, mod->init_size + mod->core_size);
81814 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
81815 print_unload_info(m, mod);
81816
81817 /* Informative for users. */
81818 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
81819 mod->state == MODULE_STATE_COMING ? "Loading":
81820 "Live");
81821 /* Used by oprofile and other similar tools. */
81822 - seq_printf(m, " 0x%pK", mod->module_core);
81823 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
81824
81825 /* Taints info */
81826 if (mod->taints)
81827 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
81828
81829 static int __init proc_modules_init(void)
81830 {
81831 +#ifndef CONFIG_GRKERNSEC_HIDESYM
81832 +#ifdef CONFIG_GRKERNSEC_PROC_USER
81833 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
81834 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81835 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
81836 +#else
81837 proc_create("modules", 0, NULL, &proc_modules_operations);
81838 +#endif
81839 +#else
81840 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
81841 +#endif
81842 return 0;
81843 }
81844 module_init(proc_modules_init);
81845 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
81846 {
81847 struct module *mod;
81848
81849 - if (addr < module_addr_min || addr > module_addr_max)
81850 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
81851 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
81852 return NULL;
81853
81854 list_for_each_entry_rcu(mod, &modules, list) {
81855 if (mod->state == MODULE_STATE_UNFORMED)
81856 continue;
81857 - if (within_module_core(addr, mod)
81858 - || within_module_init(addr, mod))
81859 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
81860 return mod;
81861 }
81862 return NULL;
81863 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
81864 */
81865 struct module *__module_text_address(unsigned long addr)
81866 {
81867 - struct module *mod = __module_address(addr);
81868 + struct module *mod;
81869 +
81870 +#ifdef CONFIG_X86_32
81871 + addr = ktla_ktva(addr);
81872 +#endif
81873 +
81874 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
81875 + return NULL;
81876 +
81877 + mod = __module_address(addr);
81878 +
81879 if (mod) {
81880 /* Make sure it's within the text section. */
81881 - if (!within(addr, mod->module_init, mod->init_text_size)
81882 - && !within(addr, mod->module_core, mod->core_text_size))
81883 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
81884 mod = NULL;
81885 }
81886 return mod;
81887 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
81888 index 7e3443f..b2a1e6b 100644
81889 --- a/kernel/mutex-debug.c
81890 +++ b/kernel/mutex-debug.c
81891 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
81892 }
81893
81894 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
81895 - struct thread_info *ti)
81896 + struct task_struct *task)
81897 {
81898 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
81899
81900 /* Mark the current thread as blocked on the lock: */
81901 - ti->task->blocked_on = waiter;
81902 + task->blocked_on = waiter;
81903 }
81904
81905 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
81906 - struct thread_info *ti)
81907 + struct task_struct *task)
81908 {
81909 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
81910 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
81911 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
81912 - ti->task->blocked_on = NULL;
81913 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
81914 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
81915 + task->blocked_on = NULL;
81916
81917 list_del_init(&waiter->list);
81918 waiter->task = NULL;
81919 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
81920 index 0799fd3..d06ae3b 100644
81921 --- a/kernel/mutex-debug.h
81922 +++ b/kernel/mutex-debug.h
81923 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
81924 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
81925 extern void debug_mutex_add_waiter(struct mutex *lock,
81926 struct mutex_waiter *waiter,
81927 - struct thread_info *ti);
81928 + struct task_struct *task);
81929 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
81930 - struct thread_info *ti);
81931 + struct task_struct *task);
81932 extern void debug_mutex_unlock(struct mutex *lock);
81933 extern void debug_mutex_init(struct mutex *lock, const char *name,
81934 struct lock_class_key *key);
81935 diff --git a/kernel/mutex.c b/kernel/mutex.c
81936 index a52ee7bb..f361f16 100644
81937 --- a/kernel/mutex.c
81938 +++ b/kernel/mutex.c
81939 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
81940 node->locked = 1;
81941 return;
81942 }
81943 - ACCESS_ONCE(prev->next) = node;
81944 + ACCESS_ONCE_RW(prev->next) = node;
81945 smp_wmb();
81946 /* Wait until the lock holder passes the lock down */
81947 while (!ACCESS_ONCE(node->locked))
81948 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
81949 while (!(next = ACCESS_ONCE(node->next)))
81950 arch_mutex_cpu_relax();
81951 }
81952 - ACCESS_ONCE(next->locked) = 1;
81953 + ACCESS_ONCE_RW(next->locked) = 1;
81954 smp_wmb();
81955 }
81956
81957 @@ -514,7 +514,7 @@ slowpath:
81958 spin_lock_mutex(&lock->wait_lock, flags);
81959
81960 debug_mutex_lock_common(lock, &waiter);
81961 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
81962 + debug_mutex_add_waiter(lock, &waiter, task);
81963
81964 /* add waiting tasks to the end of the waitqueue (FIFO): */
81965 list_add_tail(&waiter.list, &lock->wait_list);
81966 @@ -565,7 +565,7 @@ slowpath:
81967 done:
81968 lock_acquired(&lock->dep_map, ip);
81969 /* got the lock - rejoice! */
81970 - mutex_remove_waiter(lock, &waiter, current_thread_info());
81971 + mutex_remove_waiter(lock, &waiter, task);
81972 mutex_set_owner(lock);
81973
81974 if (!__builtin_constant_p(ww_ctx == NULL)) {
81975 @@ -604,7 +604,7 @@ done:
81976 return 0;
81977
81978 err:
81979 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
81980 + mutex_remove_waiter(lock, &waiter, task);
81981 spin_unlock_mutex(&lock->wait_lock, flags);
81982 debug_mutex_free_waiter(&waiter);
81983 mutex_release(&lock->dep_map, 1, ip);
81984 diff --git a/kernel/notifier.c b/kernel/notifier.c
81985 index 2d5cc4c..d9ea600 100644
81986 --- a/kernel/notifier.c
81987 +++ b/kernel/notifier.c
81988 @@ -5,6 +5,7 @@
81989 #include <linux/rcupdate.h>
81990 #include <linux/vmalloc.h>
81991 #include <linux/reboot.h>
81992 +#include <linux/mm.h>
81993
81994 /*
81995 * Notifier list for kernel code which wants to be called
81996 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
81997 while ((*nl) != NULL) {
81998 if (n->priority > (*nl)->priority)
81999 break;
82000 - nl = &((*nl)->next);
82001 + nl = (struct notifier_block **)&((*nl)->next);
82002 }
82003 - n->next = *nl;
82004 + pax_open_kernel();
82005 + *(const void **)&n->next = *nl;
82006 rcu_assign_pointer(*nl, n);
82007 + pax_close_kernel();
82008 return 0;
82009 }
82010
82011 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82012 return 0;
82013 if (n->priority > (*nl)->priority)
82014 break;
82015 - nl = &((*nl)->next);
82016 + nl = (struct notifier_block **)&((*nl)->next);
82017 }
82018 - n->next = *nl;
82019 + pax_open_kernel();
82020 + *(const void **)&n->next = *nl;
82021 rcu_assign_pointer(*nl, n);
82022 + pax_close_kernel();
82023 return 0;
82024 }
82025
82026 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82027 {
82028 while ((*nl) != NULL) {
82029 if ((*nl) == n) {
82030 + pax_open_kernel();
82031 rcu_assign_pointer(*nl, n->next);
82032 + pax_close_kernel();
82033 return 0;
82034 }
82035 - nl = &((*nl)->next);
82036 + nl = (struct notifier_block **)&((*nl)->next);
82037 }
82038 return -ENOENT;
82039 }
82040 diff --git a/kernel/panic.c b/kernel/panic.c
82041 index 8018646..b6a5b4f 100644
82042 --- a/kernel/panic.c
82043 +++ b/kernel/panic.c
82044 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82045 disable_trace_on_warning();
82046
82047 pr_warn("------------[ cut here ]------------\n");
82048 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82049 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82050 raw_smp_processor_id(), current->pid, file, line, caller);
82051
82052 if (args)
82053 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82054 */
82055 void __stack_chk_fail(void)
82056 {
82057 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82058 + dump_stack();
82059 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82060 __builtin_return_address(0));
82061 }
82062 EXPORT_SYMBOL(__stack_chk_fail);
82063 diff --git a/kernel/pid.c b/kernel/pid.c
82064 index ebe5e80..5d6d634 100644
82065 --- a/kernel/pid.c
82066 +++ b/kernel/pid.c
82067 @@ -33,6 +33,7 @@
82068 #include <linux/rculist.h>
82069 #include <linux/bootmem.h>
82070 #include <linux/hash.h>
82071 +#include <linux/security.h>
82072 #include <linux/pid_namespace.h>
82073 #include <linux/init_task.h>
82074 #include <linux/syscalls.h>
82075 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82076
82077 int pid_max = PID_MAX_DEFAULT;
82078
82079 -#define RESERVED_PIDS 300
82080 +#define RESERVED_PIDS 500
82081
82082 int pid_max_min = RESERVED_PIDS + 1;
82083 int pid_max_max = PID_MAX_LIMIT;
82084 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
82085 */
82086 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82087 {
82088 + struct task_struct *task;
82089 +
82090 rcu_lockdep_assert(rcu_read_lock_held(),
82091 "find_task_by_pid_ns() needs rcu_read_lock()"
82092 " protection");
82093 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82094 +
82095 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82096 +
82097 + if (gr_pid_is_chrooted(task))
82098 + return NULL;
82099 +
82100 + return task;
82101 }
82102
82103 struct task_struct *find_task_by_vpid(pid_t vnr)
82104 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82105 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82106 }
82107
82108 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82109 +{
82110 + rcu_lockdep_assert(rcu_read_lock_held(),
82111 + "find_task_by_pid_ns() needs rcu_read_lock()"
82112 + " protection");
82113 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82114 +}
82115 +
82116 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82117 {
82118 struct pid *pid;
82119 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82120 index 601bb36..f7e6f34 100644
82121 --- a/kernel/pid_namespace.c
82122 +++ b/kernel/pid_namespace.c
82123 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82124 void __user *buffer, size_t *lenp, loff_t *ppos)
82125 {
82126 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82127 - struct ctl_table tmp = *table;
82128 + ctl_table_no_const tmp = *table;
82129
82130 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82131 return -EPERM;
82132 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82133 index c7f31aa..2b44977 100644
82134 --- a/kernel/posix-cpu-timers.c
82135 +++ b/kernel/posix-cpu-timers.c
82136 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82137
82138 static __init int init_posix_cpu_timers(void)
82139 {
82140 - struct k_clock process = {
82141 + static struct k_clock process = {
82142 .clock_getres = process_cpu_clock_getres,
82143 .clock_get = process_cpu_clock_get,
82144 .timer_create = process_cpu_timer_create,
82145 .nsleep = process_cpu_nsleep,
82146 .nsleep_restart = process_cpu_nsleep_restart,
82147 };
82148 - struct k_clock thread = {
82149 + static struct k_clock thread = {
82150 .clock_getres = thread_cpu_clock_getres,
82151 .clock_get = thread_cpu_clock_get,
82152 .timer_create = thread_cpu_timer_create,
82153 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82154 index 424c2d4..679242f 100644
82155 --- a/kernel/posix-timers.c
82156 +++ b/kernel/posix-timers.c
82157 @@ -43,6 +43,7 @@
82158 #include <linux/hash.h>
82159 #include <linux/posix-clock.h>
82160 #include <linux/posix-timers.h>
82161 +#include <linux/grsecurity.h>
82162 #include <linux/syscalls.h>
82163 #include <linux/wait.h>
82164 #include <linux/workqueue.h>
82165 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82166 * which we beg off on and pass to do_sys_settimeofday().
82167 */
82168
82169 -static struct k_clock posix_clocks[MAX_CLOCKS];
82170 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82171
82172 /*
82173 * These ones are defined below.
82174 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82175 */
82176 static __init int init_posix_timers(void)
82177 {
82178 - struct k_clock clock_realtime = {
82179 + static struct k_clock clock_realtime = {
82180 .clock_getres = hrtimer_get_res,
82181 .clock_get = posix_clock_realtime_get,
82182 .clock_set = posix_clock_realtime_set,
82183 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82184 .timer_get = common_timer_get,
82185 .timer_del = common_timer_del,
82186 };
82187 - struct k_clock clock_monotonic = {
82188 + static struct k_clock clock_monotonic = {
82189 .clock_getres = hrtimer_get_res,
82190 .clock_get = posix_ktime_get_ts,
82191 .nsleep = common_nsleep,
82192 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82193 .timer_get = common_timer_get,
82194 .timer_del = common_timer_del,
82195 };
82196 - struct k_clock clock_monotonic_raw = {
82197 + static struct k_clock clock_monotonic_raw = {
82198 .clock_getres = hrtimer_get_res,
82199 .clock_get = posix_get_monotonic_raw,
82200 };
82201 - struct k_clock clock_realtime_coarse = {
82202 + static struct k_clock clock_realtime_coarse = {
82203 .clock_getres = posix_get_coarse_res,
82204 .clock_get = posix_get_realtime_coarse,
82205 };
82206 - struct k_clock clock_monotonic_coarse = {
82207 + static struct k_clock clock_monotonic_coarse = {
82208 .clock_getres = posix_get_coarse_res,
82209 .clock_get = posix_get_monotonic_coarse,
82210 };
82211 - struct k_clock clock_tai = {
82212 + static struct k_clock clock_tai = {
82213 .clock_getres = hrtimer_get_res,
82214 .clock_get = posix_get_tai,
82215 .nsleep = common_nsleep,
82216 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82217 .timer_get = common_timer_get,
82218 .timer_del = common_timer_del,
82219 };
82220 - struct k_clock clock_boottime = {
82221 + static struct k_clock clock_boottime = {
82222 .clock_getres = hrtimer_get_res,
82223 .clock_get = posix_get_boottime,
82224 .nsleep = common_nsleep,
82225 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82226 return;
82227 }
82228
82229 - posix_clocks[clock_id] = *new_clock;
82230 + posix_clocks[clock_id] = new_clock;
82231 }
82232 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82233
82234 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82235 return (id & CLOCKFD_MASK) == CLOCKFD ?
82236 &clock_posix_dynamic : &clock_posix_cpu;
82237
82238 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82239 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82240 return NULL;
82241 - return &posix_clocks[id];
82242 + return posix_clocks[id];
82243 }
82244
82245 static int common_timer_create(struct k_itimer *new_timer)
82246 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82247 struct k_clock *kc = clockid_to_kclock(which_clock);
82248 struct k_itimer *new_timer;
82249 int error, new_timer_id;
82250 - sigevent_t event;
82251 + sigevent_t event = { };
82252 int it_id_set = IT_ID_NOT_SET;
82253
82254 if (!kc)
82255 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82256 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82257 return -EFAULT;
82258
82259 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82260 + have their clock_set fptr set to a nosettime dummy function
82261 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82262 + call common_clock_set, which calls do_sys_settimeofday, which
82263 + we hook
82264 + */
82265 +
82266 return kc->clock_set(which_clock, &new_tp);
82267 }
82268
82269 diff --git a/kernel/power/process.c b/kernel/power/process.c
82270 index 06ec886..9dba35e 100644
82271 --- a/kernel/power/process.c
82272 +++ b/kernel/power/process.c
82273 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82274 unsigned int elapsed_msecs;
82275 bool wakeup = false;
82276 int sleep_usecs = USEC_PER_MSEC;
82277 + bool timedout = false;
82278
82279 do_gettimeofday(&start);
82280
82281 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82282
82283 while (true) {
82284 todo = 0;
82285 + if (time_after(jiffies, end_time))
82286 + timedout = true;
82287 read_lock(&tasklist_lock);
82288 do_each_thread(g, p) {
82289 if (p == current || !freeze_task(p))
82290 continue;
82291
82292 - if (!freezer_should_skip(p))
82293 + if (!freezer_should_skip(p)) {
82294 todo++;
82295 + if (timedout) {
82296 + printk(KERN_ERR "Task refusing to freeze:\n");
82297 + sched_show_task(p);
82298 + }
82299 + }
82300 } while_each_thread(g, p);
82301 read_unlock(&tasklist_lock);
82302
82303 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82304 todo += wq_busy;
82305 }
82306
82307 - if (!todo || time_after(jiffies, end_time))
82308 + if (!todo || timedout)
82309 break;
82310
82311 if (pm_wakeup_pending()) {
82312 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82313 index 5b5a708..ec7637e 100644
82314 --- a/kernel/printk/printk.c
82315 +++ b/kernel/printk/printk.c
82316 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82317 if (from_file && type != SYSLOG_ACTION_OPEN)
82318 return 0;
82319
82320 +#ifdef CONFIG_GRKERNSEC_DMESG
82321 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82322 + return -EPERM;
82323 +#endif
82324 +
82325 if (syslog_action_restricted(type)) {
82326 if (capable(CAP_SYSLOG))
82327 return 0;
82328 diff --git a/kernel/profile.c b/kernel/profile.c
82329 index 6631e1e..310c266 100644
82330 --- a/kernel/profile.c
82331 +++ b/kernel/profile.c
82332 @@ -37,7 +37,7 @@ struct profile_hit {
82333 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82334 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82335
82336 -static atomic_t *prof_buffer;
82337 +static atomic_unchecked_t *prof_buffer;
82338 static unsigned long prof_len, prof_shift;
82339
82340 int prof_on __read_mostly;
82341 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82342 hits[i].pc = 0;
82343 continue;
82344 }
82345 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82346 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82347 hits[i].hits = hits[i].pc = 0;
82348 }
82349 }
82350 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82351 * Add the current hit(s) and flush the write-queue out
82352 * to the global buffer:
82353 */
82354 - atomic_add(nr_hits, &prof_buffer[pc]);
82355 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82356 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82357 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82358 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82359 hits[i].pc = hits[i].hits = 0;
82360 }
82361 out:
82362 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82363 {
82364 unsigned long pc;
82365 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82366 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82367 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82368 }
82369 #endif /* !CONFIG_SMP */
82370
82371 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82372 return -EFAULT;
82373 buf++; p++; count--; read++;
82374 }
82375 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82376 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82377 if (copy_to_user(buf, (void *)pnt, count))
82378 return -EFAULT;
82379 read += count;
82380 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82381 }
82382 #endif
82383 profile_discard_flip_buffers();
82384 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82385 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82386 return count;
82387 }
82388
82389 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82390 index a146ee3..ffed4c3 100644
82391 --- a/kernel/ptrace.c
82392 +++ b/kernel/ptrace.c
82393 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82394 if (seize)
82395 flags |= PT_SEIZED;
82396 rcu_read_lock();
82397 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82398 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82399 flags |= PT_PTRACE_CAP;
82400 rcu_read_unlock();
82401 task->ptrace = flags;
82402 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82403 break;
82404 return -EIO;
82405 }
82406 - if (copy_to_user(dst, buf, retval))
82407 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82408 return -EFAULT;
82409 copied += retval;
82410 src += retval;
82411 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82412 bool seized = child->ptrace & PT_SEIZED;
82413 int ret = -EIO;
82414 siginfo_t siginfo, *si;
82415 - void __user *datavp = (void __user *) data;
82416 + void __user *datavp = (__force void __user *) data;
82417 unsigned long __user *datalp = datavp;
82418 unsigned long flags;
82419
82420 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82421 goto out;
82422 }
82423
82424 + if (gr_handle_ptrace(child, request)) {
82425 + ret = -EPERM;
82426 + goto out_put_task_struct;
82427 + }
82428 +
82429 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82430 ret = ptrace_attach(child, request, addr, data);
82431 /*
82432 * Some architectures need to do book-keeping after
82433 * a ptrace attach.
82434 */
82435 - if (!ret)
82436 + if (!ret) {
82437 arch_ptrace_attach(child);
82438 + gr_audit_ptrace(child);
82439 + }
82440 goto out_put_task_struct;
82441 }
82442
82443 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82444 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82445 if (copied != sizeof(tmp))
82446 return -EIO;
82447 - return put_user(tmp, (unsigned long __user *)data);
82448 + return put_user(tmp, (__force unsigned long __user *)data);
82449 }
82450
82451 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82452 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82453 }
82454
82455 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82456 - compat_long_t addr, compat_long_t data)
82457 + compat_ulong_t addr, compat_ulong_t data)
82458 {
82459 struct task_struct *child;
82460 long ret;
82461 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82462 goto out;
82463 }
82464
82465 + if (gr_handle_ptrace(child, request)) {
82466 + ret = -EPERM;
82467 + goto out_put_task_struct;
82468 + }
82469 +
82470 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82471 ret = ptrace_attach(child, request, addr, data);
82472 /*
82473 * Some architectures need to do book-keeping after
82474 * a ptrace attach.
82475 */
82476 - if (!ret)
82477 + if (!ret) {
82478 arch_ptrace_attach(child);
82479 + gr_audit_ptrace(child);
82480 + }
82481 goto out_put_task_struct;
82482 }
82483
82484 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82485 index cce6ba8..7c758b1f 100644
82486 --- a/kernel/rcupdate.c
82487 +++ b/kernel/rcupdate.c
82488 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82489 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82490 */
82491 if (till_stall_check < 3) {
82492 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82493 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82494 till_stall_check = 3;
82495 } else if (till_stall_check > 300) {
82496 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82497 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82498 till_stall_check = 300;
82499 }
82500 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82501 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82502 index aa34411..4832cd4 100644
82503 --- a/kernel/rcutiny.c
82504 +++ b/kernel/rcutiny.c
82505 @@ -45,7 +45,7 @@
82506 /* Forward declarations for rcutiny_plugin.h. */
82507 struct rcu_ctrlblk;
82508 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82509 -static void rcu_process_callbacks(struct softirq_action *unused);
82510 +static void rcu_process_callbacks(void);
82511 static void __call_rcu(struct rcu_head *head,
82512 void (*func)(struct rcu_head *rcu),
82513 struct rcu_ctrlblk *rcp);
82514 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82515 false));
82516 }
82517
82518 -static void rcu_process_callbacks(struct softirq_action *unused)
82519 +static __latent_entropy void rcu_process_callbacks(void)
82520 {
82521 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82522 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82523 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82524 index f4871e5..8ef5741 100644
82525 --- a/kernel/rcutorture.c
82526 +++ b/kernel/rcutorture.c
82527 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82528 { 0 };
82529 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82530 { 0 };
82531 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82532 -static atomic_t n_rcu_torture_alloc;
82533 -static atomic_t n_rcu_torture_alloc_fail;
82534 -static atomic_t n_rcu_torture_free;
82535 -static atomic_t n_rcu_torture_mberror;
82536 -static atomic_t n_rcu_torture_error;
82537 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82538 +static atomic_unchecked_t n_rcu_torture_alloc;
82539 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82540 +static atomic_unchecked_t n_rcu_torture_free;
82541 +static atomic_unchecked_t n_rcu_torture_mberror;
82542 +static atomic_unchecked_t n_rcu_torture_error;
82543 static long n_rcu_torture_barrier_error;
82544 static long n_rcu_torture_boost_ktrerror;
82545 static long n_rcu_torture_boost_rterror;
82546 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82547
82548 spin_lock_bh(&rcu_torture_lock);
82549 if (list_empty(&rcu_torture_freelist)) {
82550 - atomic_inc(&n_rcu_torture_alloc_fail);
82551 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82552 spin_unlock_bh(&rcu_torture_lock);
82553 return NULL;
82554 }
82555 - atomic_inc(&n_rcu_torture_alloc);
82556 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82557 p = rcu_torture_freelist.next;
82558 list_del_init(p);
82559 spin_unlock_bh(&rcu_torture_lock);
82560 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82561 static void
82562 rcu_torture_free(struct rcu_torture *p)
82563 {
82564 - atomic_inc(&n_rcu_torture_free);
82565 + atomic_inc_unchecked(&n_rcu_torture_free);
82566 spin_lock_bh(&rcu_torture_lock);
82567 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82568 spin_unlock_bh(&rcu_torture_lock);
82569 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82570 i = rp->rtort_pipe_count;
82571 if (i > RCU_TORTURE_PIPE_LEN)
82572 i = RCU_TORTURE_PIPE_LEN;
82573 - atomic_inc(&rcu_torture_wcount[i]);
82574 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82575 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82576 rp->rtort_mbtest = 0;
82577 rcu_torture_free(rp);
82578 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82579 i = rp->rtort_pipe_count;
82580 if (i > RCU_TORTURE_PIPE_LEN)
82581 i = RCU_TORTURE_PIPE_LEN;
82582 - atomic_inc(&rcu_torture_wcount[i]);
82583 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82584 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82585 rp->rtort_mbtest = 0;
82586 list_del(&rp->rtort_free);
82587 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82588 i = old_rp->rtort_pipe_count;
82589 if (i > RCU_TORTURE_PIPE_LEN)
82590 i = RCU_TORTURE_PIPE_LEN;
82591 - atomic_inc(&rcu_torture_wcount[i]);
82592 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82593 old_rp->rtort_pipe_count++;
82594 cur_ops->deferred_free(old_rp);
82595 }
82596 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82597 return;
82598 }
82599 if (p->rtort_mbtest == 0)
82600 - atomic_inc(&n_rcu_torture_mberror);
82601 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82602 spin_lock(&rand_lock);
82603 cur_ops->read_delay(&rand);
82604 n_rcu_torture_timers++;
82605 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82606 continue;
82607 }
82608 if (p->rtort_mbtest == 0)
82609 - atomic_inc(&n_rcu_torture_mberror);
82610 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82611 cur_ops->read_delay(&rand);
82612 preempt_disable();
82613 pipe_count = p->rtort_pipe_count;
82614 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82615 rcu_torture_current,
82616 rcu_torture_current_version,
82617 list_empty(&rcu_torture_freelist),
82618 - atomic_read(&n_rcu_torture_alloc),
82619 - atomic_read(&n_rcu_torture_alloc_fail),
82620 - atomic_read(&n_rcu_torture_free));
82621 + atomic_read_unchecked(&n_rcu_torture_alloc),
82622 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82623 + atomic_read_unchecked(&n_rcu_torture_free));
82624 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82625 - atomic_read(&n_rcu_torture_mberror),
82626 + atomic_read_unchecked(&n_rcu_torture_mberror),
82627 n_rcu_torture_boost_ktrerror,
82628 n_rcu_torture_boost_rterror);
82629 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82630 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82631 n_barrier_attempts,
82632 n_rcu_torture_barrier_error);
82633 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82634 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82635 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82636 n_rcu_torture_barrier_error != 0 ||
82637 n_rcu_torture_boost_ktrerror != 0 ||
82638 n_rcu_torture_boost_rterror != 0 ||
82639 n_rcu_torture_boost_failure != 0 ||
82640 i > 1) {
82641 cnt += sprintf(&page[cnt], "!!! ");
82642 - atomic_inc(&n_rcu_torture_error);
82643 + atomic_inc_unchecked(&n_rcu_torture_error);
82644 WARN_ON_ONCE(1);
82645 }
82646 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82647 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82648 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82649 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82650 cnt += sprintf(&page[cnt], " %d",
82651 - atomic_read(&rcu_torture_wcount[i]));
82652 + atomic_read_unchecked(&rcu_torture_wcount[i]));
82653 }
82654 cnt += sprintf(&page[cnt], "\n");
82655 if (cur_ops->stats)
82656 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
82657
82658 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
82659
82660 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82661 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82662 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
82663 else if (n_online_successes != n_online_attempts ||
82664 n_offline_successes != n_offline_attempts)
82665 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
82666
82667 rcu_torture_current = NULL;
82668 rcu_torture_current_version = 0;
82669 - atomic_set(&n_rcu_torture_alloc, 0);
82670 - atomic_set(&n_rcu_torture_alloc_fail, 0);
82671 - atomic_set(&n_rcu_torture_free, 0);
82672 - atomic_set(&n_rcu_torture_mberror, 0);
82673 - atomic_set(&n_rcu_torture_error, 0);
82674 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
82675 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
82676 + atomic_set_unchecked(&n_rcu_torture_free, 0);
82677 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
82678 + atomic_set_unchecked(&n_rcu_torture_error, 0);
82679 n_rcu_torture_barrier_error = 0;
82680 n_rcu_torture_boost_ktrerror = 0;
82681 n_rcu_torture_boost_rterror = 0;
82682 n_rcu_torture_boost_failure = 0;
82683 n_rcu_torture_boosts = 0;
82684 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
82685 - atomic_set(&rcu_torture_wcount[i], 0);
82686 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
82687 for_each_possible_cpu(cpu) {
82688 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82689 per_cpu(rcu_torture_count, cpu)[i] = 0;
82690 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
82691 index 068de3a..5e7db2f 100644
82692 --- a/kernel/rcutree.c
82693 +++ b/kernel/rcutree.c
82694 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
82695 rcu_prepare_for_idle(smp_processor_id());
82696 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82697 smp_mb__before_atomic_inc(); /* See above. */
82698 - atomic_inc(&rdtp->dynticks);
82699 + atomic_inc_unchecked(&rdtp->dynticks);
82700 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
82701 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82702 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82703
82704 /*
82705 * It is illegal to enter an extended quiescent state while
82706 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
82707 int user)
82708 {
82709 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
82710 - atomic_inc(&rdtp->dynticks);
82711 + atomic_inc_unchecked(&rdtp->dynticks);
82712 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82713 smp_mb__after_atomic_inc(); /* See above. */
82714 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82715 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82716 rcu_cleanup_after_idle(smp_processor_id());
82717 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
82718 if (!user && !is_idle_task(current)) {
82719 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
82720 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
82721
82722 if (rdtp->dynticks_nmi_nesting == 0 &&
82723 - (atomic_read(&rdtp->dynticks) & 0x1))
82724 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
82725 return;
82726 rdtp->dynticks_nmi_nesting++;
82727 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
82728 - atomic_inc(&rdtp->dynticks);
82729 + atomic_inc_unchecked(&rdtp->dynticks);
82730 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82731 smp_mb__after_atomic_inc(); /* See above. */
82732 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82733 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82734 }
82735
82736 /**
82737 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
82738 return;
82739 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82740 smp_mb__before_atomic_inc(); /* See above. */
82741 - atomic_inc(&rdtp->dynticks);
82742 + atomic_inc_unchecked(&rdtp->dynticks);
82743 smp_mb__after_atomic_inc(); /* Force delay to next write. */
82744 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82745 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82746 }
82747
82748 /**
82749 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
82750 int ret;
82751
82752 preempt_disable();
82753 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82754 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82755 preempt_enable();
82756 return ret;
82757 }
82758 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
82759 */
82760 static int dyntick_save_progress_counter(struct rcu_data *rdp)
82761 {
82762 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
82763 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82764 return (rdp->dynticks_snap & 0x1) == 0;
82765 }
82766
82767 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
82768 unsigned int curr;
82769 unsigned int snap;
82770
82771 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
82772 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82773 snap = (unsigned int)rdp->dynticks_snap;
82774
82775 /*
82776 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
82777 rdp = this_cpu_ptr(rsp->rda);
82778 rcu_preempt_check_blocked_tasks(rnp);
82779 rnp->qsmask = rnp->qsmaskinit;
82780 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
82781 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
82782 WARN_ON_ONCE(rnp->completed != rsp->completed);
82783 - ACCESS_ONCE(rnp->completed) = rsp->completed;
82784 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
82785 if (rnp == rdp->mynode)
82786 __note_gp_changes(rsp, rnp, rdp);
82787 rcu_preempt_boost_start_gp(rnp);
82788 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
82789 */
82790 rcu_for_each_node_breadth_first(rsp, rnp) {
82791 raw_spin_lock_irq(&rnp->lock);
82792 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
82793 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
82794 rdp = this_cpu_ptr(rsp->rda);
82795 if (rnp == rdp->mynode)
82796 __note_gp_changes(rsp, rnp, rdp);
82797 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
82798 rsp->qlen += rdp->qlen;
82799 rdp->n_cbs_orphaned += rdp->qlen;
82800 rdp->qlen_lazy = 0;
82801 - ACCESS_ONCE(rdp->qlen) = 0;
82802 + ACCESS_ONCE_RW(rdp->qlen) = 0;
82803 }
82804
82805 /*
82806 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
82807 }
82808 smp_mb(); /* List handling before counting for rcu_barrier(). */
82809 rdp->qlen_lazy -= count_lazy;
82810 - ACCESS_ONCE(rdp->qlen) -= count;
82811 + ACCESS_ONCE_RW(rdp->qlen) -= count;
82812 rdp->n_cbs_invoked += count;
82813
82814 /* Reinstate batch limit if we have worked down the excess. */
82815 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
82816 /*
82817 * Do RCU core processing for the current CPU.
82818 */
82819 -static void rcu_process_callbacks(struct softirq_action *unused)
82820 +static __latent_entropy void rcu_process_callbacks(void)
82821 {
82822 struct rcu_state *rsp;
82823
82824 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
82825 local_irq_restore(flags);
82826 return;
82827 }
82828 - ACCESS_ONCE(rdp->qlen)++;
82829 + ACCESS_ONCE_RW(rdp->qlen)++;
82830 if (lazy)
82831 rdp->qlen_lazy++;
82832 else
82833 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
82834 * counter wrap on a 32-bit system. Quite a few more CPUs would of
82835 * course be required on a 64-bit system.
82836 */
82837 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
82838 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
82839 (ulong)atomic_long_read(&rsp->expedited_done) +
82840 ULONG_MAX / 8)) {
82841 synchronize_sched();
82842 - atomic_long_inc(&rsp->expedited_wrap);
82843 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
82844 return;
82845 }
82846
82847 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
82848 * Take a ticket. Note that atomic_inc_return() implies a
82849 * full memory barrier.
82850 */
82851 - snap = atomic_long_inc_return(&rsp->expedited_start);
82852 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
82853 firstsnap = snap;
82854 get_online_cpus();
82855 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
82856 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
82857 synchronize_sched_expedited_cpu_stop,
82858 NULL) == -EAGAIN) {
82859 put_online_cpus();
82860 - atomic_long_inc(&rsp->expedited_tryfail);
82861 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
82862
82863 /* Check to see if someone else did our work for us. */
82864 s = atomic_long_read(&rsp->expedited_done);
82865 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
82866 /* ensure test happens before caller kfree */
82867 smp_mb__before_atomic_inc(); /* ^^^ */
82868 - atomic_long_inc(&rsp->expedited_workdone1);
82869 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
82870 return;
82871 }
82872
82873 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
82874 udelay(trycount * num_online_cpus());
82875 } else {
82876 wait_rcu_gp(call_rcu_sched);
82877 - atomic_long_inc(&rsp->expedited_normal);
82878 + atomic_long_inc_unchecked(&rsp->expedited_normal);
82879 return;
82880 }
82881
82882 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
82883 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
82884 /* ensure test happens before caller kfree */
82885 smp_mb__before_atomic_inc(); /* ^^^ */
82886 - atomic_long_inc(&rsp->expedited_workdone2);
82887 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
82888 return;
82889 }
82890
82891 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
82892 * period works for us.
82893 */
82894 get_online_cpus();
82895 - snap = atomic_long_read(&rsp->expedited_start);
82896 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
82897 smp_mb(); /* ensure read is before try_stop_cpus(). */
82898 }
82899 - atomic_long_inc(&rsp->expedited_stoppedcpus);
82900 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
82901
82902 /*
82903 * Everyone up to our most recent fetch is covered by our grace
82904 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
82905 * than we did already did their update.
82906 */
82907 do {
82908 - atomic_long_inc(&rsp->expedited_done_tries);
82909 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
82910 s = atomic_long_read(&rsp->expedited_done);
82911 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
82912 /* ensure test happens before caller kfree */
82913 smp_mb__before_atomic_inc(); /* ^^^ */
82914 - atomic_long_inc(&rsp->expedited_done_lost);
82915 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
82916 break;
82917 }
82918 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
82919 - atomic_long_inc(&rsp->expedited_done_exit);
82920 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
82921
82922 put_online_cpus();
82923 }
82924 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
82925 * ACCESS_ONCE() to prevent the compiler from speculating
82926 * the increment to precede the early-exit check.
82927 */
82928 - ACCESS_ONCE(rsp->n_barrier_done)++;
82929 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
82930 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
82931 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
82932 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
82933 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
82934
82935 /* Increment ->n_barrier_done to prevent duplicate work. */
82936 smp_mb(); /* Keep increment after above mechanism. */
82937 - ACCESS_ONCE(rsp->n_barrier_done)++;
82938 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
82939 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
82940 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
82941 smp_mb(); /* Keep increment before caller's subsequent code. */
82942 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
82943 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
82944 init_callback_list(rdp);
82945 rdp->qlen_lazy = 0;
82946 - ACCESS_ONCE(rdp->qlen) = 0;
82947 + ACCESS_ONCE_RW(rdp->qlen) = 0;
82948 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
82949 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
82950 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
82951 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
82952 rdp->cpu = cpu;
82953 rdp->rsp = rsp;
82954 rcu_boot_init_nocb_percpu_data(rdp);
82955 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
82956 rdp->blimit = blimit;
82957 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
82958 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
82959 - atomic_set(&rdp->dynticks->dynticks,
82960 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
82961 + atomic_set_unchecked(&rdp->dynticks->dynticks,
82962 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
82963 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
82964
82965 /* Add CPU to rcu_node bitmasks. */
82966 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
82967 index b383258..2440c1e 100644
82968 --- a/kernel/rcutree.h
82969 +++ b/kernel/rcutree.h
82970 @@ -87,7 +87,7 @@ struct rcu_dynticks {
82971 long long dynticks_nesting; /* Track irq/process nesting level. */
82972 /* Process level is worth LLONG_MAX/2. */
82973 int dynticks_nmi_nesting; /* Track NMI nesting level. */
82974 - atomic_t dynticks; /* Even value for idle, else odd. */
82975 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
82976 #ifdef CONFIG_RCU_FAST_NO_HZ
82977 bool all_lazy; /* Are all CPU's CBs lazy? */
82978 unsigned long nonlazy_posted;
82979 @@ -419,17 +419,17 @@ struct rcu_state {
82980 /* _rcu_barrier(). */
82981 /* End of fields guarded by barrier_mutex. */
82982
82983 - atomic_long_t expedited_start; /* Starting ticket. */
82984 - atomic_long_t expedited_done; /* Done ticket. */
82985 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
82986 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
82987 - atomic_long_t expedited_workdone1; /* # done by others #1. */
82988 - atomic_long_t expedited_workdone2; /* # done by others #2. */
82989 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
82990 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
82991 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
82992 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
82993 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
82994 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
82995 + atomic_long_t expedited_done; /* Done ticket. */
82996 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
82997 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
82998 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
82999 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83000 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83001 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83002 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83003 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83004 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83005
83006 unsigned long jiffies_force_qs; /* Time at which to invoke */
83007 /* force_quiescent_state(). */
83008 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83009 index 769e12e..7b2139b 100644
83010 --- a/kernel/rcutree_plugin.h
83011 +++ b/kernel/rcutree_plugin.h
83012 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83013
83014 /* Clean up and exit. */
83015 smp_mb(); /* ensure expedited GP seen before counter increment. */
83016 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83017 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83018 unlock_mb_ret:
83019 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83020 mb_ret:
83021 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83022 free_cpumask_var(cm);
83023 }
83024
83025 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83026 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83027 .store = &rcu_cpu_kthread_task,
83028 .thread_should_run = rcu_cpu_kthread_should_run,
83029 .thread_fn = rcu_cpu_kthread,
83030 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83031 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83032 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83033 cpu, ticks_value, ticks_title,
83034 - atomic_read(&rdtp->dynticks) & 0xfff,
83035 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83036 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83037 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83038 fast_no_hz);
83039 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83040
83041 /* Enqueue the callback on the nocb list and update counts. */
83042 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83043 - ACCESS_ONCE(*old_rhpp) = rhp;
83044 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83045 atomic_long_add(rhcount, &rdp->nocb_q_count);
83046 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83047
83048 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83049 * Extract queued callbacks, update counts, and wait
83050 * for a grace period to elapse.
83051 */
83052 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83053 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83054 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83055 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83056 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83057 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83058 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83059 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83060 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83061 rcu_nocb_wait_gp(rdp);
83062
83063 /* Each pass through the following loop invokes a callback. */
83064 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83065 list = next;
83066 }
83067 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83068 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83069 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83070 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83071 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83072 rdp->n_nocbs_invoked += c;
83073 }
83074 return 0;
83075 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83076 t = kthread_run(rcu_nocb_kthread, rdp,
83077 "rcuo%c/%d", rsp->abbr, cpu);
83078 BUG_ON(IS_ERR(t));
83079 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83080 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83081 }
83082 }
83083
83084 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83085 index cf6c174..a8f4b50 100644
83086 --- a/kernel/rcutree_trace.c
83087 +++ b/kernel/rcutree_trace.c
83088 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83089 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83090 rdp->passed_quiesce, rdp->qs_pending);
83091 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83092 - atomic_read(&rdp->dynticks->dynticks),
83093 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83094 rdp->dynticks->dynticks_nesting,
83095 rdp->dynticks->dynticks_nmi_nesting,
83096 rdp->dynticks_fqs);
83097 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83098 struct rcu_state *rsp = (struct rcu_state *)m->private;
83099
83100 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",
83101 - atomic_long_read(&rsp->expedited_start),
83102 + atomic_long_read_unchecked(&rsp->expedited_start),
83103 atomic_long_read(&rsp->expedited_done),
83104 - atomic_long_read(&rsp->expedited_wrap),
83105 - atomic_long_read(&rsp->expedited_tryfail),
83106 - atomic_long_read(&rsp->expedited_workdone1),
83107 - atomic_long_read(&rsp->expedited_workdone2),
83108 - atomic_long_read(&rsp->expedited_normal),
83109 - atomic_long_read(&rsp->expedited_stoppedcpus),
83110 - atomic_long_read(&rsp->expedited_done_tries),
83111 - atomic_long_read(&rsp->expedited_done_lost),
83112 - atomic_long_read(&rsp->expedited_done_exit));
83113 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83114 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83115 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83116 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83117 + atomic_long_read_unchecked(&rsp->expedited_normal),
83118 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83119 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83120 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83121 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83122 return 0;
83123 }
83124
83125 diff --git a/kernel/resource.c b/kernel/resource.c
83126 index 3f285dc..5755f62 100644
83127 --- a/kernel/resource.c
83128 +++ b/kernel/resource.c
83129 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83130
83131 static int __init ioresources_init(void)
83132 {
83133 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83134 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83135 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83136 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83137 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83138 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83139 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83140 +#endif
83141 +#else
83142 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83143 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83144 +#endif
83145 return 0;
83146 }
83147 __initcall(ioresources_init);
83148 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83149 index 1d96dd0..994ff19 100644
83150 --- a/kernel/rtmutex-tester.c
83151 +++ b/kernel/rtmutex-tester.c
83152 @@ -22,7 +22,7 @@
83153 #define MAX_RT_TEST_MUTEXES 8
83154
83155 static spinlock_t rttest_lock;
83156 -static atomic_t rttest_event;
83157 +static atomic_unchecked_t rttest_event;
83158
83159 struct test_thread_data {
83160 int opcode;
83161 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83162
83163 case RTTEST_LOCKCONT:
83164 td->mutexes[td->opdata] = 1;
83165 - td->event = atomic_add_return(1, &rttest_event);
83166 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83167 return 0;
83168
83169 case RTTEST_RESET:
83170 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83171 return 0;
83172
83173 case RTTEST_RESETEVENT:
83174 - atomic_set(&rttest_event, 0);
83175 + atomic_set_unchecked(&rttest_event, 0);
83176 return 0;
83177
83178 default:
83179 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83180 return ret;
83181
83182 td->mutexes[id] = 1;
83183 - td->event = atomic_add_return(1, &rttest_event);
83184 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83185 rt_mutex_lock(&mutexes[id]);
83186 - td->event = atomic_add_return(1, &rttest_event);
83187 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83188 td->mutexes[id] = 4;
83189 return 0;
83190
83191 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83192 return ret;
83193
83194 td->mutexes[id] = 1;
83195 - td->event = atomic_add_return(1, &rttest_event);
83196 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83197 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83198 - td->event = atomic_add_return(1, &rttest_event);
83199 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83200 td->mutexes[id] = ret ? 0 : 4;
83201 return ret ? -EINTR : 0;
83202
83203 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83204 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83205 return ret;
83206
83207 - td->event = atomic_add_return(1, &rttest_event);
83208 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83209 rt_mutex_unlock(&mutexes[id]);
83210 - td->event = atomic_add_return(1, &rttest_event);
83211 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83212 td->mutexes[id] = 0;
83213 return 0;
83214
83215 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83216 break;
83217
83218 td->mutexes[dat] = 2;
83219 - td->event = atomic_add_return(1, &rttest_event);
83220 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83221 break;
83222
83223 default:
83224 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83225 return;
83226
83227 td->mutexes[dat] = 3;
83228 - td->event = atomic_add_return(1, &rttest_event);
83229 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83230 break;
83231
83232 case RTTEST_LOCKNOWAIT:
83233 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83234 return;
83235
83236 td->mutexes[dat] = 1;
83237 - td->event = atomic_add_return(1, &rttest_event);
83238 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83239 return;
83240
83241 default:
83242 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83243 index 4a07353..66b5291 100644
83244 --- a/kernel/sched/auto_group.c
83245 +++ b/kernel/sched/auto_group.c
83246 @@ -11,7 +11,7 @@
83247
83248 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83249 static struct autogroup autogroup_default;
83250 -static atomic_t autogroup_seq_nr;
83251 +static atomic_unchecked_t autogroup_seq_nr;
83252
83253 void __init autogroup_init(struct task_struct *init_task)
83254 {
83255 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83256
83257 kref_init(&ag->kref);
83258 init_rwsem(&ag->lock);
83259 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83260 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83261 ag->tg = tg;
83262 #ifdef CONFIG_RT_GROUP_SCHED
83263 /*
83264 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83265 index 05c39f0..442e6fe 100644
83266 --- a/kernel/sched/core.c
83267 +++ b/kernel/sched/core.c
83268 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83269 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83270 * or number of jiffies left till timeout) if completed.
83271 */
83272 -long __sched
83273 +long __sched __intentional_overflow(-1)
83274 wait_for_completion_interruptible_timeout(struct completion *x,
83275 unsigned long timeout)
83276 {
83277 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83278 *
83279 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83280 */
83281 -int __sched wait_for_completion_killable(struct completion *x)
83282 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83283 {
83284 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83285 if (t == -ERESTARTSYS)
83286 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83287 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83288 * or number of jiffies left till timeout) if completed.
83289 */
83290 -long __sched
83291 +long __sched __intentional_overflow(-1)
83292 wait_for_completion_killable_timeout(struct completion *x,
83293 unsigned long timeout)
83294 {
83295 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83296 /* convert nice value [19,-20] to rlimit style value [1,40] */
83297 int nice_rlim = 20 - nice;
83298
83299 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83300 +
83301 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83302 capable(CAP_SYS_NICE));
83303 }
83304 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83305 if (nice > 19)
83306 nice = 19;
83307
83308 - if (increment < 0 && !can_nice(current, nice))
83309 + if (increment < 0 && (!can_nice(current, nice) ||
83310 + gr_handle_chroot_nice()))
83311 return -EPERM;
83312
83313 retval = security_task_setnice(current, nice);
83314 @@ -3344,6 +3347,7 @@ recheck:
83315 unsigned long rlim_rtprio =
83316 task_rlimit(p, RLIMIT_RTPRIO);
83317
83318 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83319 /* can't set/change the rt policy */
83320 if (policy != p->policy && !rlim_rtprio)
83321 return -EPERM;
83322 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83323
83324 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83325
83326 -static struct ctl_table sd_ctl_dir[] = {
83327 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83328 {
83329 .procname = "sched_domain",
83330 .mode = 0555,
83331 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83332 {}
83333 };
83334
83335 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83336 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83337 {
83338 - struct ctl_table *entry =
83339 + ctl_table_no_const *entry =
83340 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83341
83342 return entry;
83343 }
83344
83345 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83346 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83347 {
83348 - struct ctl_table *entry;
83349 + ctl_table_no_const *entry;
83350
83351 /*
83352 * In the intermediate directories, both the child directory and
83353 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83354 * will always be set. In the lowest directory the names are
83355 * static strings and all have proc handlers.
83356 */
83357 - for (entry = *tablep; entry->mode; entry++) {
83358 - if (entry->child)
83359 - sd_free_ctl_entry(&entry->child);
83360 + for (entry = tablep; entry->mode; entry++) {
83361 + if (entry->child) {
83362 + sd_free_ctl_entry(entry->child);
83363 + pax_open_kernel();
83364 + entry->child = NULL;
83365 + pax_close_kernel();
83366 + }
83367 if (entry->proc_handler == NULL)
83368 kfree(entry->procname);
83369 }
83370
83371 - kfree(*tablep);
83372 - *tablep = NULL;
83373 + kfree(tablep);
83374 }
83375
83376 static int min_load_idx = 0;
83377 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83378
83379 static void
83380 -set_table_entry(struct ctl_table *entry,
83381 +set_table_entry(ctl_table_no_const *entry,
83382 const char *procname, void *data, int maxlen,
83383 umode_t mode, proc_handler *proc_handler,
83384 bool load_idx)
83385 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83386 static struct ctl_table *
83387 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83388 {
83389 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83390 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83391
83392 if (table == NULL)
83393 return NULL;
83394 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83395 return table;
83396 }
83397
83398 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83399 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83400 {
83401 - struct ctl_table *entry, *table;
83402 + ctl_table_no_const *entry, *table;
83403 struct sched_domain *sd;
83404 int domain_num = 0, i;
83405 char buf[32];
83406 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83407 static void register_sched_domain_sysctl(void)
83408 {
83409 int i, cpu_num = num_possible_cpus();
83410 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83411 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83412 char buf[32];
83413
83414 WARN_ON(sd_ctl_dir[0].child);
83415 + pax_open_kernel();
83416 sd_ctl_dir[0].child = entry;
83417 + pax_close_kernel();
83418
83419 if (entry == NULL)
83420 return;
83421 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83422 if (sd_sysctl_header)
83423 unregister_sysctl_table(sd_sysctl_header);
83424 sd_sysctl_header = NULL;
83425 - if (sd_ctl_dir[0].child)
83426 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83427 + if (sd_ctl_dir[0].child) {
83428 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83429 + pax_open_kernel();
83430 + sd_ctl_dir[0].child = NULL;
83431 + pax_close_kernel();
83432 + }
83433 }
83434 #else
83435 static void register_sched_domain_sysctl(void)
83436 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83437 index 31cbc15..ba68c15 100644
83438 --- a/kernel/sched/fair.c
83439 +++ b/kernel/sched/fair.c
83440 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83441
83442 static void reset_ptenuma_scan(struct task_struct *p)
83443 {
83444 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83445 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83446 p->mm->numa_scan_offset = 0;
83447 }
83448
83449 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83450 * run_rebalance_domains is triggered when needed from the scheduler tick.
83451 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83452 */
83453 -static void run_rebalance_domains(struct softirq_action *h)
83454 +static __latent_entropy void run_rebalance_domains(void)
83455 {
83456 int this_cpu = smp_processor_id();
83457 struct rq *this_rq = cpu_rq(this_cpu);
83458 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83459 index ef0a7b2..1b728c1 100644
83460 --- a/kernel/sched/sched.h
83461 +++ b/kernel/sched/sched.h
83462 @@ -1004,7 +1004,7 @@ struct sched_class {
83463 #ifdef CONFIG_FAIR_GROUP_SCHED
83464 void (*task_move_group) (struct task_struct *p, int on_rq);
83465 #endif
83466 -};
83467 +} __do_const;
83468
83469 #define sched_class_highest (&stop_sched_class)
83470 #define for_each_class(class) \
83471 diff --git a/kernel/signal.c b/kernel/signal.c
83472 index 50e4107..9409983 100644
83473 --- a/kernel/signal.c
83474 +++ b/kernel/signal.c
83475 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83476
83477 int print_fatal_signals __read_mostly;
83478
83479 -static void __user *sig_handler(struct task_struct *t, int sig)
83480 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83481 {
83482 return t->sighand->action[sig - 1].sa.sa_handler;
83483 }
83484
83485 -static int sig_handler_ignored(void __user *handler, int sig)
83486 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83487 {
83488 /* Is it explicitly or implicitly ignored? */
83489 return handler == SIG_IGN ||
83490 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83491
83492 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83493 {
83494 - void __user *handler;
83495 + __sighandler_t handler;
83496
83497 handler = sig_handler(t, sig);
83498
83499 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83500 atomic_inc(&user->sigpending);
83501 rcu_read_unlock();
83502
83503 + if (!override_rlimit)
83504 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83505 +
83506 if (override_rlimit ||
83507 atomic_read(&user->sigpending) <=
83508 task_rlimit(t, RLIMIT_SIGPENDING)) {
83509 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83510
83511 int unhandled_signal(struct task_struct *tsk, int sig)
83512 {
83513 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83514 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83515 if (is_global_init(tsk))
83516 return 1;
83517 if (handler != SIG_IGN && handler != SIG_DFL)
83518 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83519 }
83520 }
83521
83522 + /* allow glibc communication via tgkill to other threads in our
83523 + thread group */
83524 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83525 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83526 + && gr_handle_signal(t, sig))
83527 + return -EPERM;
83528 +
83529 return security_task_kill(t, info, sig, 0);
83530 }
83531
83532 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83533 return send_signal(sig, info, p, 1);
83534 }
83535
83536 -static int
83537 +int
83538 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83539 {
83540 return send_signal(sig, info, t, 0);
83541 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83542 unsigned long int flags;
83543 int ret, blocked, ignored;
83544 struct k_sigaction *action;
83545 + int is_unhandled = 0;
83546
83547 spin_lock_irqsave(&t->sighand->siglock, flags);
83548 action = &t->sighand->action[sig-1];
83549 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83550 }
83551 if (action->sa.sa_handler == SIG_DFL)
83552 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83553 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83554 + is_unhandled = 1;
83555 ret = specific_send_sig_info(sig, info, t);
83556 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83557
83558 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83559 + normal operation */
83560 + if (is_unhandled) {
83561 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83562 + gr_handle_crash(t, sig);
83563 + }
83564 +
83565 return ret;
83566 }
83567
83568 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83569 ret = check_kill_permission(sig, info, p);
83570 rcu_read_unlock();
83571
83572 - if (!ret && sig)
83573 + if (!ret && sig) {
83574 ret = do_send_sig_info(sig, info, p, true);
83575 + if (!ret)
83576 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83577 + }
83578
83579 return ret;
83580 }
83581 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83582 int error = -ESRCH;
83583
83584 rcu_read_lock();
83585 - p = find_task_by_vpid(pid);
83586 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83587 + /* allow glibc communication via tgkill to other threads in our
83588 + thread group */
83589 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83590 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83591 + p = find_task_by_vpid_unrestricted(pid);
83592 + else
83593 +#endif
83594 + p = find_task_by_vpid(pid);
83595 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83596 error = check_kill_permission(sig, info, p);
83597 /*
83598 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83599 }
83600 seg = get_fs();
83601 set_fs(KERNEL_DS);
83602 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83603 - (stack_t __force __user *) &uoss,
83604 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83605 + (stack_t __force_user *) &uoss,
83606 compat_user_stack_pointer());
83607 set_fs(seg);
83608 if (ret >= 0 && uoss_ptr) {
83609 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83610 index eb89e18..a4e6792 100644
83611 --- a/kernel/smpboot.c
83612 +++ b/kernel/smpboot.c
83613 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83614 }
83615 smpboot_unpark_thread(plug_thread, cpu);
83616 }
83617 - list_add(&plug_thread->list, &hotplug_threads);
83618 + pax_list_add(&plug_thread->list, &hotplug_threads);
83619 out:
83620 mutex_unlock(&smpboot_threads_lock);
83621 return ret;
83622 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83623 {
83624 get_online_cpus();
83625 mutex_lock(&smpboot_threads_lock);
83626 - list_del(&plug_thread->list);
83627 + pax_list_del(&plug_thread->list);
83628 smpboot_destroy_threads(plug_thread);
83629 mutex_unlock(&smpboot_threads_lock);
83630 put_online_cpus();
83631 diff --git a/kernel/softirq.c b/kernel/softirq.c
83632 index adf6c00..5d89b73 100644
83633 --- a/kernel/softirq.c
83634 +++ b/kernel/softirq.c
83635 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83636 EXPORT_SYMBOL(irq_stat);
83637 #endif
83638
83639 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83640 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83641
83642 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83643
83644 -char *softirq_to_name[NR_SOFTIRQS] = {
83645 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83646 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83647 "TASKLET", "SCHED", "HRTIMER", "RCU"
83648 };
83649 @@ -248,7 +248,7 @@ restart:
83650 kstat_incr_softirqs_this_cpu(vec_nr);
83651
83652 trace_softirq_entry(vec_nr);
83653 - h->action(h);
83654 + h->action();
83655 trace_softirq_exit(vec_nr);
83656 if (unlikely(prev_count != preempt_count())) {
83657 printk(KERN_ERR "huh, entered softirq %u %s %p"
83658 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
83659 or_softirq_pending(1UL << nr);
83660 }
83661
83662 -void open_softirq(int nr, void (*action)(struct softirq_action *))
83663 +void __init open_softirq(int nr, void (*action)(void))
83664 {
83665 softirq_vec[nr].action = action;
83666 }
83667 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
83668
83669 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
83670
83671 -static void tasklet_action(struct softirq_action *a)
83672 +static __latent_entropy void tasklet_action(void)
83673 {
83674 struct tasklet_struct *list;
83675
83676 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
83677 }
83678 }
83679
83680 -static void tasklet_hi_action(struct softirq_action *a)
83681 +static __latent_entropy void tasklet_hi_action(void)
83682 {
83683 struct tasklet_struct *list;
83684
83685 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
83686 .notifier_call = cpu_callback
83687 };
83688
83689 -static struct smp_hotplug_thread softirq_threads = {
83690 +static struct smp_hotplug_thread softirq_threads __read_only = {
83691 .store = &ksoftirqd,
83692 .thread_should_run = ksoftirqd_should_run,
83693 .thread_fn = run_ksoftirqd,
83694 diff --git a/kernel/srcu.c b/kernel/srcu.c
83695 index 01d5ccb..cdcbee6 100644
83696 --- a/kernel/srcu.c
83697 +++ b/kernel/srcu.c
83698 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
83699
83700 idx = ACCESS_ONCE(sp->completed) & 0x1;
83701 preempt_disable();
83702 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83703 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83704 smp_mb(); /* B */ /* Avoid leaking the critical section. */
83705 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83706 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83707 preempt_enable();
83708 return idx;
83709 }
83710 diff --git a/kernel/sys.c b/kernel/sys.c
83711 index 771129b..dc0c7e3 100644
83712 --- a/kernel/sys.c
83713 +++ b/kernel/sys.c
83714 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
83715 error = -EACCES;
83716 goto out;
83717 }
83718 +
83719 + if (gr_handle_chroot_setpriority(p, niceval)) {
83720 + error = -EACCES;
83721 + goto out;
83722 + }
83723 +
83724 no_nice = security_task_setnice(p, niceval);
83725 if (no_nice) {
83726 error = no_nice;
83727 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
83728 goto error;
83729 }
83730
83731 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
83732 + goto error;
83733 +
83734 if (rgid != (gid_t) -1 ||
83735 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
83736 new->sgid = new->egid;
83737 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
83738 old = current_cred();
83739
83740 retval = -EPERM;
83741 +
83742 + if (gr_check_group_change(kgid, kgid, kgid))
83743 + goto error;
83744 +
83745 if (nsown_capable(CAP_SETGID))
83746 new->gid = new->egid = new->sgid = new->fsgid = kgid;
83747 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
83748 @@ -404,7 +417,7 @@ error:
83749 /*
83750 * change the user struct in a credentials set to match the new UID
83751 */
83752 -static int set_user(struct cred *new)
83753 +int set_user(struct cred *new)
83754 {
83755 struct user_struct *new_user;
83756
83757 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
83758 goto error;
83759 }
83760
83761 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
83762 + goto error;
83763 +
83764 if (!uid_eq(new->uid, old->uid)) {
83765 retval = set_user(new);
83766 if (retval < 0)
83767 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
83768 old = current_cred();
83769
83770 retval = -EPERM;
83771 +
83772 + if (gr_check_crash_uid(kuid))
83773 + goto error;
83774 + if (gr_check_user_change(kuid, kuid, kuid))
83775 + goto error;
83776 +
83777 if (nsown_capable(CAP_SETUID)) {
83778 new->suid = new->uid = kuid;
83779 if (!uid_eq(kuid, old->uid)) {
83780 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
83781 goto error;
83782 }
83783
83784 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
83785 + goto error;
83786 +
83787 if (ruid != (uid_t) -1) {
83788 new->uid = kruid;
83789 if (!uid_eq(kruid, old->uid)) {
83790 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
83791 goto error;
83792 }
83793
83794 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
83795 + goto error;
83796 +
83797 if (rgid != (gid_t) -1)
83798 new->gid = krgid;
83799 if (egid != (gid_t) -1)
83800 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
83801 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
83802 nsown_capable(CAP_SETUID)) {
83803 if (!uid_eq(kuid, old->fsuid)) {
83804 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
83805 + goto error;
83806 +
83807 new->fsuid = kuid;
83808 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
83809 goto change_okay;
83810 }
83811 }
83812
83813 +error:
83814 abort_creds(new);
83815 return old_fsuid;
83816
83817 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
83818 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
83819 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
83820 nsown_capable(CAP_SETGID)) {
83821 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
83822 + goto error;
83823 +
83824 if (!gid_eq(kgid, old->fsgid)) {
83825 new->fsgid = kgid;
83826 goto change_okay;
83827 }
83828 }
83829
83830 +error:
83831 abort_creds(new);
83832 return old_fsgid;
83833
83834 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
83835 return -EFAULT;
83836
83837 down_read(&uts_sem);
83838 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
83839 + error = __copy_to_user(name->sysname, &utsname()->sysname,
83840 __OLD_UTS_LEN);
83841 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
83842 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
83843 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
83844 __OLD_UTS_LEN);
83845 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
83846 - error |= __copy_to_user(&name->release, &utsname()->release,
83847 + error |= __copy_to_user(name->release, &utsname()->release,
83848 __OLD_UTS_LEN);
83849 error |= __put_user(0, name->release + __OLD_UTS_LEN);
83850 - error |= __copy_to_user(&name->version, &utsname()->version,
83851 + error |= __copy_to_user(name->version, &utsname()->version,
83852 __OLD_UTS_LEN);
83853 error |= __put_user(0, name->version + __OLD_UTS_LEN);
83854 - error |= __copy_to_user(&name->machine, &utsname()->machine,
83855 + error |= __copy_to_user(name->machine, &utsname()->machine,
83856 __OLD_UTS_LEN);
83857 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
83858 up_read(&uts_sem);
83859 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
83860 */
83861 new_rlim->rlim_cur = 1;
83862 }
83863 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
83864 + is changed to a lower value. Since tasks can be created by the same
83865 + user in between this limit change and an execve by this task, force
83866 + a recheck only for this task by setting PF_NPROC_EXCEEDED
83867 + */
83868 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
83869 + tsk->flags |= PF_NPROC_EXCEEDED;
83870 }
83871 if (!retval) {
83872 if (old_rlim)
83873 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
83874 index 07f6fc4..65fb3d4 100644
83875 --- a/kernel/sysctl.c
83876 +++ b/kernel/sysctl.c
83877 @@ -93,7 +93,6 @@
83878
83879
83880 #if defined(CONFIG_SYSCTL)
83881 -
83882 /* External variables not in a header file. */
83883 extern int sysctl_overcommit_memory;
83884 extern int sysctl_overcommit_ratio;
83885 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
83886
83887 /* Constants used for minimum and maximum */
83888 #ifdef CONFIG_LOCKUP_DETECTOR
83889 -static int sixty = 60;
83890 +static int sixty __read_only = 60;
83891 #endif
83892
83893 -static int zero;
83894 -static int __maybe_unused one = 1;
83895 -static int __maybe_unused two = 2;
83896 -static int __maybe_unused three = 3;
83897 -static unsigned long one_ul = 1;
83898 -static int one_hundred = 100;
83899 +static int neg_one __read_only = -1;
83900 +static int zero __read_only = 0;
83901 +static int __maybe_unused one __read_only = 1;
83902 +static int __maybe_unused two __read_only = 2;
83903 +static int __maybe_unused three __read_only = 3;
83904 +static unsigned long one_ul __read_only = 1;
83905 +static int one_hundred __read_only = 100;
83906 #ifdef CONFIG_PRINTK
83907 -static int ten_thousand = 10000;
83908 +static int ten_thousand __read_only = 10000;
83909 #endif
83910
83911 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
83912 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
83913 void __user *buffer, size_t *lenp, loff_t *ppos);
83914 #endif
83915
83916 -#ifdef CONFIG_PRINTK
83917 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
83918 void __user *buffer, size_t *lenp, loff_t *ppos);
83919 -#endif
83920
83921 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
83922 void __user *buffer, size_t *lenp, loff_t *ppos);
83923 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
83924
83925 #endif
83926
83927 +extern struct ctl_table grsecurity_table[];
83928 +
83929 static struct ctl_table kern_table[];
83930 static struct ctl_table vm_table[];
83931 static struct ctl_table fs_table[];
83932 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
83933 int sysctl_legacy_va_layout;
83934 #endif
83935
83936 +#ifdef CONFIG_PAX_SOFTMODE
83937 +static ctl_table pax_table[] = {
83938 + {
83939 + .procname = "softmode",
83940 + .data = &pax_softmode,
83941 + .maxlen = sizeof(unsigned int),
83942 + .mode = 0600,
83943 + .proc_handler = &proc_dointvec,
83944 + },
83945 +
83946 + { }
83947 +};
83948 +#endif
83949 +
83950 /* The default sysctl tables: */
83951
83952 static struct ctl_table sysctl_base_table[] = {
83953 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
83954 #endif
83955
83956 static struct ctl_table kern_table[] = {
83957 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
83958 + {
83959 + .procname = "grsecurity",
83960 + .mode = 0500,
83961 + .child = grsecurity_table,
83962 + },
83963 +#endif
83964 +
83965 +#ifdef CONFIG_PAX_SOFTMODE
83966 + {
83967 + .procname = "pax",
83968 + .mode = 0500,
83969 + .child = pax_table,
83970 + },
83971 +#endif
83972 +
83973 {
83974 .procname = "sched_child_runs_first",
83975 .data = &sysctl_sched_child_runs_first,
83976 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
83977 .data = &modprobe_path,
83978 .maxlen = KMOD_PATH_LEN,
83979 .mode = 0644,
83980 - .proc_handler = proc_dostring,
83981 + .proc_handler = proc_dostring_modpriv,
83982 },
83983 {
83984 .procname = "modules_disabled",
83985 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
83986 .extra1 = &zero,
83987 .extra2 = &one,
83988 },
83989 +#endif
83990 {
83991 .procname = "kptr_restrict",
83992 .data = &kptr_restrict,
83993 .maxlen = sizeof(int),
83994 .mode = 0644,
83995 .proc_handler = proc_dointvec_minmax_sysadmin,
83996 +#ifdef CONFIG_GRKERNSEC_HIDESYM
83997 + .extra1 = &two,
83998 +#else
83999 .extra1 = &zero,
84000 +#endif
84001 .extra2 = &two,
84002 },
84003 -#endif
84004 {
84005 .procname = "ngroups_max",
84006 .data = &ngroups_max,
84007 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84008 */
84009 {
84010 .procname = "perf_event_paranoid",
84011 - .data = &sysctl_perf_event_paranoid,
84012 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84013 + .data = &sysctl_perf_event_legitimately_concerned,
84014 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84015 .mode = 0644,
84016 - .proc_handler = proc_dointvec,
84017 + /* go ahead, be a hero */
84018 + .proc_handler = proc_dointvec_minmax_sysadmin,
84019 + .extra1 = &neg_one,
84020 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84021 + .extra2 = &three,
84022 +#else
84023 + .extra2 = &two,
84024 +#endif
84025 },
84026 {
84027 .procname = "perf_event_mlock_kb",
84028 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84029 .proc_handler = proc_dointvec_minmax,
84030 .extra1 = &zero,
84031 },
84032 + {
84033 + .procname = "heap_stack_gap",
84034 + .data = &sysctl_heap_stack_gap,
84035 + .maxlen = sizeof(sysctl_heap_stack_gap),
84036 + .mode = 0644,
84037 + .proc_handler = proc_doulongvec_minmax,
84038 + },
84039 #else
84040 {
84041 .procname = "nr_trim_pages",
84042 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84043 buffer, lenp, ppos);
84044 }
84045
84046 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84047 + void __user *buffer, size_t *lenp, loff_t *ppos)
84048 +{
84049 + if (write && !capable(CAP_SYS_MODULE))
84050 + return -EPERM;
84051 +
84052 + return _proc_do_string(table->data, table->maxlen, write,
84053 + buffer, lenp, ppos);
84054 +}
84055 +
84056 static size_t proc_skip_spaces(char **buf)
84057 {
84058 size_t ret;
84059 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84060 len = strlen(tmp);
84061 if (len > *size)
84062 len = *size;
84063 + if (len > sizeof(tmp))
84064 + len = sizeof(tmp);
84065 if (copy_to_user(*buf, tmp, len))
84066 return -EFAULT;
84067 *size -= len;
84068 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84069 static int proc_taint(struct ctl_table *table, int write,
84070 void __user *buffer, size_t *lenp, loff_t *ppos)
84071 {
84072 - struct ctl_table t;
84073 + ctl_table_no_const t;
84074 unsigned long tmptaint = get_taint();
84075 int err;
84076
84077 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84078 return err;
84079 }
84080
84081 -#ifdef CONFIG_PRINTK
84082 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84083 void __user *buffer, size_t *lenp, loff_t *ppos)
84084 {
84085 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84086
84087 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84088 }
84089 -#endif
84090
84091 struct do_proc_dointvec_minmax_conv_param {
84092 int *min;
84093 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84094 *i = val;
84095 } else {
84096 val = convdiv * (*i) / convmul;
84097 - if (!first)
84098 + if (!first) {
84099 err = proc_put_char(&buffer, &left, '\t');
84100 + if (err)
84101 + break;
84102 + }
84103 err = proc_put_long(&buffer, &left, val, false);
84104 if (err)
84105 break;
84106 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84107 return -ENOSYS;
84108 }
84109
84110 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84111 + void __user *buffer, size_t *lenp, loff_t *ppos)
84112 +{
84113 + return -ENOSYS;
84114 +}
84115 +
84116 int proc_dointvec(struct ctl_table *table, int write,
84117 void __user *buffer, size_t *lenp, loff_t *ppos)
84118 {
84119 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84120 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84121 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84122 EXPORT_SYMBOL(proc_dostring);
84123 +EXPORT_SYMBOL(proc_dostring_modpriv);
84124 EXPORT_SYMBOL(proc_doulongvec_minmax);
84125 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84126 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84127 index 145bb4d..b2aa969 100644
84128 --- a/kernel/taskstats.c
84129 +++ b/kernel/taskstats.c
84130 @@ -28,9 +28,12 @@
84131 #include <linux/fs.h>
84132 #include <linux/file.h>
84133 #include <linux/pid_namespace.h>
84134 +#include <linux/grsecurity.h>
84135 #include <net/genetlink.h>
84136 #include <linux/atomic.h>
84137
84138 +extern int gr_is_taskstats_denied(int pid);
84139 +
84140 /*
84141 * Maximum length of a cpumask that can be specified in
84142 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84143 @@ -570,6 +573,9 @@ err:
84144
84145 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84146 {
84147 + if (gr_is_taskstats_denied(current->pid))
84148 + return -EACCES;
84149 +
84150 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84151 return cmd_attr_register_cpumask(info);
84152 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84153 diff --git a/kernel/time.c b/kernel/time.c
84154 index 7c7964c..784a599 100644
84155 --- a/kernel/time.c
84156 +++ b/kernel/time.c
84157 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84158 return error;
84159
84160 if (tz) {
84161 + /* we log in do_settimeofday called below, so don't log twice
84162 + */
84163 + if (!tv)
84164 + gr_log_timechange();
84165 +
84166 sys_tz = *tz;
84167 update_vsyscall_tz();
84168 if (firsttime) {
84169 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84170 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84171 * value to a scaled second value.
84172 */
84173 -unsigned long
84174 +unsigned long __intentional_overflow(-1)
84175 timespec_to_jiffies(const struct timespec *value)
84176 {
84177 unsigned long sec = value->tv_sec;
84178 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84179 index eec50fc..65e5df6 100644
84180 --- a/kernel/time/alarmtimer.c
84181 +++ b/kernel/time/alarmtimer.c
84182 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84183 struct platform_device *pdev;
84184 int error = 0;
84185 int i;
84186 - struct k_clock alarm_clock = {
84187 + static struct k_clock alarm_clock = {
84188 .clock_getres = alarm_clock_getres,
84189 .clock_get = alarm_clock_get,
84190 .timer_create = alarm_timer_create,
84191 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84192 index 947ba25..20cbade 100644
84193 --- a/kernel/time/timekeeping.c
84194 +++ b/kernel/time/timekeeping.c
84195 @@ -15,6 +15,7 @@
84196 #include <linux/init.h>
84197 #include <linux/mm.h>
84198 #include <linux/sched.h>
84199 +#include <linux/grsecurity.h>
84200 #include <linux/syscore_ops.h>
84201 #include <linux/clocksource.h>
84202 #include <linux/jiffies.h>
84203 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84204 if (!timespec_valid_strict(tv))
84205 return -EINVAL;
84206
84207 + gr_log_timechange();
84208 +
84209 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84210 write_seqcount_begin(&timekeeper_seq);
84211
84212 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84213 index 61ed862..3b52c65 100644
84214 --- a/kernel/time/timer_list.c
84215 +++ b/kernel/time/timer_list.c
84216 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84217
84218 static void print_name_offset(struct seq_file *m, void *sym)
84219 {
84220 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84221 + SEQ_printf(m, "<%p>", NULL);
84222 +#else
84223 char symname[KSYM_NAME_LEN];
84224
84225 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84226 SEQ_printf(m, "<%pK>", sym);
84227 else
84228 SEQ_printf(m, "%s", symname);
84229 +#endif
84230 }
84231
84232 static void
84233 @@ -119,7 +123,11 @@ next_one:
84234 static void
84235 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84236 {
84237 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84238 + SEQ_printf(m, " .base: %p\n", NULL);
84239 +#else
84240 SEQ_printf(m, " .base: %pK\n", base);
84241 +#endif
84242 SEQ_printf(m, " .index: %d\n",
84243 base->index);
84244 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84245 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84246 {
84247 struct proc_dir_entry *pe;
84248
84249 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84250 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84251 +#else
84252 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84253 +#endif
84254 if (!pe)
84255 return -ENOMEM;
84256 return 0;
84257 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84258 index 0b537f2..40d6c20 100644
84259 --- a/kernel/time/timer_stats.c
84260 +++ b/kernel/time/timer_stats.c
84261 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84262 static unsigned long nr_entries;
84263 static struct entry entries[MAX_ENTRIES];
84264
84265 -static atomic_t overflow_count;
84266 +static atomic_unchecked_t overflow_count;
84267
84268 /*
84269 * The entries are in a hash-table, for fast lookup:
84270 @@ -140,7 +140,7 @@ static void reset_entries(void)
84271 nr_entries = 0;
84272 memset(entries, 0, sizeof(entries));
84273 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84274 - atomic_set(&overflow_count, 0);
84275 + atomic_set_unchecked(&overflow_count, 0);
84276 }
84277
84278 static struct entry *alloc_entry(void)
84279 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84280 if (likely(entry))
84281 entry->count++;
84282 else
84283 - atomic_inc(&overflow_count);
84284 + atomic_inc_unchecked(&overflow_count);
84285
84286 out_unlock:
84287 raw_spin_unlock_irqrestore(lock, flags);
84288 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84289
84290 static void print_name_offset(struct seq_file *m, unsigned long addr)
84291 {
84292 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84293 + seq_printf(m, "<%p>", NULL);
84294 +#else
84295 char symname[KSYM_NAME_LEN];
84296
84297 if (lookup_symbol_name(addr, symname) < 0)
84298 - seq_printf(m, "<%p>", (void *)addr);
84299 + seq_printf(m, "<%pK>", (void *)addr);
84300 else
84301 seq_printf(m, "%s", symname);
84302 +#endif
84303 }
84304
84305 static int tstats_show(struct seq_file *m, void *v)
84306 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84307
84308 seq_puts(m, "Timer Stats Version: v0.2\n");
84309 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84310 - if (atomic_read(&overflow_count))
84311 + if (atomic_read_unchecked(&overflow_count))
84312 seq_printf(m, "Overflow: %d entries\n",
84313 - atomic_read(&overflow_count));
84314 + atomic_read_unchecked(&overflow_count));
84315
84316 for (i = 0; i < nr_entries; i++) {
84317 entry = entries + i;
84318 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84319 {
84320 struct proc_dir_entry *pe;
84321
84322 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84323 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84324 +#else
84325 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84326 +#endif
84327 if (!pe)
84328 return -ENOMEM;
84329 return 0;
84330 diff --git a/kernel/timer.c b/kernel/timer.c
84331 index 4296d13..0164b04 100644
84332 --- a/kernel/timer.c
84333 +++ b/kernel/timer.c
84334 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84335 /*
84336 * This function runs timers and the timer-tq in bottom half context.
84337 */
84338 -static void run_timer_softirq(struct softirq_action *h)
84339 +static __latent_entropy void run_timer_softirq(void)
84340 {
84341 struct tvec_base *base = __this_cpu_read(tvec_bases);
84342
84343 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84344 *
84345 * In all cases the return value is guaranteed to be non-negative.
84346 */
84347 -signed long __sched schedule_timeout(signed long timeout)
84348 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84349 {
84350 struct timer_list timer;
84351 unsigned long expire;
84352 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84353 index b8b8560..75b1a09 100644
84354 --- a/kernel/trace/blktrace.c
84355 +++ b/kernel/trace/blktrace.c
84356 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84357 struct blk_trace *bt = filp->private_data;
84358 char buf[16];
84359
84360 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84361 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84362
84363 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84364 }
84365 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84366 return 1;
84367
84368 bt = buf->chan->private_data;
84369 - atomic_inc(&bt->dropped);
84370 + atomic_inc_unchecked(&bt->dropped);
84371 return 0;
84372 }
84373
84374 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84375
84376 bt->dir = dir;
84377 bt->dev = dev;
84378 - atomic_set(&bt->dropped, 0);
84379 + atomic_set_unchecked(&bt->dropped, 0);
84380
84381 ret = -EIO;
84382 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84383 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84384 index a6d098c..bb8cf65 100644
84385 --- a/kernel/trace/ftrace.c
84386 +++ b/kernel/trace/ftrace.c
84387 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84388 if (unlikely(ftrace_disabled))
84389 return 0;
84390
84391 + ret = ftrace_arch_code_modify_prepare();
84392 + FTRACE_WARN_ON(ret);
84393 + if (ret)
84394 + return 0;
84395 +
84396 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84397 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84398 if (ret) {
84399 ftrace_bug(ret, ip);
84400 - return 0;
84401 }
84402 - return 1;
84403 + return ret ? 0 : 1;
84404 }
84405
84406 /*
84407 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84408 if (!count)
84409 return 0;
84410
84411 + pax_open_kernel();
84412 sort(start, count, sizeof(*start),
84413 ftrace_cmp_ips, ftrace_swap_ips);
84414 + pax_close_kernel();
84415
84416 start_pg = ftrace_allocate_pages(count);
84417 if (!start_pg)
84418 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84419 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84420
84421 static int ftrace_graph_active;
84422 -static struct notifier_block ftrace_suspend_notifier;
84423 -
84424 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84425 {
84426 return 0;
84427 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84428 return NOTIFY_DONE;
84429 }
84430
84431 +static struct notifier_block ftrace_suspend_notifier = {
84432 + .notifier_call = ftrace_suspend_notifier_call
84433 +};
84434 +
84435 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84436 trace_func_graph_ent_t entryfunc)
84437 {
84438 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84439 goto out;
84440 }
84441
84442 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84443 register_pm_notifier(&ftrace_suspend_notifier);
84444
84445 ftrace_graph_active++;
84446 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84447 index cc2f66f..05edd54 100644
84448 --- a/kernel/trace/ring_buffer.c
84449 +++ b/kernel/trace/ring_buffer.c
84450 @@ -352,9 +352,9 @@ struct buffer_data_page {
84451 */
84452 struct buffer_page {
84453 struct list_head list; /* list of buffer pages */
84454 - local_t write; /* index for next write */
84455 + local_unchecked_t write; /* index for next write */
84456 unsigned read; /* index for next read */
84457 - local_t entries; /* entries on this page */
84458 + local_unchecked_t entries; /* entries on this page */
84459 unsigned long real_end; /* real end of data */
84460 struct buffer_data_page *page; /* Actual data page */
84461 };
84462 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84463 unsigned long last_overrun;
84464 local_t entries_bytes;
84465 local_t entries;
84466 - local_t overrun;
84467 - local_t commit_overrun;
84468 + local_unchecked_t overrun;
84469 + local_unchecked_t commit_overrun;
84470 local_t dropped_events;
84471 local_t committing;
84472 local_t commits;
84473 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84474 *
84475 * We add a counter to the write field to denote this.
84476 */
84477 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84478 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84479 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84480 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84481
84482 /*
84483 * Just make sure we have seen our old_write and synchronize
84484 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84485 * cmpxchg to only update if an interrupt did not already
84486 * do it for us. If the cmpxchg fails, we don't care.
84487 */
84488 - (void)local_cmpxchg(&next_page->write, old_write, val);
84489 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84490 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84491 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84492
84493 /*
84494 * No need to worry about races with clearing out the commit.
84495 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84496
84497 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84498 {
84499 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84500 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84501 }
84502
84503 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84504 {
84505 - return local_read(&bpage->write) & RB_WRITE_MASK;
84506 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84507 }
84508
84509 static int
84510 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84511 * bytes consumed in ring buffer from here.
84512 * Increment overrun to account for the lost events.
84513 */
84514 - local_add(page_entries, &cpu_buffer->overrun);
84515 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84516 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84517 }
84518
84519 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84520 * it is our responsibility to update
84521 * the counters.
84522 */
84523 - local_add(entries, &cpu_buffer->overrun);
84524 + local_add_unchecked(entries, &cpu_buffer->overrun);
84525 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84526
84527 /*
84528 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84529 if (tail == BUF_PAGE_SIZE)
84530 tail_page->real_end = 0;
84531
84532 - local_sub(length, &tail_page->write);
84533 + local_sub_unchecked(length, &tail_page->write);
84534 return;
84535 }
84536
84537 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84538 rb_event_set_padding(event);
84539
84540 /* Set the write back to the previous setting */
84541 - local_sub(length, &tail_page->write);
84542 + local_sub_unchecked(length, &tail_page->write);
84543 return;
84544 }
84545
84546 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84547
84548 /* Set write to end of buffer */
84549 length = (tail + length) - BUF_PAGE_SIZE;
84550 - local_sub(length, &tail_page->write);
84551 + local_sub_unchecked(length, &tail_page->write);
84552 }
84553
84554 /*
84555 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84556 * about it.
84557 */
84558 if (unlikely(next_page == commit_page)) {
84559 - local_inc(&cpu_buffer->commit_overrun);
84560 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84561 goto out_reset;
84562 }
84563
84564 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84565 cpu_buffer->tail_page) &&
84566 (cpu_buffer->commit_page ==
84567 cpu_buffer->reader_page))) {
84568 - local_inc(&cpu_buffer->commit_overrun);
84569 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84570 goto out_reset;
84571 }
84572 }
84573 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84574 length += RB_LEN_TIME_EXTEND;
84575
84576 tail_page = cpu_buffer->tail_page;
84577 - write = local_add_return(length, &tail_page->write);
84578 + write = local_add_return_unchecked(length, &tail_page->write);
84579
84580 /* set write to only the index of the write */
84581 write &= RB_WRITE_MASK;
84582 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84583 kmemcheck_annotate_bitfield(event, bitfield);
84584 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84585
84586 - local_inc(&tail_page->entries);
84587 + local_inc_unchecked(&tail_page->entries);
84588
84589 /*
84590 * If this is the first commit on the page, then update
84591 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84592
84593 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84594 unsigned long write_mask =
84595 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84596 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84597 unsigned long event_length = rb_event_length(event);
84598 /*
84599 * This is on the tail page. It is possible that
84600 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84601 */
84602 old_index += write_mask;
84603 new_index += write_mask;
84604 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84605 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84606 if (index == old_index) {
84607 /* update counters */
84608 local_sub(event_length, &cpu_buffer->entries_bytes);
84609 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84610
84611 /* Do the likely case first */
84612 if (likely(bpage->page == (void *)addr)) {
84613 - local_dec(&bpage->entries);
84614 + local_dec_unchecked(&bpage->entries);
84615 return;
84616 }
84617
84618 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84619 start = bpage;
84620 do {
84621 if (bpage->page == (void *)addr) {
84622 - local_dec(&bpage->entries);
84623 + local_dec_unchecked(&bpage->entries);
84624 return;
84625 }
84626 rb_inc_page(cpu_buffer, &bpage);
84627 @@ -3139,7 +3139,7 @@ static inline unsigned long
84628 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84629 {
84630 return local_read(&cpu_buffer->entries) -
84631 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84632 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84633 }
84634
84635 /**
84636 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84637 return 0;
84638
84639 cpu_buffer = buffer->buffers[cpu];
84640 - ret = local_read(&cpu_buffer->overrun);
84641 + ret = local_read_unchecked(&cpu_buffer->overrun);
84642
84643 return ret;
84644 }
84645 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84646 return 0;
84647
84648 cpu_buffer = buffer->buffers[cpu];
84649 - ret = local_read(&cpu_buffer->commit_overrun);
84650 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84651
84652 return ret;
84653 }
84654 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
84655 /* if you care about this being correct, lock the buffer */
84656 for_each_buffer_cpu(buffer, cpu) {
84657 cpu_buffer = buffer->buffers[cpu];
84658 - overruns += local_read(&cpu_buffer->overrun);
84659 + overruns += local_read_unchecked(&cpu_buffer->overrun);
84660 }
84661
84662 return overruns;
84663 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84664 /*
84665 * Reset the reader page to size zero.
84666 */
84667 - local_set(&cpu_buffer->reader_page->write, 0);
84668 - local_set(&cpu_buffer->reader_page->entries, 0);
84669 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84670 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84671 local_set(&cpu_buffer->reader_page->page->commit, 0);
84672 cpu_buffer->reader_page->real_end = 0;
84673
84674 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84675 * want to compare with the last_overrun.
84676 */
84677 smp_mb();
84678 - overwrite = local_read(&(cpu_buffer->overrun));
84679 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
84680
84681 /*
84682 * Here's the tricky part.
84683 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84684
84685 cpu_buffer->head_page
84686 = list_entry(cpu_buffer->pages, struct buffer_page, list);
84687 - local_set(&cpu_buffer->head_page->write, 0);
84688 - local_set(&cpu_buffer->head_page->entries, 0);
84689 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
84690 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
84691 local_set(&cpu_buffer->head_page->page->commit, 0);
84692
84693 cpu_buffer->head_page->read = 0;
84694 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84695
84696 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
84697 INIT_LIST_HEAD(&cpu_buffer->new_pages);
84698 - local_set(&cpu_buffer->reader_page->write, 0);
84699 - local_set(&cpu_buffer->reader_page->entries, 0);
84700 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84701 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84702 local_set(&cpu_buffer->reader_page->page->commit, 0);
84703 cpu_buffer->reader_page->read = 0;
84704
84705 local_set(&cpu_buffer->entries_bytes, 0);
84706 - local_set(&cpu_buffer->overrun, 0);
84707 - local_set(&cpu_buffer->commit_overrun, 0);
84708 + local_set_unchecked(&cpu_buffer->overrun, 0);
84709 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
84710 local_set(&cpu_buffer->dropped_events, 0);
84711 local_set(&cpu_buffer->entries, 0);
84712 local_set(&cpu_buffer->committing, 0);
84713 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
84714 rb_init_page(bpage);
84715 bpage = reader->page;
84716 reader->page = *data_page;
84717 - local_set(&reader->write, 0);
84718 - local_set(&reader->entries, 0);
84719 + local_set_unchecked(&reader->write, 0);
84720 + local_set_unchecked(&reader->entries, 0);
84721 reader->read = 0;
84722 *data_page = bpage;
84723
84724 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
84725 index 496f94d..754aeea 100644
84726 --- a/kernel/trace/trace.c
84727 +++ b/kernel/trace/trace.c
84728 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
84729 return 0;
84730 }
84731
84732 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
84733 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
84734 {
84735 /* do nothing if flag is already set */
84736 if (!!(trace_flags & mask) == !!enabled)
84737 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
84738 index afaae41..64871f8 100644
84739 --- a/kernel/trace/trace.h
84740 +++ b/kernel/trace/trace.h
84741 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
84742 void trace_printk_init_buffers(void);
84743 void trace_printk_start_comm(void);
84744 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
84745 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
84746 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
84747
84748 /*
84749 * Normal trace_printk() and friends allocates special buffers
84750 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
84751 index 26dc348..8708ca7 100644
84752 --- a/kernel/trace/trace_clock.c
84753 +++ b/kernel/trace/trace_clock.c
84754 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
84755 return now;
84756 }
84757
84758 -static atomic64_t trace_counter;
84759 +static atomic64_unchecked_t trace_counter;
84760
84761 /*
84762 * trace_clock_counter(): simply an atomic counter.
84763 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
84764 */
84765 u64 notrace trace_clock_counter(void)
84766 {
84767 - return atomic64_add_return(1, &trace_counter);
84768 + return atomic64_inc_return_unchecked(&trace_counter);
84769 }
84770 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
84771 index 29a7ebc..eb473cf 100644
84772 --- a/kernel/trace/trace_events.c
84773 +++ b/kernel/trace/trace_events.c
84774 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
84775 struct ftrace_module_file_ops {
84776 struct list_head list;
84777 struct module *mod;
84778 - struct file_operations id;
84779 - struct file_operations enable;
84780 - struct file_operations format;
84781 - struct file_operations filter;
84782 };
84783
84784 static struct ftrace_module_file_ops *
84785 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
84786
84787 file_ops->mod = mod;
84788
84789 - file_ops->id = ftrace_event_id_fops;
84790 - file_ops->id.owner = mod;
84791 -
84792 - file_ops->enable = ftrace_enable_fops;
84793 - file_ops->enable.owner = mod;
84794 -
84795 - file_ops->filter = ftrace_event_filter_fops;
84796 - file_ops->filter.owner = mod;
84797 -
84798 - file_ops->format = ftrace_event_format_fops;
84799 - file_ops->format.owner = mod;
84800 + pax_open_kernel();
84801 + mod->trace_id.owner = mod;
84802 + mod->trace_enable.owner = mod;
84803 + mod->trace_filter.owner = mod;
84804 + mod->trace_format.owner = mod;
84805 + pax_close_kernel();
84806
84807 list_add(&file_ops->list, &ftrace_module_file_list);
84808
84809 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
84810 struct ftrace_module_file_ops *file_ops)
84811 {
84812 return __trace_add_new_event(call, tr,
84813 - &file_ops->id, &file_ops->enable,
84814 - &file_ops->filter, &file_ops->format);
84815 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
84816 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
84817 }
84818
84819 #else
84820 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
84821 index b3dcfb2..ebee344 100644
84822 --- a/kernel/trace/trace_mmiotrace.c
84823 +++ b/kernel/trace/trace_mmiotrace.c
84824 @@ -24,7 +24,7 @@ struct header_iter {
84825 static struct trace_array *mmio_trace_array;
84826 static bool overrun_detected;
84827 static unsigned long prev_overruns;
84828 -static atomic_t dropped_count;
84829 +static atomic_unchecked_t dropped_count;
84830
84831 static void mmio_reset_data(struct trace_array *tr)
84832 {
84833 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
84834
84835 static unsigned long count_overruns(struct trace_iterator *iter)
84836 {
84837 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
84838 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
84839 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
84840
84841 if (over > prev_overruns)
84842 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
84843 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
84844 sizeof(*entry), 0, pc);
84845 if (!event) {
84846 - atomic_inc(&dropped_count);
84847 + atomic_inc_unchecked(&dropped_count);
84848 return;
84849 }
84850 entry = ring_buffer_event_data(event);
84851 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
84852 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
84853 sizeof(*entry), 0, pc);
84854 if (!event) {
84855 - atomic_inc(&dropped_count);
84856 + atomic_inc_unchecked(&dropped_count);
84857 return;
84858 }
84859 entry = ring_buffer_event_data(event);
84860 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
84861 index 34e7cba..6f9a729 100644
84862 --- a/kernel/trace/trace_output.c
84863 +++ b/kernel/trace/trace_output.c
84864 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
84865
84866 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
84867 if (!IS_ERR(p)) {
84868 - p = mangle_path(s->buffer + s->len, p, "\n");
84869 + p = mangle_path(s->buffer + s->len, p, "\n\\");
84870 if (p) {
84871 s->len = p - s->buffer;
84872 return 1;
84873 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
84874 goto out;
84875 }
84876
84877 + pax_open_kernel();
84878 if (event->funcs->trace == NULL)
84879 - event->funcs->trace = trace_nop_print;
84880 + *(void **)&event->funcs->trace = trace_nop_print;
84881 if (event->funcs->raw == NULL)
84882 - event->funcs->raw = trace_nop_print;
84883 + *(void **)&event->funcs->raw = trace_nop_print;
84884 if (event->funcs->hex == NULL)
84885 - event->funcs->hex = trace_nop_print;
84886 + *(void **)&event->funcs->hex = trace_nop_print;
84887 if (event->funcs->binary == NULL)
84888 - event->funcs->binary = trace_nop_print;
84889 + *(void **)&event->funcs->binary = trace_nop_print;
84890 + pax_close_kernel();
84891
84892 key = event->type & (EVENT_HASHSIZE - 1);
84893
84894 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
84895 index b20428c..4845a10 100644
84896 --- a/kernel/trace/trace_stack.c
84897 +++ b/kernel/trace/trace_stack.c
84898 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
84899 return;
84900
84901 /* we do not handle interrupt stacks yet */
84902 - if (!object_is_on_stack(stack))
84903 + if (!object_starts_on_stack(stack))
84904 return;
84905
84906 local_irq_save(flags);
84907 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
84908 index 9064b91..1f5d2f8 100644
84909 --- a/kernel/user_namespace.c
84910 +++ b/kernel/user_namespace.c
84911 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
84912 !kgid_has_mapping(parent_ns, group))
84913 return -EPERM;
84914
84915 +#ifdef CONFIG_GRKERNSEC
84916 + /*
84917 + * This doesn't really inspire confidence:
84918 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
84919 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
84920 + * Increases kernel attack surface in areas developers
84921 + * previously cared little about ("low importance due
84922 + * to requiring "root" capability")
84923 + * To be removed when this code receives *proper* review
84924 + */
84925 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
84926 + !capable(CAP_SETGID))
84927 + return -EPERM;
84928 +#endif
84929 +
84930 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
84931 if (!ns)
84932 return -ENOMEM;
84933 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
84934 if (atomic_read(&current->mm->mm_users) > 1)
84935 return -EINVAL;
84936
84937 - if (current->fs->users != 1)
84938 + if (atomic_read(&current->fs->users) != 1)
84939 return -EINVAL;
84940
84941 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
84942 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
84943 index 4f69f9a..7c6f8f8 100644
84944 --- a/kernel/utsname_sysctl.c
84945 +++ b/kernel/utsname_sysctl.c
84946 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
84947 static int proc_do_uts_string(ctl_table *table, int write,
84948 void __user *buffer, size_t *lenp, loff_t *ppos)
84949 {
84950 - struct ctl_table uts_table;
84951 + ctl_table_no_const uts_table;
84952 int r;
84953 memcpy(&uts_table, table, sizeof(uts_table));
84954 uts_table.data = get_uts(table, write);
84955 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
84956 index 1241d8c..d5cfc28 100644
84957 --- a/kernel/watchdog.c
84958 +++ b/kernel/watchdog.c
84959 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
84960 static void watchdog_nmi_disable(unsigned int cpu) { return; }
84961 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
84962
84963 -static struct smp_hotplug_thread watchdog_threads = {
84964 +static struct smp_hotplug_thread watchdog_threads __read_only = {
84965 .store = &softlockup_watchdog,
84966 .thread_should_run = watchdog_should_run,
84967 .thread_fn = watchdog,
84968 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
84969 index e93f7b9..989fcd7 100644
84970 --- a/kernel/workqueue.c
84971 +++ b/kernel/workqueue.c
84972 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
84973 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
84974 worker_flags |= WORKER_REBOUND;
84975 worker_flags &= ~WORKER_UNBOUND;
84976 - ACCESS_ONCE(worker->flags) = worker_flags;
84977 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
84978 }
84979
84980 spin_unlock_irq(&pool->lock);
84981 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
84982 index 1501aa5..e771896 100644
84983 --- a/lib/Kconfig.debug
84984 +++ b/lib/Kconfig.debug
84985 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
84986
84987 config DEBUG_WW_MUTEX_SLOWPATH
84988 bool "Wait/wound mutex debugging: Slowpath testing"
84989 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
84990 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
84991 select DEBUG_LOCK_ALLOC
84992 select DEBUG_SPINLOCK
84993 select DEBUG_MUTEXES
84994 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
84995
84996 config DEBUG_LOCK_ALLOC
84997 bool "Lock debugging: detect incorrect freeing of live locks"
84998 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
84999 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85000 select DEBUG_SPINLOCK
85001 select DEBUG_MUTEXES
85002 select LOCKDEP
85003 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85004
85005 config PROVE_LOCKING
85006 bool "Lock debugging: prove locking correctness"
85007 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85008 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85009 select LOCKDEP
85010 select DEBUG_SPINLOCK
85011 select DEBUG_MUTEXES
85012 @@ -914,7 +914,7 @@ config LOCKDEP
85013
85014 config LOCK_STAT
85015 bool "Lock usage statistics"
85016 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85017 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85018 select LOCKDEP
85019 select DEBUG_SPINLOCK
85020 select DEBUG_MUTEXES
85021 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85022 depends on DEBUG_KERNEL
85023 depends on STACKTRACE_SUPPORT
85024 depends on PROC_FS
85025 + depends on !GRKERNSEC_HIDESYM
85026 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85027 select KALLSYMS
85028 select KALLSYMS_ALL
85029 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85030 config DEBUG_STRICT_USER_COPY_CHECKS
85031 bool "Strict user copy size checks"
85032 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85033 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85034 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85035 help
85036 Enabling this option turns a certain set of sanity checks for user
85037 copy operations into compile time failures.
85038 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85039
85040 config PROVIDE_OHCI1394_DMA_INIT
85041 bool "Remote debugging over FireWire early on boot"
85042 - depends on PCI && X86
85043 + depends on PCI && X86 && !GRKERNSEC
85044 help
85045 If you want to debug problems which hang or crash the kernel early
85046 on boot and the crashing machine has a FireWire port, you can use
85047 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85048
85049 config FIREWIRE_OHCI_REMOTE_DMA
85050 bool "Remote debugging over FireWire with firewire-ohci"
85051 - depends on FIREWIRE_OHCI
85052 + depends on FIREWIRE_OHCI && !GRKERNSEC
85053 help
85054 This option lets you use the FireWire bus for remote debugging
85055 with help of the firewire-ohci driver. It enables unfiltered
85056 diff --git a/lib/Makefile b/lib/Makefile
85057 index 7baccfd..3ceb95f 100644
85058 --- a/lib/Makefile
85059 +++ b/lib/Makefile
85060 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85061
85062 obj-$(CONFIG_BTREE) += btree.o
85063 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85064 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85065 +obj-y += list_debug.o
85066 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85067
85068 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85069 diff --git a/lib/bitmap.c b/lib/bitmap.c
85070 index 06f7e4f..f3cf2b0 100644
85071 --- a/lib/bitmap.c
85072 +++ b/lib/bitmap.c
85073 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85074 {
85075 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85076 u32 chunk;
85077 - const char __user __force *ubuf = (const char __user __force *)buf;
85078 + const char __user *ubuf = (const char __force_user *)buf;
85079
85080 bitmap_zero(maskp, nmaskbits);
85081
85082 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85083 {
85084 if (!access_ok(VERIFY_READ, ubuf, ulen))
85085 return -EFAULT;
85086 - return __bitmap_parse((const char __force *)ubuf,
85087 + return __bitmap_parse((const char __force_kernel *)ubuf,
85088 ulen, 1, maskp, nmaskbits);
85089
85090 }
85091 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85092 {
85093 unsigned a, b;
85094 int c, old_c, totaldigits;
85095 - const char __user __force *ubuf = (const char __user __force *)buf;
85096 + const char __user *ubuf = (const char __force_user *)buf;
85097 int exp_digit, in_range;
85098
85099 totaldigits = c = 0;
85100 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85101 {
85102 if (!access_ok(VERIFY_READ, ubuf, ulen))
85103 return -EFAULT;
85104 - return __bitmap_parselist((const char __force *)ubuf,
85105 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85106 ulen, 1, maskp, nmaskbits);
85107 }
85108 EXPORT_SYMBOL(bitmap_parselist_user);
85109 diff --git a/lib/bug.c b/lib/bug.c
85110 index 1686034..a9c00c8 100644
85111 --- a/lib/bug.c
85112 +++ b/lib/bug.c
85113 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85114 return BUG_TRAP_TYPE_NONE;
85115
85116 bug = find_bug(bugaddr);
85117 + if (!bug)
85118 + return BUG_TRAP_TYPE_NONE;
85119
85120 file = NULL;
85121 line = 0;
85122 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85123 index 37061ed..da83f48 100644
85124 --- a/lib/debugobjects.c
85125 +++ b/lib/debugobjects.c
85126 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85127 if (limit > 4)
85128 return;
85129
85130 - is_on_stack = object_is_on_stack(addr);
85131 + is_on_stack = object_starts_on_stack(addr);
85132 if (is_on_stack == onstack)
85133 return;
85134
85135 diff --git a/lib/devres.c b/lib/devres.c
85136 index 8235331..5881053 100644
85137 --- a/lib/devres.c
85138 +++ b/lib/devres.c
85139 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85140 void devm_iounmap(struct device *dev, void __iomem *addr)
85141 {
85142 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85143 - (void *)addr));
85144 + (void __force *)addr));
85145 iounmap(addr);
85146 }
85147 EXPORT_SYMBOL(devm_iounmap);
85148 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85149 {
85150 ioport_unmap(addr);
85151 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85152 - devm_ioport_map_match, (void *)addr));
85153 + devm_ioport_map_match, (void __force *)addr));
85154 }
85155 EXPORT_SYMBOL(devm_ioport_unmap);
85156 #endif /* CONFIG_HAS_IOPORT */
85157 diff --git a/lib/div64.c b/lib/div64.c
85158 index a163b6c..9618fa5 100644
85159 --- a/lib/div64.c
85160 +++ b/lib/div64.c
85161 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85162 EXPORT_SYMBOL(__div64_32);
85163
85164 #ifndef div_s64_rem
85165 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85166 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85167 {
85168 u64 quotient;
85169
85170 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85171 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85172 */
85173 #ifndef div64_u64
85174 -u64 div64_u64(u64 dividend, u64 divisor)
85175 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85176 {
85177 u32 high = divisor >> 32;
85178 u64 quot;
85179 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85180 index d87a17a..ac0d79a 100644
85181 --- a/lib/dma-debug.c
85182 +++ b/lib/dma-debug.c
85183 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85184
85185 void dma_debug_add_bus(struct bus_type *bus)
85186 {
85187 - struct notifier_block *nb;
85188 + notifier_block_no_const *nb;
85189
85190 if (global_disable)
85191 return;
85192 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85193
85194 static void check_for_stack(struct device *dev, void *addr)
85195 {
85196 - if (object_is_on_stack(addr))
85197 + if (object_starts_on_stack(addr))
85198 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85199 "stack [addr=%p]\n", addr);
85200 }
85201 diff --git a/lib/inflate.c b/lib/inflate.c
85202 index 013a761..c28f3fc 100644
85203 --- a/lib/inflate.c
85204 +++ b/lib/inflate.c
85205 @@ -269,7 +269,7 @@ static void free(void *where)
85206 malloc_ptr = free_mem_ptr;
85207 }
85208 #else
85209 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85210 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85211 #define free(a) kfree(a)
85212 #endif
85213
85214 diff --git a/lib/ioremap.c b/lib/ioremap.c
85215 index 0c9216c..863bd89 100644
85216 --- a/lib/ioremap.c
85217 +++ b/lib/ioremap.c
85218 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85219 unsigned long next;
85220
85221 phys_addr -= addr;
85222 - pmd = pmd_alloc(&init_mm, pud, addr);
85223 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85224 if (!pmd)
85225 return -ENOMEM;
85226 do {
85227 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85228 unsigned long next;
85229
85230 phys_addr -= addr;
85231 - pud = pud_alloc(&init_mm, pgd, addr);
85232 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85233 if (!pud)
85234 return -ENOMEM;
85235 do {
85236 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85237 index bd2bea9..6b3c95e 100644
85238 --- a/lib/is_single_threaded.c
85239 +++ b/lib/is_single_threaded.c
85240 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85241 struct task_struct *p, *t;
85242 bool ret;
85243
85244 + if (!mm)
85245 + return true;
85246 +
85247 if (atomic_read(&task->signal->live) != 1)
85248 return false;
85249
85250 diff --git a/lib/kobject.c b/lib/kobject.c
85251 index 4a1f33d..2f3ca75 100644
85252 --- a/lib/kobject.c
85253 +++ b/lib/kobject.c
85254 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85255
85256
85257 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85258 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85259 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85260
85261 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85262 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85263 {
85264 enum kobj_ns_type type = ops->type;
85265 int error;
85266 diff --git a/lib/list_debug.c b/lib/list_debug.c
85267 index c24c2f7..06e070b 100644
85268 --- a/lib/list_debug.c
85269 +++ b/lib/list_debug.c
85270 @@ -11,7 +11,9 @@
85271 #include <linux/bug.h>
85272 #include <linux/kernel.h>
85273 #include <linux/rculist.h>
85274 +#include <linux/mm.h>
85275
85276 +#ifdef CONFIG_DEBUG_LIST
85277 /*
85278 * Insert a new entry between two known consecutive entries.
85279 *
85280 @@ -19,21 +21,32 @@
85281 * the prev/next entries already!
85282 */
85283
85284 -void __list_add(struct list_head *new,
85285 - struct list_head *prev,
85286 - struct list_head *next)
85287 +static bool __list_add_debug(struct list_head *new,
85288 + struct list_head *prev,
85289 + struct list_head *next)
85290 {
85291 - WARN(next->prev != prev,
85292 + if (WARN(next->prev != prev,
85293 "list_add corruption. next->prev should be "
85294 "prev (%p), but was %p. (next=%p).\n",
85295 - prev, next->prev, next);
85296 - WARN(prev->next != next,
85297 + prev, next->prev, next) ||
85298 + WARN(prev->next != next,
85299 "list_add corruption. prev->next should be "
85300 "next (%p), but was %p. (prev=%p).\n",
85301 - next, prev->next, prev);
85302 - WARN(new == prev || new == next,
85303 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85304 - new, prev, next);
85305 + next, prev->next, prev) ||
85306 + WARN(new == prev || new == next,
85307 + "list_add double add: new=%p, prev=%p, next=%p.\n",
85308 + new, prev, next))
85309 + return false;
85310 + return true;
85311 +}
85312 +
85313 +void __list_add(struct list_head *new,
85314 + struct list_head *prev,
85315 + struct list_head *next)
85316 +{
85317 + if (!__list_add_debug(new, prev, next))
85318 + return;
85319 +
85320 next->prev = new;
85321 new->next = next;
85322 new->prev = prev;
85323 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
85324 }
85325 EXPORT_SYMBOL(__list_add);
85326
85327 -void __list_del_entry(struct list_head *entry)
85328 +static bool __list_del_entry_debug(struct list_head *entry)
85329 {
85330 struct list_head *prev, *next;
85331
85332 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
85333 WARN(next->prev != entry,
85334 "list_del corruption. next->prev should be %p, "
85335 "but was %p\n", entry, next->prev))
85336 + return false;
85337 + return true;
85338 +}
85339 +
85340 +void __list_del_entry(struct list_head *entry)
85341 +{
85342 + if (!__list_del_entry_debug(entry))
85343 return;
85344
85345 - __list_del(prev, next);
85346 + __list_del(entry->prev, entry->next);
85347 }
85348 EXPORT_SYMBOL(__list_del_entry);
85349
85350 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
85351 void __list_add_rcu(struct list_head *new,
85352 struct list_head *prev, struct list_head *next)
85353 {
85354 - WARN(next->prev != prev,
85355 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85356 - prev, next->prev, next);
85357 - WARN(prev->next != next,
85358 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85359 - next, prev->next, prev);
85360 + if (!__list_add_debug(new, prev, next))
85361 + return;
85362 +
85363 new->next = next;
85364 new->prev = prev;
85365 rcu_assign_pointer(list_next_rcu(prev), new);
85366 next->prev = new;
85367 }
85368 EXPORT_SYMBOL(__list_add_rcu);
85369 +#endif
85370 +
85371 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85372 +{
85373 +#ifdef CONFIG_DEBUG_LIST
85374 + if (!__list_add_debug(new, prev, next))
85375 + return;
85376 +#endif
85377 +
85378 + pax_open_kernel();
85379 + next->prev = new;
85380 + new->next = next;
85381 + new->prev = prev;
85382 + prev->next = new;
85383 + pax_close_kernel();
85384 +}
85385 +EXPORT_SYMBOL(__pax_list_add);
85386 +
85387 +void pax_list_del(struct list_head *entry)
85388 +{
85389 +#ifdef CONFIG_DEBUG_LIST
85390 + if (!__list_del_entry_debug(entry))
85391 + return;
85392 +#endif
85393 +
85394 + pax_open_kernel();
85395 + __list_del(entry->prev, entry->next);
85396 + entry->next = LIST_POISON1;
85397 + entry->prev = LIST_POISON2;
85398 + pax_close_kernel();
85399 +}
85400 +EXPORT_SYMBOL(pax_list_del);
85401 +
85402 +void pax_list_del_init(struct list_head *entry)
85403 +{
85404 + pax_open_kernel();
85405 + __list_del(entry->prev, entry->next);
85406 + INIT_LIST_HEAD(entry);
85407 + pax_close_kernel();
85408 +}
85409 +EXPORT_SYMBOL(pax_list_del_init);
85410 +
85411 +void __pax_list_add_rcu(struct list_head *new,
85412 + struct list_head *prev, struct list_head *next)
85413 +{
85414 +#ifdef CONFIG_DEBUG_LIST
85415 + if (!__list_add_debug(new, prev, next))
85416 + return;
85417 +#endif
85418 +
85419 + pax_open_kernel();
85420 + new->next = next;
85421 + new->prev = prev;
85422 + rcu_assign_pointer(list_next_rcu(prev), new);
85423 + next->prev = new;
85424 + pax_close_kernel();
85425 +}
85426 +EXPORT_SYMBOL(__pax_list_add_rcu);
85427 +
85428 +void pax_list_del_rcu(struct list_head *entry)
85429 +{
85430 +#ifdef CONFIG_DEBUG_LIST
85431 + if (!__list_del_entry_debug(entry))
85432 + return;
85433 +#endif
85434 +
85435 + pax_open_kernel();
85436 + __list_del(entry->prev, entry->next);
85437 + entry->next = LIST_POISON1;
85438 + entry->prev = LIST_POISON2;
85439 + pax_close_kernel();
85440 +}
85441 +EXPORT_SYMBOL(pax_list_del_rcu);
85442 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
85443 index 7deeb62..144eb47 100644
85444 --- a/lib/percpu-refcount.c
85445 +++ b/lib/percpu-refcount.c
85446 @@ -29,7 +29,7 @@
85447 * can't hit 0 before we've added up all the percpu refs.
85448 */
85449
85450 -#define PCPU_COUNT_BIAS (1U << 31)
85451 +#define PCPU_COUNT_BIAS (1U << 30)
85452
85453 /**
85454 * percpu_ref_init - initialize a percpu refcount
85455 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85456 index e796429..6e38f9f 100644
85457 --- a/lib/radix-tree.c
85458 +++ b/lib/radix-tree.c
85459 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85460 int nr;
85461 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85462 };
85463 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85464 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85465
85466 static inline void *ptr_to_indirect(void *ptr)
85467 {
85468 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85469 index bb2b201..46abaf9 100644
85470 --- a/lib/strncpy_from_user.c
85471 +++ b/lib/strncpy_from_user.c
85472 @@ -21,7 +21,7 @@
85473 */
85474 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
85475 {
85476 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85477 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85478 long res = 0;
85479
85480 /*
85481 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85482 index a28df52..3d55877 100644
85483 --- a/lib/strnlen_user.c
85484 +++ b/lib/strnlen_user.c
85485 @@ -26,7 +26,7 @@
85486 */
85487 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85488 {
85489 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85490 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85491 long align, res = 0;
85492 unsigned long c;
85493
85494 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85495 index d23762e..e21eab2 100644
85496 --- a/lib/swiotlb.c
85497 +++ b/lib/swiotlb.c
85498 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85499
85500 void
85501 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85502 - dma_addr_t dev_addr)
85503 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85504 {
85505 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85506
85507 diff --git a/lib/usercopy.c b/lib/usercopy.c
85508 index 4f5b1dd..7cab418 100644
85509 --- a/lib/usercopy.c
85510 +++ b/lib/usercopy.c
85511 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85512 WARN(1, "Buffer overflow detected!\n");
85513 }
85514 EXPORT_SYMBOL(copy_from_user_overflow);
85515 +
85516 +void copy_to_user_overflow(void)
85517 +{
85518 + WARN(1, "Buffer overflow detected!\n");
85519 +}
85520 +EXPORT_SYMBOL(copy_to_user_overflow);
85521 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85522 index 739a363..aa668d7 100644
85523 --- a/lib/vsprintf.c
85524 +++ b/lib/vsprintf.c
85525 @@ -16,6 +16,9 @@
85526 * - scnprintf and vscnprintf
85527 */
85528
85529 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85530 +#define __INCLUDED_BY_HIDESYM 1
85531 +#endif
85532 #include <stdarg.h>
85533 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85534 #include <linux/types.h>
85535 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85536 return number(buf, end, *(const netdev_features_t *)addr, spec);
85537 }
85538
85539 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85540 +int kptr_restrict __read_mostly = 2;
85541 +#else
85542 int kptr_restrict __read_mostly;
85543 +#endif
85544
85545 /*
85546 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85547 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85548 * - 'f' For simple symbolic function names without offset
85549 * - 'S' For symbolic direct pointers with offset
85550 * - 's' For symbolic direct pointers without offset
85551 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85552 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85553 * - 'B' For backtraced symbolic direct pointers with offset
85554 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85555 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85556
85557 if (!ptr && *fmt != 'K') {
85558 /*
85559 - * Print (null) with the same width as a pointer so it makes
85560 + * Print (nil) with the same width as a pointer so it makes
85561 * tabular output look nice.
85562 */
85563 if (spec.field_width == -1)
85564 spec.field_width = default_width;
85565 - return string(buf, end, "(null)", spec);
85566 + return string(buf, end, "(nil)", spec);
85567 }
85568
85569 switch (*fmt) {
85570 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85571 /* Fallthrough */
85572 case 'S':
85573 case 's':
85574 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85575 + break;
85576 +#else
85577 + return symbol_string(buf, end, ptr, spec, fmt);
85578 +#endif
85579 + case 'A':
85580 case 'B':
85581 return symbol_string(buf, end, ptr, spec, fmt);
85582 case 'R':
85583 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85584 va_end(va);
85585 return buf;
85586 }
85587 + case 'P':
85588 + break;
85589 case 'K':
85590 /*
85591 * %pK cannot be used in IRQ context because its test
85592 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85593 return number(buf, end,
85594 (unsigned long long) *((phys_addr_t *)ptr), spec);
85595 }
85596 +
85597 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85598 + /* 'P' = approved pointers to copy to userland,
85599 + as in the /proc/kallsyms case, as we make it display nothing
85600 + for non-root users, and the real contents for root users
85601 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85602 + above
85603 + */
85604 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85605 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85606 + dump_stack();
85607 + ptr = NULL;
85608 + }
85609 +#endif
85610 +
85611 spec.flags |= SMALL;
85612 if (spec.field_width == -1) {
85613 spec.field_width = default_width;
85614 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85615 typeof(type) value; \
85616 if (sizeof(type) == 8) { \
85617 args = PTR_ALIGN(args, sizeof(u32)); \
85618 - *(u32 *)&value = *(u32 *)args; \
85619 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85620 + *(u32 *)&value = *(const u32 *)args; \
85621 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85622 } else { \
85623 args = PTR_ALIGN(args, sizeof(type)); \
85624 - value = *(typeof(type) *)args; \
85625 + value = *(const typeof(type) *)args; \
85626 } \
85627 args += sizeof(type); \
85628 value; \
85629 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85630 case FORMAT_TYPE_STR: {
85631 const char *str_arg = args;
85632 args += strlen(str_arg) + 1;
85633 - str = string(str, end, (char *)str_arg, spec);
85634 + str = string(str, end, str_arg, spec);
85635 break;
85636 }
85637
85638 diff --git a/localversion-grsec b/localversion-grsec
85639 new file mode 100644
85640 index 0000000..7cd6065
85641 --- /dev/null
85642 +++ b/localversion-grsec
85643 @@ -0,0 +1 @@
85644 +-grsec
85645 diff --git a/mm/Kconfig b/mm/Kconfig
85646 index 6509d27..dbec5b8 100644
85647 --- a/mm/Kconfig
85648 +++ b/mm/Kconfig
85649 @@ -317,10 +317,10 @@ config KSM
85650 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
85651
85652 config DEFAULT_MMAP_MIN_ADDR
85653 - int "Low address space to protect from user allocation"
85654 + int "Low address space to protect from user allocation"
85655 depends on MMU
85656 - default 4096
85657 - help
85658 + default 65536
85659 + help
85660 This is the portion of low virtual memory which should be protected
85661 from userspace allocation. Keeping a user from writing to low pages
85662 can help reduce the impact of kernel NULL pointer bugs.
85663 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
85664
85665 config HWPOISON_INJECT
85666 tristate "HWPoison pages injector"
85667 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
85668 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
85669 select PROC_PAGE_MONITOR
85670
85671 config NOMMU_INITIAL_TRIM_EXCESS
85672 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
85673 index e04454c..ca5be3e 100644
85674 --- a/mm/backing-dev.c
85675 +++ b/mm/backing-dev.c
85676 @@ -12,7 +12,7 @@
85677 #include <linux/device.h>
85678 #include <trace/events/writeback.h>
85679
85680 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
85681 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
85682
85683 struct backing_dev_info default_backing_dev_info = {
85684 .name = "default",
85685 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
85686 return err;
85687
85688 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
85689 - atomic_long_inc_return(&bdi_seq));
85690 + atomic_long_inc_return_unchecked(&bdi_seq));
85691 if (err) {
85692 bdi_destroy(bdi);
85693 return err;
85694 diff --git a/mm/filemap.c b/mm/filemap.c
85695 index 4b51ac1..5aa90ff 100644
85696 --- a/mm/filemap.c
85697 +++ b/mm/filemap.c
85698 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
85699 struct address_space *mapping = file->f_mapping;
85700
85701 if (!mapping->a_ops->readpage)
85702 - return -ENOEXEC;
85703 + return -ENODEV;
85704 file_accessed(file);
85705 vma->vm_ops = &generic_file_vm_ops;
85706 return 0;
85707 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
85708
85709 while (bytes) {
85710 char __user *buf = iov->iov_base + base;
85711 - int copy = min(bytes, iov->iov_len - base);
85712 + size_t copy = min(bytes, iov->iov_len - base);
85713
85714 base = 0;
85715 left = __copy_from_user_inatomic(vaddr, buf, copy);
85716 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
85717 BUG_ON(!in_atomic());
85718 kaddr = kmap_atomic(page);
85719 if (likely(i->nr_segs == 1)) {
85720 - int left;
85721 + size_t left;
85722 char __user *buf = i->iov->iov_base + i->iov_offset;
85723 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
85724 copied = bytes - left;
85725 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
85726
85727 kaddr = kmap(page);
85728 if (likely(i->nr_segs == 1)) {
85729 - int left;
85730 + size_t left;
85731 char __user *buf = i->iov->iov_base + i->iov_offset;
85732 left = __copy_from_user(kaddr + offset, buf, bytes);
85733 copied = bytes - left;
85734 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
85735 * zero-length segments (without overruning the iovec).
85736 */
85737 while (bytes || unlikely(i->count && !iov->iov_len)) {
85738 - int copy;
85739 + size_t copy;
85740
85741 copy = min(bytes, iov->iov_len - base);
85742 BUG_ON(!i->count || i->count < copy);
85743 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
85744 *pos = i_size_read(inode);
85745
85746 if (limit != RLIM_INFINITY) {
85747 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
85748 if (*pos >= limit) {
85749 send_sig(SIGXFSZ, current, 0);
85750 return -EFBIG;
85751 diff --git a/mm/fremap.c b/mm/fremap.c
85752 index 5bff081..d8189a9 100644
85753 --- a/mm/fremap.c
85754 +++ b/mm/fremap.c
85755 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
85756 retry:
85757 vma = find_vma(mm, start);
85758
85759 +#ifdef CONFIG_PAX_SEGMEXEC
85760 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
85761 + goto out;
85762 +#endif
85763 +
85764 /*
85765 * Make sure the vma is shared, that it supports prefaulting,
85766 * and that the remapped range is valid and fully within
85767 diff --git a/mm/highmem.c b/mm/highmem.c
85768 index b32b70c..e512eb0 100644
85769 --- a/mm/highmem.c
85770 +++ b/mm/highmem.c
85771 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
85772 * So no dangers, even with speculative execution.
85773 */
85774 page = pte_page(pkmap_page_table[i]);
85775 + pax_open_kernel();
85776 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
85777 -
85778 + pax_close_kernel();
85779 set_page_address(page, NULL);
85780 need_flush = 1;
85781 }
85782 @@ -198,9 +199,11 @@ start:
85783 }
85784 }
85785 vaddr = PKMAP_ADDR(last_pkmap_nr);
85786 +
85787 + pax_open_kernel();
85788 set_pte_at(&init_mm, vaddr,
85789 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
85790 -
85791 + pax_close_kernel();
85792 pkmap_count[last_pkmap_nr] = 1;
85793 set_page_address(page, (void *)vaddr);
85794
85795 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
85796 index b60f330..ee7de7e 100644
85797 --- a/mm/hugetlb.c
85798 +++ b/mm/hugetlb.c
85799 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
85800 struct hstate *h = &default_hstate;
85801 unsigned long tmp;
85802 int ret;
85803 + ctl_table_no_const hugetlb_table;
85804
85805 tmp = h->max_huge_pages;
85806
85807 if (write && h->order >= MAX_ORDER)
85808 return -EINVAL;
85809
85810 - table->data = &tmp;
85811 - table->maxlen = sizeof(unsigned long);
85812 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
85813 + hugetlb_table = *table;
85814 + hugetlb_table.data = &tmp;
85815 + hugetlb_table.maxlen = sizeof(unsigned long);
85816 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
85817 if (ret)
85818 goto out;
85819
85820 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
85821 struct hstate *h = &default_hstate;
85822 unsigned long tmp;
85823 int ret;
85824 + ctl_table_no_const hugetlb_table;
85825
85826 tmp = h->nr_overcommit_huge_pages;
85827
85828 if (write && h->order >= MAX_ORDER)
85829 return -EINVAL;
85830
85831 - table->data = &tmp;
85832 - table->maxlen = sizeof(unsigned long);
85833 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
85834 + hugetlb_table = *table;
85835 + hugetlb_table.data = &tmp;
85836 + hugetlb_table.maxlen = sizeof(unsigned long);
85837 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
85838 if (ret)
85839 goto out;
85840
85841 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
85842 return 1;
85843 }
85844
85845 +#ifdef CONFIG_PAX_SEGMEXEC
85846 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
85847 +{
85848 + struct mm_struct *mm = vma->vm_mm;
85849 + struct vm_area_struct *vma_m;
85850 + unsigned long address_m;
85851 + pte_t *ptep_m;
85852 +
85853 + vma_m = pax_find_mirror_vma(vma);
85854 + if (!vma_m)
85855 + return;
85856 +
85857 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
85858 + address_m = address + SEGMEXEC_TASK_SIZE;
85859 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
85860 + get_page(page_m);
85861 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
85862 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
85863 +}
85864 +#endif
85865 +
85866 /*
85867 * Hugetlb_cow() should be called with page lock of the original hugepage held.
85868 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
85869 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
85870 make_huge_pte(vma, new_page, 1));
85871 page_remove_rmap(old_page);
85872 hugepage_add_new_anon_rmap(new_page, vma, address);
85873 +
85874 +#ifdef CONFIG_PAX_SEGMEXEC
85875 + pax_mirror_huge_pte(vma, address, new_page);
85876 +#endif
85877 +
85878 /* Make the old page be freed below */
85879 new_page = old_page;
85880 }
85881 @@ -2821,6 +2851,10 @@ retry:
85882 && (vma->vm_flags & VM_SHARED)));
85883 set_huge_pte_at(mm, address, ptep, new_pte);
85884
85885 +#ifdef CONFIG_PAX_SEGMEXEC
85886 + pax_mirror_huge_pte(vma, address, page);
85887 +#endif
85888 +
85889 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
85890 /* Optimization, do the COW without a second fault */
85891 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
85892 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85893 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
85894 struct hstate *h = hstate_vma(vma);
85895
85896 +#ifdef CONFIG_PAX_SEGMEXEC
85897 + struct vm_area_struct *vma_m;
85898 +#endif
85899 +
85900 address &= huge_page_mask(h);
85901
85902 ptep = huge_pte_offset(mm, address);
85903 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85904 VM_FAULT_SET_HINDEX(hstate_index(h));
85905 }
85906
85907 +#ifdef CONFIG_PAX_SEGMEXEC
85908 + vma_m = pax_find_mirror_vma(vma);
85909 + if (vma_m) {
85910 + unsigned long address_m;
85911 +
85912 + if (vma->vm_start > vma_m->vm_start) {
85913 + address_m = address;
85914 + address -= SEGMEXEC_TASK_SIZE;
85915 + vma = vma_m;
85916 + h = hstate_vma(vma);
85917 + } else
85918 + address_m = address + SEGMEXEC_TASK_SIZE;
85919 +
85920 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
85921 + return VM_FAULT_OOM;
85922 + address_m &= HPAGE_MASK;
85923 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
85924 + }
85925 +#endif
85926 +
85927 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
85928 if (!ptep)
85929 return VM_FAULT_OOM;
85930 diff --git a/mm/internal.h b/mm/internal.h
85931 index 4390ac6..fc60373c 100644
85932 --- a/mm/internal.h
85933 +++ b/mm/internal.h
85934 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
85935 * in mm/page_alloc.c
85936 */
85937 extern void __free_pages_bootmem(struct page *page, unsigned int order);
85938 +extern void free_compound_page(struct page *page);
85939 extern void prep_compound_page(struct page *page, unsigned long order);
85940 #ifdef CONFIG_MEMORY_FAILURE
85941 extern bool is_free_buddy_page(struct page *page);
85942 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
85943
85944 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
85945 unsigned long, unsigned long,
85946 - unsigned long, unsigned long);
85947 + unsigned long, unsigned long) __intentional_overflow(-1);
85948
85949 extern void set_pageblock_order(void);
85950 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
85951 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
85952 index c8d7f31..2dbeffd 100644
85953 --- a/mm/kmemleak.c
85954 +++ b/mm/kmemleak.c
85955 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
85956
85957 for (i = 0; i < object->trace_len; i++) {
85958 void *ptr = (void *)object->trace[i];
85959 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
85960 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
85961 }
85962 }
85963
85964 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
85965 return -ENOMEM;
85966 }
85967
85968 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
85969 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
85970 &kmemleak_fops);
85971 if (!dentry)
85972 pr_warning("Failed to create the debugfs kmemleak file\n");
85973 diff --git a/mm/maccess.c b/mm/maccess.c
85974 index d53adf9..03a24bf 100644
85975 --- a/mm/maccess.c
85976 +++ b/mm/maccess.c
85977 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
85978 set_fs(KERNEL_DS);
85979 pagefault_disable();
85980 ret = __copy_from_user_inatomic(dst,
85981 - (__force const void __user *)src, size);
85982 + (const void __force_user *)src, size);
85983 pagefault_enable();
85984 set_fs(old_fs);
85985
85986 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
85987
85988 set_fs(KERNEL_DS);
85989 pagefault_disable();
85990 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
85991 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
85992 pagefault_enable();
85993 set_fs(old_fs);
85994
85995 diff --git a/mm/madvise.c b/mm/madvise.c
85996 index 7055883..aafb1ed 100644
85997 --- a/mm/madvise.c
85998 +++ b/mm/madvise.c
85999 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86000 pgoff_t pgoff;
86001 unsigned long new_flags = vma->vm_flags;
86002
86003 +#ifdef CONFIG_PAX_SEGMEXEC
86004 + struct vm_area_struct *vma_m;
86005 +#endif
86006 +
86007 switch (behavior) {
86008 case MADV_NORMAL:
86009 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86010 @@ -126,6 +130,13 @@ success:
86011 /*
86012 * vm_flags is protected by the mmap_sem held in write mode.
86013 */
86014 +
86015 +#ifdef CONFIG_PAX_SEGMEXEC
86016 + vma_m = pax_find_mirror_vma(vma);
86017 + if (vma_m)
86018 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86019 +#endif
86020 +
86021 vma->vm_flags = new_flags;
86022
86023 out:
86024 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86025 struct vm_area_struct ** prev,
86026 unsigned long start, unsigned long end)
86027 {
86028 +
86029 +#ifdef CONFIG_PAX_SEGMEXEC
86030 + struct vm_area_struct *vma_m;
86031 +#endif
86032 +
86033 *prev = vma;
86034 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86035 return -EINVAL;
86036 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86037 zap_page_range(vma, start, end - start, &details);
86038 } else
86039 zap_page_range(vma, start, end - start, NULL);
86040 +
86041 +#ifdef CONFIG_PAX_SEGMEXEC
86042 + vma_m = pax_find_mirror_vma(vma);
86043 + if (vma_m) {
86044 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86045 + struct zap_details details = {
86046 + .nonlinear_vma = vma_m,
86047 + .last_index = ULONG_MAX,
86048 + };
86049 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86050 + } else
86051 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86052 + }
86053 +#endif
86054 +
86055 return 0;
86056 }
86057
86058 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86059 if (end < start)
86060 return error;
86061
86062 +#ifdef CONFIG_PAX_SEGMEXEC
86063 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86064 + if (end > SEGMEXEC_TASK_SIZE)
86065 + return error;
86066 + } else
86067 +#endif
86068 +
86069 + if (end > TASK_SIZE)
86070 + return error;
86071 +
86072 error = 0;
86073 if (end == start)
86074 return error;
86075 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86076 index 2c13aa7..64cbc3f 100644
86077 --- a/mm/memory-failure.c
86078 +++ b/mm/memory-failure.c
86079 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86080
86081 int sysctl_memory_failure_recovery __read_mostly = 1;
86082
86083 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86084 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86085
86086 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86087
86088 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86089 pfn, t->comm, t->pid);
86090 si.si_signo = SIGBUS;
86091 si.si_errno = 0;
86092 - si.si_addr = (void *)addr;
86093 + si.si_addr = (void __user *)addr;
86094 #ifdef __ARCH_SI_TRAPNO
86095 si.si_trapno = trapno;
86096 #endif
86097 @@ -760,7 +760,7 @@ static struct page_state {
86098 unsigned long res;
86099 char *msg;
86100 int (*action)(struct page *p, unsigned long pfn);
86101 -} error_states[] = {
86102 +} __do_const error_states[] = {
86103 { reserved, reserved, "reserved kernel", me_kernel },
86104 /*
86105 * free pages are specially detected outside this table:
86106 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86107 nr_pages = 1 << compound_order(hpage);
86108 else /* normal page or thp */
86109 nr_pages = 1;
86110 - atomic_long_add(nr_pages, &num_poisoned_pages);
86111 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86112
86113 /*
86114 * We need/can do nothing about count=0 pages.
86115 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86116 if (!PageHWPoison(hpage)
86117 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86118 || (p != hpage && TestSetPageHWPoison(hpage))) {
86119 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86120 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86121 return 0;
86122 }
86123 set_page_hwpoison_huge_page(hpage);
86124 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86125 }
86126 if (hwpoison_filter(p)) {
86127 if (TestClearPageHWPoison(p))
86128 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86129 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86130 unlock_page(hpage);
86131 put_page(hpage);
86132 return 0;
86133 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86134 return 0;
86135 }
86136 if (TestClearPageHWPoison(p))
86137 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86138 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86139 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86140 return 0;
86141 }
86142 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86143 */
86144 if (TestClearPageHWPoison(page)) {
86145 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86146 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86147 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86148 freeit = 1;
86149 if (PageHuge(page))
86150 clear_page_hwpoison_huge_page(page);
86151 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86152 } else {
86153 set_page_hwpoison_huge_page(hpage);
86154 dequeue_hwpoisoned_huge_page(hpage);
86155 - atomic_long_add(1 << compound_trans_order(hpage),
86156 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86157 &num_poisoned_pages);
86158 }
86159 return ret;
86160 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86161 if (PageHuge(page)) {
86162 set_page_hwpoison_huge_page(hpage);
86163 dequeue_hwpoisoned_huge_page(hpage);
86164 - atomic_long_add(1 << compound_trans_order(hpage),
86165 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86166 &num_poisoned_pages);
86167 } else {
86168 SetPageHWPoison(page);
86169 - atomic_long_inc(&num_poisoned_pages);
86170 + atomic_long_inc_unchecked(&num_poisoned_pages);
86171 }
86172 }
86173 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86174 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86175 put_page(page);
86176 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86177 SetPageHWPoison(page);
86178 - atomic_long_inc(&num_poisoned_pages);
86179 + atomic_long_inc_unchecked(&num_poisoned_pages);
86180 return 0;
86181 }
86182
86183 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86184 if (!is_free_buddy_page(page))
86185 pr_info("soft offline: %#lx: page leaked\n",
86186 pfn);
86187 - atomic_long_inc(&num_poisoned_pages);
86188 + atomic_long_inc_unchecked(&num_poisoned_pages);
86189 }
86190 } else {
86191 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86192 diff --git a/mm/memory.c b/mm/memory.c
86193 index af84bc0..2ed0816 100644
86194 --- a/mm/memory.c
86195 +++ b/mm/memory.c
86196 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86197 free_pte_range(tlb, pmd, addr);
86198 } while (pmd++, addr = next, addr != end);
86199
86200 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86201 start &= PUD_MASK;
86202 if (start < floor)
86203 return;
86204 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86205 pmd = pmd_offset(pud, start);
86206 pud_clear(pud);
86207 pmd_free_tlb(tlb, pmd, start);
86208 +#endif
86209 +
86210 }
86211
86212 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86213 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86214 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86215 } while (pud++, addr = next, addr != end);
86216
86217 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86218 start &= PGDIR_MASK;
86219 if (start < floor)
86220 return;
86221 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86222 pud = pud_offset(pgd, start);
86223 pgd_clear(pgd);
86224 pud_free_tlb(tlb, pud, start);
86225 +#endif
86226 +
86227 }
86228
86229 /*
86230 @@ -1645,12 +1651,6 @@ no_page_table:
86231 return page;
86232 }
86233
86234 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86235 -{
86236 - return stack_guard_page_start(vma, addr) ||
86237 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86238 -}
86239 -
86240 /**
86241 * __get_user_pages() - pin user pages in memory
86242 * @tsk: task_struct of target task
86243 @@ -1737,10 +1737,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86244
86245 i = 0;
86246
86247 - do {
86248 + while (nr_pages) {
86249 struct vm_area_struct *vma;
86250
86251 - vma = find_extend_vma(mm, start);
86252 + vma = find_vma(mm, start);
86253 if (!vma && in_gate_area(mm, start)) {
86254 unsigned long pg = start & PAGE_MASK;
86255 pgd_t *pgd;
86256 @@ -1789,7 +1789,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86257 goto next_page;
86258 }
86259
86260 - if (!vma ||
86261 + if (!vma || start < vma->vm_start ||
86262 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86263 !(vm_flags & vma->vm_flags))
86264 return i ? : -EFAULT;
86265 @@ -1818,11 +1818,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86266 int ret;
86267 unsigned int fault_flags = 0;
86268
86269 - /* For mlock, just skip the stack guard page. */
86270 - if (foll_flags & FOLL_MLOCK) {
86271 - if (stack_guard_page(vma, start))
86272 - goto next_page;
86273 - }
86274 if (foll_flags & FOLL_WRITE)
86275 fault_flags |= FAULT_FLAG_WRITE;
86276 if (nonblocking)
86277 @@ -1902,7 +1897,7 @@ next_page:
86278 start += page_increm * PAGE_SIZE;
86279 nr_pages -= page_increm;
86280 } while (nr_pages && start < vma->vm_end);
86281 - } while (nr_pages);
86282 + }
86283 return i;
86284 }
86285 EXPORT_SYMBOL(__get_user_pages);
86286 @@ -2109,6 +2104,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86287 page_add_file_rmap(page);
86288 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86289
86290 +#ifdef CONFIG_PAX_SEGMEXEC
86291 + pax_mirror_file_pte(vma, addr, page, ptl);
86292 +#endif
86293 +
86294 retval = 0;
86295 pte_unmap_unlock(pte, ptl);
86296 return retval;
86297 @@ -2153,9 +2152,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86298 if (!page_count(page))
86299 return -EINVAL;
86300 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86301 +
86302 +#ifdef CONFIG_PAX_SEGMEXEC
86303 + struct vm_area_struct *vma_m;
86304 +#endif
86305 +
86306 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86307 BUG_ON(vma->vm_flags & VM_PFNMAP);
86308 vma->vm_flags |= VM_MIXEDMAP;
86309 +
86310 +#ifdef CONFIG_PAX_SEGMEXEC
86311 + vma_m = pax_find_mirror_vma(vma);
86312 + if (vma_m)
86313 + vma_m->vm_flags |= VM_MIXEDMAP;
86314 +#endif
86315 +
86316 }
86317 return insert_page(vma, addr, page, vma->vm_page_prot);
86318 }
86319 @@ -2238,6 +2249,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86320 unsigned long pfn)
86321 {
86322 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86323 + BUG_ON(vma->vm_mirror);
86324
86325 if (addr < vma->vm_start || addr >= vma->vm_end)
86326 return -EFAULT;
86327 @@ -2485,7 +2497,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86328
86329 BUG_ON(pud_huge(*pud));
86330
86331 - pmd = pmd_alloc(mm, pud, addr);
86332 + pmd = (mm == &init_mm) ?
86333 + pmd_alloc_kernel(mm, pud, addr) :
86334 + pmd_alloc(mm, pud, addr);
86335 if (!pmd)
86336 return -ENOMEM;
86337 do {
86338 @@ -2505,7 +2519,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86339 unsigned long next;
86340 int err;
86341
86342 - pud = pud_alloc(mm, pgd, addr);
86343 + pud = (mm == &init_mm) ?
86344 + pud_alloc_kernel(mm, pgd, addr) :
86345 + pud_alloc(mm, pgd, addr);
86346 if (!pud)
86347 return -ENOMEM;
86348 do {
86349 @@ -2593,6 +2609,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86350 copy_user_highpage(dst, src, va, vma);
86351 }
86352
86353 +#ifdef CONFIG_PAX_SEGMEXEC
86354 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86355 +{
86356 + struct mm_struct *mm = vma->vm_mm;
86357 + spinlock_t *ptl;
86358 + pte_t *pte, entry;
86359 +
86360 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86361 + entry = *pte;
86362 + if (!pte_present(entry)) {
86363 + if (!pte_none(entry)) {
86364 + BUG_ON(pte_file(entry));
86365 + free_swap_and_cache(pte_to_swp_entry(entry));
86366 + pte_clear_not_present_full(mm, address, pte, 0);
86367 + }
86368 + } else {
86369 + struct page *page;
86370 +
86371 + flush_cache_page(vma, address, pte_pfn(entry));
86372 + entry = ptep_clear_flush(vma, address, pte);
86373 + BUG_ON(pte_dirty(entry));
86374 + page = vm_normal_page(vma, address, entry);
86375 + if (page) {
86376 + update_hiwater_rss(mm);
86377 + if (PageAnon(page))
86378 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86379 + else
86380 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86381 + page_remove_rmap(page);
86382 + page_cache_release(page);
86383 + }
86384 + }
86385 + pte_unmap_unlock(pte, ptl);
86386 +}
86387 +
86388 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86389 + *
86390 + * the ptl of the lower mapped page is held on entry and is not released on exit
86391 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86392 + */
86393 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86394 +{
86395 + struct mm_struct *mm = vma->vm_mm;
86396 + unsigned long address_m;
86397 + spinlock_t *ptl_m;
86398 + struct vm_area_struct *vma_m;
86399 + pmd_t *pmd_m;
86400 + pte_t *pte_m, entry_m;
86401 +
86402 + BUG_ON(!page_m || !PageAnon(page_m));
86403 +
86404 + vma_m = pax_find_mirror_vma(vma);
86405 + if (!vma_m)
86406 + return;
86407 +
86408 + BUG_ON(!PageLocked(page_m));
86409 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86410 + address_m = address + SEGMEXEC_TASK_SIZE;
86411 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86412 + pte_m = pte_offset_map(pmd_m, address_m);
86413 + ptl_m = pte_lockptr(mm, pmd_m);
86414 + if (ptl != ptl_m) {
86415 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86416 + if (!pte_none(*pte_m))
86417 + goto out;
86418 + }
86419 +
86420 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86421 + page_cache_get(page_m);
86422 + page_add_anon_rmap(page_m, vma_m, address_m);
86423 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86424 + set_pte_at(mm, address_m, pte_m, entry_m);
86425 + update_mmu_cache(vma_m, address_m, pte_m);
86426 +out:
86427 + if (ptl != ptl_m)
86428 + spin_unlock(ptl_m);
86429 + pte_unmap(pte_m);
86430 + unlock_page(page_m);
86431 +}
86432 +
86433 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86434 +{
86435 + struct mm_struct *mm = vma->vm_mm;
86436 + unsigned long address_m;
86437 + spinlock_t *ptl_m;
86438 + struct vm_area_struct *vma_m;
86439 + pmd_t *pmd_m;
86440 + pte_t *pte_m, entry_m;
86441 +
86442 + BUG_ON(!page_m || PageAnon(page_m));
86443 +
86444 + vma_m = pax_find_mirror_vma(vma);
86445 + if (!vma_m)
86446 + return;
86447 +
86448 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86449 + address_m = address + SEGMEXEC_TASK_SIZE;
86450 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86451 + pte_m = pte_offset_map(pmd_m, address_m);
86452 + ptl_m = pte_lockptr(mm, pmd_m);
86453 + if (ptl != ptl_m) {
86454 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86455 + if (!pte_none(*pte_m))
86456 + goto out;
86457 + }
86458 +
86459 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86460 + page_cache_get(page_m);
86461 + page_add_file_rmap(page_m);
86462 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86463 + set_pte_at(mm, address_m, pte_m, entry_m);
86464 + update_mmu_cache(vma_m, address_m, pte_m);
86465 +out:
86466 + if (ptl != ptl_m)
86467 + spin_unlock(ptl_m);
86468 + pte_unmap(pte_m);
86469 +}
86470 +
86471 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86472 +{
86473 + struct mm_struct *mm = vma->vm_mm;
86474 + unsigned long address_m;
86475 + spinlock_t *ptl_m;
86476 + struct vm_area_struct *vma_m;
86477 + pmd_t *pmd_m;
86478 + pte_t *pte_m, entry_m;
86479 +
86480 + vma_m = pax_find_mirror_vma(vma);
86481 + if (!vma_m)
86482 + return;
86483 +
86484 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86485 + address_m = address + SEGMEXEC_TASK_SIZE;
86486 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86487 + pte_m = pte_offset_map(pmd_m, address_m);
86488 + ptl_m = pte_lockptr(mm, pmd_m);
86489 + if (ptl != ptl_m) {
86490 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86491 + if (!pte_none(*pte_m))
86492 + goto out;
86493 + }
86494 +
86495 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86496 + set_pte_at(mm, address_m, pte_m, entry_m);
86497 +out:
86498 + if (ptl != ptl_m)
86499 + spin_unlock(ptl_m);
86500 + pte_unmap(pte_m);
86501 +}
86502 +
86503 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86504 +{
86505 + struct page *page_m;
86506 + pte_t entry;
86507 +
86508 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86509 + goto out;
86510 +
86511 + entry = *pte;
86512 + page_m = vm_normal_page(vma, address, entry);
86513 + if (!page_m)
86514 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86515 + else if (PageAnon(page_m)) {
86516 + if (pax_find_mirror_vma(vma)) {
86517 + pte_unmap_unlock(pte, ptl);
86518 + lock_page(page_m);
86519 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86520 + if (pte_same(entry, *pte))
86521 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86522 + else
86523 + unlock_page(page_m);
86524 + }
86525 + } else
86526 + pax_mirror_file_pte(vma, address, page_m, ptl);
86527 +
86528 +out:
86529 + pte_unmap_unlock(pte, ptl);
86530 +}
86531 +#endif
86532 +
86533 /*
86534 * This routine handles present pages, when users try to write
86535 * to a shared page. It is done by copying the page to a new address
86536 @@ -2809,6 +3005,12 @@ gotten:
86537 */
86538 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86539 if (likely(pte_same(*page_table, orig_pte))) {
86540 +
86541 +#ifdef CONFIG_PAX_SEGMEXEC
86542 + if (pax_find_mirror_vma(vma))
86543 + BUG_ON(!trylock_page(new_page));
86544 +#endif
86545 +
86546 if (old_page) {
86547 if (!PageAnon(old_page)) {
86548 dec_mm_counter_fast(mm, MM_FILEPAGES);
86549 @@ -2860,6 +3062,10 @@ gotten:
86550 page_remove_rmap(old_page);
86551 }
86552
86553 +#ifdef CONFIG_PAX_SEGMEXEC
86554 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86555 +#endif
86556 +
86557 /* Free the old page.. */
86558 new_page = old_page;
86559 ret |= VM_FAULT_WRITE;
86560 @@ -3137,6 +3343,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86561 swap_free(entry);
86562 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86563 try_to_free_swap(page);
86564 +
86565 +#ifdef CONFIG_PAX_SEGMEXEC
86566 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86567 +#endif
86568 +
86569 unlock_page(page);
86570 if (page != swapcache) {
86571 /*
86572 @@ -3160,6 +3371,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86573
86574 /* No need to invalidate - it was non-present before */
86575 update_mmu_cache(vma, address, page_table);
86576 +
86577 +#ifdef CONFIG_PAX_SEGMEXEC
86578 + pax_mirror_anon_pte(vma, address, page, ptl);
86579 +#endif
86580 +
86581 unlock:
86582 pte_unmap_unlock(page_table, ptl);
86583 out:
86584 @@ -3179,40 +3395,6 @@ out_release:
86585 }
86586
86587 /*
86588 - * This is like a special single-page "expand_{down|up}wards()",
86589 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86590 - * doesn't hit another vma.
86591 - */
86592 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86593 -{
86594 - address &= PAGE_MASK;
86595 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86596 - struct vm_area_struct *prev = vma->vm_prev;
86597 -
86598 - /*
86599 - * Is there a mapping abutting this one below?
86600 - *
86601 - * That's only ok if it's the same stack mapping
86602 - * that has gotten split..
86603 - */
86604 - if (prev && prev->vm_end == address)
86605 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86606 -
86607 - expand_downwards(vma, address - PAGE_SIZE);
86608 - }
86609 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86610 - struct vm_area_struct *next = vma->vm_next;
86611 -
86612 - /* As VM_GROWSDOWN but s/below/above/ */
86613 - if (next && next->vm_start == address + PAGE_SIZE)
86614 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86615 -
86616 - expand_upwards(vma, address + PAGE_SIZE);
86617 - }
86618 - return 0;
86619 -}
86620 -
86621 -/*
86622 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86623 * but allow concurrent faults), and pte mapped but not yet locked.
86624 * We return with mmap_sem still held, but pte unmapped and unlocked.
86625 @@ -3221,27 +3403,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86626 unsigned long address, pte_t *page_table, pmd_t *pmd,
86627 unsigned int flags)
86628 {
86629 - struct page *page;
86630 + struct page *page = NULL;
86631 spinlock_t *ptl;
86632 pte_t entry;
86633
86634 - pte_unmap(page_table);
86635 -
86636 - /* Check if we need to add a guard page to the stack */
86637 - if (check_stack_guard_page(vma, address) < 0)
86638 - return VM_FAULT_SIGBUS;
86639 -
86640 - /* Use the zero-page for reads */
86641 if (!(flags & FAULT_FLAG_WRITE)) {
86642 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
86643 vma->vm_page_prot));
86644 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86645 + ptl = pte_lockptr(mm, pmd);
86646 + spin_lock(ptl);
86647 if (!pte_none(*page_table))
86648 goto unlock;
86649 goto setpte;
86650 }
86651
86652 /* Allocate our own private page. */
86653 + pte_unmap(page_table);
86654 +
86655 if (unlikely(anon_vma_prepare(vma)))
86656 goto oom;
86657 page = alloc_zeroed_user_highpage_movable(vma, address);
86658 @@ -3265,6 +3443,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86659 if (!pte_none(*page_table))
86660 goto release;
86661
86662 +#ifdef CONFIG_PAX_SEGMEXEC
86663 + if (pax_find_mirror_vma(vma))
86664 + BUG_ON(!trylock_page(page));
86665 +#endif
86666 +
86667 inc_mm_counter_fast(mm, MM_ANONPAGES);
86668 page_add_new_anon_rmap(page, vma, address);
86669 setpte:
86670 @@ -3272,6 +3455,12 @@ setpte:
86671
86672 /* No need to invalidate - it was non-present before */
86673 update_mmu_cache(vma, address, page_table);
86674 +
86675 +#ifdef CONFIG_PAX_SEGMEXEC
86676 + if (page)
86677 + pax_mirror_anon_pte(vma, address, page, ptl);
86678 +#endif
86679 +
86680 unlock:
86681 pte_unmap_unlock(page_table, ptl);
86682 return 0;
86683 @@ -3415,6 +3604,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86684 */
86685 /* Only go through if we didn't race with anybody else... */
86686 if (likely(pte_same(*page_table, orig_pte))) {
86687 +
86688 +#ifdef CONFIG_PAX_SEGMEXEC
86689 + if (anon && pax_find_mirror_vma(vma))
86690 + BUG_ON(!trylock_page(page));
86691 +#endif
86692 +
86693 flush_icache_page(vma, page);
86694 entry = mk_pte(page, vma->vm_page_prot);
86695 if (flags & FAULT_FLAG_WRITE)
86696 @@ -3436,6 +3631,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86697
86698 /* no need to invalidate: a not-present page won't be cached */
86699 update_mmu_cache(vma, address, page_table);
86700 +
86701 +#ifdef CONFIG_PAX_SEGMEXEC
86702 + if (anon)
86703 + pax_mirror_anon_pte(vma, address, page, ptl);
86704 + else
86705 + pax_mirror_file_pte(vma, address, page, ptl);
86706 +#endif
86707 +
86708 } else {
86709 if (cow_page)
86710 mem_cgroup_uncharge_page(cow_page);
86711 @@ -3757,6 +3960,12 @@ int handle_pte_fault(struct mm_struct *mm,
86712 if (flags & FAULT_FLAG_WRITE)
86713 flush_tlb_fix_spurious_fault(vma, address);
86714 }
86715 +
86716 +#ifdef CONFIG_PAX_SEGMEXEC
86717 + pax_mirror_pte(vma, address, pte, pmd, ptl);
86718 + return 0;
86719 +#endif
86720 +
86721 unlock:
86722 pte_unmap_unlock(pte, ptl);
86723 return 0;
86724 @@ -3773,6 +3982,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86725 pmd_t *pmd;
86726 pte_t *pte;
86727
86728 +#ifdef CONFIG_PAX_SEGMEXEC
86729 + struct vm_area_struct *vma_m;
86730 +#endif
86731 +
86732 __set_current_state(TASK_RUNNING);
86733
86734 count_vm_event(PGFAULT);
86735 @@ -3784,6 +3997,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86736 if (unlikely(is_vm_hugetlb_page(vma)))
86737 return hugetlb_fault(mm, vma, address, flags);
86738
86739 +#ifdef CONFIG_PAX_SEGMEXEC
86740 + vma_m = pax_find_mirror_vma(vma);
86741 + if (vma_m) {
86742 + unsigned long address_m;
86743 + pgd_t *pgd_m;
86744 + pud_t *pud_m;
86745 + pmd_t *pmd_m;
86746 +
86747 + if (vma->vm_start > vma_m->vm_start) {
86748 + address_m = address;
86749 + address -= SEGMEXEC_TASK_SIZE;
86750 + vma = vma_m;
86751 + } else
86752 + address_m = address + SEGMEXEC_TASK_SIZE;
86753 +
86754 + pgd_m = pgd_offset(mm, address_m);
86755 + pud_m = pud_alloc(mm, pgd_m, address_m);
86756 + if (!pud_m)
86757 + return VM_FAULT_OOM;
86758 + pmd_m = pmd_alloc(mm, pud_m, address_m);
86759 + if (!pmd_m)
86760 + return VM_FAULT_OOM;
86761 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
86762 + return VM_FAULT_OOM;
86763 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
86764 + }
86765 +#endif
86766 +
86767 retry:
86768 pgd = pgd_offset(mm, address);
86769 pud = pud_alloc(mm, pgd, address);
86770 @@ -3882,6 +4123,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
86771 spin_unlock(&mm->page_table_lock);
86772 return 0;
86773 }
86774 +
86775 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
86776 +{
86777 + pud_t *new = pud_alloc_one(mm, address);
86778 + if (!new)
86779 + return -ENOMEM;
86780 +
86781 + smp_wmb(); /* See comment in __pte_alloc */
86782 +
86783 + spin_lock(&mm->page_table_lock);
86784 + if (pgd_present(*pgd)) /* Another has populated it */
86785 + pud_free(mm, new);
86786 + else
86787 + pgd_populate_kernel(mm, pgd, new);
86788 + spin_unlock(&mm->page_table_lock);
86789 + return 0;
86790 +}
86791 #endif /* __PAGETABLE_PUD_FOLDED */
86792
86793 #ifndef __PAGETABLE_PMD_FOLDED
86794 @@ -3912,6 +4170,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
86795 spin_unlock(&mm->page_table_lock);
86796 return 0;
86797 }
86798 +
86799 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
86800 +{
86801 + pmd_t *new = pmd_alloc_one(mm, address);
86802 + if (!new)
86803 + return -ENOMEM;
86804 +
86805 + smp_wmb(); /* See comment in __pte_alloc */
86806 +
86807 + spin_lock(&mm->page_table_lock);
86808 +#ifndef __ARCH_HAS_4LEVEL_HACK
86809 + if (pud_present(*pud)) /* Another has populated it */
86810 + pmd_free(mm, new);
86811 + else
86812 + pud_populate_kernel(mm, pud, new);
86813 +#else
86814 + if (pgd_present(*pud)) /* Another has populated it */
86815 + pmd_free(mm, new);
86816 + else
86817 + pgd_populate_kernel(mm, pud, new);
86818 +#endif /* __ARCH_HAS_4LEVEL_HACK */
86819 + spin_unlock(&mm->page_table_lock);
86820 + return 0;
86821 +}
86822 #endif /* __PAGETABLE_PMD_FOLDED */
86823
86824 #if !defined(__HAVE_ARCH_GATE_AREA)
86825 @@ -3925,7 +4207,7 @@ static int __init gate_vma_init(void)
86826 gate_vma.vm_start = FIXADDR_USER_START;
86827 gate_vma.vm_end = FIXADDR_USER_END;
86828 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
86829 - gate_vma.vm_page_prot = __P101;
86830 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
86831
86832 return 0;
86833 }
86834 @@ -4059,8 +4341,8 @@ out:
86835 return ret;
86836 }
86837
86838 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86839 - void *buf, int len, int write)
86840 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86841 + void *buf, size_t len, int write)
86842 {
86843 resource_size_t phys_addr;
86844 unsigned long prot = 0;
86845 @@ -4085,8 +4367,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86846 * Access another process' address space as given in mm. If non-NULL, use the
86847 * given task for page fault accounting.
86848 */
86849 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86850 - unsigned long addr, void *buf, int len, int write)
86851 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86852 + unsigned long addr, void *buf, size_t len, int write)
86853 {
86854 struct vm_area_struct *vma;
86855 void *old_buf = buf;
86856 @@ -4094,7 +4376,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86857 down_read(&mm->mmap_sem);
86858 /* ignore errors, just check how much was successfully transferred */
86859 while (len) {
86860 - int bytes, ret, offset;
86861 + ssize_t bytes, ret, offset;
86862 void *maddr;
86863 struct page *page = NULL;
86864
86865 @@ -4153,8 +4435,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86866 *
86867 * The caller must hold a reference on @mm.
86868 */
86869 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
86870 - void *buf, int len, int write)
86871 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
86872 + void *buf, size_t len, int write)
86873 {
86874 return __access_remote_vm(NULL, mm, addr, buf, len, write);
86875 }
86876 @@ -4164,11 +4446,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
86877 * Source/target buffer must be kernel space,
86878 * Do not walk the page table directly, use get_user_pages
86879 */
86880 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
86881 - void *buf, int len, int write)
86882 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
86883 + void *buf, size_t len, int write)
86884 {
86885 struct mm_struct *mm;
86886 - int ret;
86887 + ssize_t ret;
86888
86889 mm = get_task_mm(tsk);
86890 if (!mm)
86891 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
86892 index 4baf12e..5497066 100644
86893 --- a/mm/mempolicy.c
86894 +++ b/mm/mempolicy.c
86895 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
86896 unsigned long vmstart;
86897 unsigned long vmend;
86898
86899 +#ifdef CONFIG_PAX_SEGMEXEC
86900 + struct vm_area_struct *vma_m;
86901 +#endif
86902 +
86903 vma = find_vma(mm, start);
86904 if (!vma || vma->vm_start > start)
86905 return -EFAULT;
86906 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
86907 err = vma_replace_policy(vma, new_pol);
86908 if (err)
86909 goto out;
86910 +
86911 +#ifdef CONFIG_PAX_SEGMEXEC
86912 + vma_m = pax_find_mirror_vma(vma);
86913 + if (vma_m) {
86914 + err = vma_replace_policy(vma_m, new_pol);
86915 + if (err)
86916 + goto out;
86917 + }
86918 +#endif
86919 +
86920 }
86921
86922 out:
86923 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
86924
86925 if (end < start)
86926 return -EINVAL;
86927 +
86928 +#ifdef CONFIG_PAX_SEGMEXEC
86929 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
86930 + if (end > SEGMEXEC_TASK_SIZE)
86931 + return -EINVAL;
86932 + } else
86933 +#endif
86934 +
86935 + if (end > TASK_SIZE)
86936 + return -EINVAL;
86937 +
86938 if (end == start)
86939 return 0;
86940
86941 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
86942 */
86943 tcred = __task_cred(task);
86944 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
86945 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
86946 - !capable(CAP_SYS_NICE)) {
86947 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
86948 rcu_read_unlock();
86949 err = -EPERM;
86950 goto out_put;
86951 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
86952 goto out;
86953 }
86954
86955 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
86956 + if (mm != current->mm &&
86957 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
86958 + mmput(mm);
86959 + err = -EPERM;
86960 + goto out;
86961 + }
86962 +#endif
86963 +
86964 err = do_migrate_pages(mm, old, new,
86965 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
86966
86967 diff --git a/mm/migrate.c b/mm/migrate.c
86968 index 25ca7ca..abe1836 100644
86969 --- a/mm/migrate.c
86970 +++ b/mm/migrate.c
86971 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
86972 */
86973 tcred = __task_cred(task);
86974 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
86975 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
86976 - !capable(CAP_SYS_NICE)) {
86977 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
86978 rcu_read_unlock();
86979 err = -EPERM;
86980 goto out;
86981 diff --git a/mm/mlock.c b/mm/mlock.c
86982 index 79b7cf7..37472bf 100644
86983 --- a/mm/mlock.c
86984 +++ b/mm/mlock.c
86985 @@ -13,6 +13,7 @@
86986 #include <linux/pagemap.h>
86987 #include <linux/mempolicy.h>
86988 #include <linux/syscalls.h>
86989 +#include <linux/security.h>
86990 #include <linux/sched.h>
86991 #include <linux/export.h>
86992 #include <linux/rmap.h>
86993 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
86994 {
86995 unsigned long nstart, end, tmp;
86996 struct vm_area_struct * vma, * prev;
86997 - int error;
86998 + int error = 0;
86999
87000 VM_BUG_ON(start & ~PAGE_MASK);
87001 VM_BUG_ON(len != PAGE_ALIGN(len));
87002 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87003 return -EINVAL;
87004 if (end == start)
87005 return 0;
87006 + if (end > TASK_SIZE)
87007 + return -EINVAL;
87008 +
87009 vma = find_vma(current->mm, start);
87010 if (!vma || vma->vm_start > start)
87011 return -ENOMEM;
87012 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87013 for (nstart = start ; ; ) {
87014 vm_flags_t newflags;
87015
87016 +#ifdef CONFIG_PAX_SEGMEXEC
87017 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87018 + break;
87019 +#endif
87020 +
87021 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87022
87023 newflags = vma->vm_flags & ~VM_LOCKED;
87024 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87025 lock_limit >>= PAGE_SHIFT;
87026
87027 /* check against resource limits */
87028 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87029 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87030 error = do_mlock(start, len, 1);
87031 up_write(&current->mm->mmap_sem);
87032 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
87033 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87034 vm_flags_t newflags;
87035
87036 +#ifdef CONFIG_PAX_SEGMEXEC
87037 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87038 + break;
87039 +#endif
87040 +
87041 newflags = vma->vm_flags & ~VM_LOCKED;
87042 if (flags & MCL_CURRENT)
87043 newflags |= VM_LOCKED;
87044
87045 /* Ignore errors */
87046 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
87047 + cond_resched();
87048 }
87049 out:
87050 return 0;
87051 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87052 lock_limit >>= PAGE_SHIFT;
87053
87054 ret = -ENOMEM;
87055 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87056 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87057 capable(CAP_IPC_LOCK))
87058 ret = do_mlockall(flags);
87059 diff --git a/mm/mmap.c b/mm/mmap.c
87060 index f9c97d1..3468d3b 100644
87061 --- a/mm/mmap.c
87062 +++ b/mm/mmap.c
87063 @@ -36,6 +36,7 @@
87064 #include <linux/sched/sysctl.h>
87065 #include <linux/notifier.h>
87066 #include <linux/memory.h>
87067 +#include <linux/random.h>
87068
87069 #include <asm/uaccess.h>
87070 #include <asm/cacheflush.h>
87071 @@ -52,6 +53,16 @@
87072 #define arch_rebalance_pgtables(addr, len) (addr)
87073 #endif
87074
87075 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87076 +{
87077 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87078 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87079 + up_read(&mm->mmap_sem);
87080 + BUG();
87081 + }
87082 +#endif
87083 +}
87084 +
87085 static void unmap_region(struct mm_struct *mm,
87086 struct vm_area_struct *vma, struct vm_area_struct *prev,
87087 unsigned long start, unsigned long end);
87088 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87089 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87090 *
87091 */
87092 -pgprot_t protection_map[16] = {
87093 +pgprot_t protection_map[16] __read_only = {
87094 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87095 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87096 };
87097
87098 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87099 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87100 {
87101 - return __pgprot(pgprot_val(protection_map[vm_flags &
87102 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87103 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87104 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87105 +
87106 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87107 + if (!(__supported_pte_mask & _PAGE_NX) &&
87108 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87109 + (vm_flags & (VM_READ | VM_WRITE)))
87110 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87111 +#endif
87112 +
87113 + return prot;
87114 }
87115 EXPORT_SYMBOL(vm_get_page_prot);
87116
87117 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87118 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87119 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87120 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87121 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87122 /*
87123 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87124 * other variables. It can be updated by several CPUs frequently.
87125 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87126 struct vm_area_struct *next = vma->vm_next;
87127
87128 might_sleep();
87129 + BUG_ON(vma->vm_mirror);
87130 if (vma->vm_ops && vma->vm_ops->close)
87131 vma->vm_ops->close(vma);
87132 if (vma->vm_file)
87133 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87134 * not page aligned -Ram Gupta
87135 */
87136 rlim = rlimit(RLIMIT_DATA);
87137 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87138 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87139 (mm->end_data - mm->start_data) > rlim)
87140 goto out;
87141 @@ -933,6 +956,12 @@ static int
87142 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
87143 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87144 {
87145 +
87146 +#ifdef CONFIG_PAX_SEGMEXEC
87147 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
87148 + return 0;
87149 +#endif
87150 +
87151 if (is_mergeable_vma(vma, file, vm_flags) &&
87152 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87153 if (vma->vm_pgoff == vm_pgoff)
87154 @@ -952,6 +981,12 @@ static int
87155 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87156 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87157 {
87158 +
87159 +#ifdef CONFIG_PAX_SEGMEXEC
87160 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87161 + return 0;
87162 +#endif
87163 +
87164 if (is_mergeable_vma(vma, file, vm_flags) &&
87165 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87166 pgoff_t vm_pglen;
87167 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87168 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87169 struct vm_area_struct *prev, unsigned long addr,
87170 unsigned long end, unsigned long vm_flags,
87171 - struct anon_vma *anon_vma, struct file *file,
87172 + struct anon_vma *anon_vma, struct file *file,
87173 pgoff_t pgoff, struct mempolicy *policy)
87174 {
87175 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87176 struct vm_area_struct *area, *next;
87177 int err;
87178
87179 +#ifdef CONFIG_PAX_SEGMEXEC
87180 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87181 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87182 +
87183 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87184 +#endif
87185 +
87186 /*
87187 * We later require that vma->vm_flags == vm_flags,
87188 * so this tests vma->vm_flags & VM_SPECIAL, too.
87189 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87190 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87191 next = next->vm_next;
87192
87193 +#ifdef CONFIG_PAX_SEGMEXEC
87194 + if (prev)
87195 + prev_m = pax_find_mirror_vma(prev);
87196 + if (area)
87197 + area_m = pax_find_mirror_vma(area);
87198 + if (next)
87199 + next_m = pax_find_mirror_vma(next);
87200 +#endif
87201 +
87202 /*
87203 * Can it merge with the predecessor?
87204 */
87205 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87206 /* cases 1, 6 */
87207 err = vma_adjust(prev, prev->vm_start,
87208 next->vm_end, prev->vm_pgoff, NULL);
87209 - } else /* cases 2, 5, 7 */
87210 +
87211 +#ifdef CONFIG_PAX_SEGMEXEC
87212 + if (!err && prev_m)
87213 + err = vma_adjust(prev_m, prev_m->vm_start,
87214 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87215 +#endif
87216 +
87217 + } else { /* cases 2, 5, 7 */
87218 err = vma_adjust(prev, prev->vm_start,
87219 end, prev->vm_pgoff, NULL);
87220 +
87221 +#ifdef CONFIG_PAX_SEGMEXEC
87222 + if (!err && prev_m)
87223 + err = vma_adjust(prev_m, prev_m->vm_start,
87224 + end_m, prev_m->vm_pgoff, NULL);
87225 +#endif
87226 +
87227 + }
87228 if (err)
87229 return NULL;
87230 khugepaged_enter_vma_merge(prev);
87231 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87232 mpol_equal(policy, vma_policy(next)) &&
87233 can_vma_merge_before(next, vm_flags,
87234 anon_vma, file, pgoff+pglen)) {
87235 - if (prev && addr < prev->vm_end) /* case 4 */
87236 + if (prev && addr < prev->vm_end) { /* case 4 */
87237 err = vma_adjust(prev, prev->vm_start,
87238 addr, prev->vm_pgoff, NULL);
87239 - else /* cases 3, 8 */
87240 +
87241 +#ifdef CONFIG_PAX_SEGMEXEC
87242 + if (!err && prev_m)
87243 + err = vma_adjust(prev_m, prev_m->vm_start,
87244 + addr_m, prev_m->vm_pgoff, NULL);
87245 +#endif
87246 +
87247 + } else { /* cases 3, 8 */
87248 err = vma_adjust(area, addr, next->vm_end,
87249 next->vm_pgoff - pglen, NULL);
87250 +
87251 +#ifdef CONFIG_PAX_SEGMEXEC
87252 + if (!err && area_m)
87253 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87254 + next_m->vm_pgoff - pglen, NULL);
87255 +#endif
87256 +
87257 + }
87258 if (err)
87259 return NULL;
87260 khugepaged_enter_vma_merge(area);
87261 @@ -1165,8 +1246,10 @@ none:
87262 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87263 struct file *file, long pages)
87264 {
87265 - const unsigned long stack_flags
87266 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87267 +
87268 +#ifdef CONFIG_PAX_RANDMMAP
87269 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87270 +#endif
87271
87272 mm->total_vm += pages;
87273
87274 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87275 mm->shared_vm += pages;
87276 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87277 mm->exec_vm += pages;
87278 - } else if (flags & stack_flags)
87279 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87280 mm->stack_vm += pages;
87281 }
87282 #endif /* CONFIG_PROC_FS */
87283 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87284 * (the exception is when the underlying filesystem is noexec
87285 * mounted, in which case we dont add PROT_EXEC.)
87286 */
87287 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87288 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87289 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87290 prot |= PROT_EXEC;
87291
87292 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87293 /* Obtain the address to map to. we verify (or select) it and ensure
87294 * that it represents a valid section of the address space.
87295 */
87296 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87297 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87298 if (addr & ~PAGE_MASK)
87299 return addr;
87300
87301 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87302 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87303 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87304
87305 +#ifdef CONFIG_PAX_MPROTECT
87306 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87307 +
87308 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87309 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87310 + mm->binfmt->handle_mmap)
87311 + mm->binfmt->handle_mmap(file);
87312 +#endif
87313 +
87314 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87315 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87316 + gr_log_rwxmmap(file);
87317 +
87318 +#ifdef CONFIG_PAX_EMUPLT
87319 + vm_flags &= ~VM_EXEC;
87320 +#else
87321 + return -EPERM;
87322 +#endif
87323 +
87324 + }
87325 +
87326 + if (!(vm_flags & VM_EXEC))
87327 + vm_flags &= ~VM_MAYEXEC;
87328 +#else
87329 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87330 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87331 +#endif
87332 + else
87333 + vm_flags &= ~VM_MAYWRITE;
87334 + }
87335 +#endif
87336 +
87337 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87338 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87339 + vm_flags &= ~VM_PAGEEXEC;
87340 +#endif
87341 +
87342 if (flags & MAP_LOCKED)
87343 if (!can_do_mlock())
87344 return -EPERM;
87345 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87346 locked += mm->locked_vm;
87347 lock_limit = rlimit(RLIMIT_MEMLOCK);
87348 lock_limit >>= PAGE_SHIFT;
87349 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87350 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87351 return -EAGAIN;
87352 }
87353 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87354 vm_flags |= VM_NORESERVE;
87355 }
87356
87357 + if (!gr_acl_handle_mmap(file, prot))
87358 + return -EACCES;
87359 +
87360 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87361 if (!IS_ERR_VALUE(addr) &&
87362 ((vm_flags & VM_LOCKED) ||
87363 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87364 vm_flags_t vm_flags = vma->vm_flags;
87365
87366 /* If it was private or non-writable, the write bit is already clear */
87367 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87368 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87369 return 0;
87370
87371 /* The backer wishes to know when pages are first written to? */
87372 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87373 unsigned long charged = 0;
87374 struct inode *inode = file ? file_inode(file) : NULL;
87375
87376 +#ifdef CONFIG_PAX_SEGMEXEC
87377 + struct vm_area_struct *vma_m = NULL;
87378 +#endif
87379 +
87380 + /*
87381 + * mm->mmap_sem is required to protect against another thread
87382 + * changing the mappings in case we sleep.
87383 + */
87384 + verify_mm_writelocked(mm);
87385 +
87386 /* Check against address space limit. */
87387 +
87388 +#ifdef CONFIG_PAX_RANDMMAP
87389 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87390 +#endif
87391 +
87392 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87393 unsigned long nr_pages;
87394
87395 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87396
87397 /* Clear old maps */
87398 error = -ENOMEM;
87399 -munmap_back:
87400 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87401 if (do_munmap(mm, addr, len))
87402 return -ENOMEM;
87403 - goto munmap_back;
87404 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87405 }
87406
87407 /*
87408 @@ -1536,6 +1674,16 @@ munmap_back:
87409 goto unacct_error;
87410 }
87411
87412 +#ifdef CONFIG_PAX_SEGMEXEC
87413 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87414 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87415 + if (!vma_m) {
87416 + error = -ENOMEM;
87417 + goto free_vma;
87418 + }
87419 + }
87420 +#endif
87421 +
87422 vma->vm_mm = mm;
87423 vma->vm_start = addr;
87424 vma->vm_end = addr + len;
87425 @@ -1560,6 +1708,13 @@ munmap_back:
87426 if (error)
87427 goto unmap_and_free_vma;
87428
87429 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87430 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87431 + vma->vm_flags |= VM_PAGEEXEC;
87432 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87433 + }
87434 +#endif
87435 +
87436 /* Can addr have changed??
87437 *
87438 * Answer: Yes, several device drivers can do it in their
87439 @@ -1598,6 +1753,11 @@ munmap_back:
87440 vma_link(mm, vma, prev, rb_link, rb_parent);
87441 file = vma->vm_file;
87442
87443 +#ifdef CONFIG_PAX_SEGMEXEC
87444 + if (vma_m)
87445 + BUG_ON(pax_mirror_vma(vma_m, vma));
87446 +#endif
87447 +
87448 /* Once vma denies write, undo our temporary denial count */
87449 if (correct_wcount)
87450 atomic_inc(&inode->i_writecount);
87451 @@ -1605,6 +1765,7 @@ out:
87452 perf_event_mmap(vma);
87453
87454 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87455 + track_exec_limit(mm, addr, addr + len, vm_flags);
87456 if (vm_flags & VM_LOCKED) {
87457 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87458 vma == get_gate_vma(current->mm)))
87459 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87460 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87461 charged = 0;
87462 free_vma:
87463 +
87464 +#ifdef CONFIG_PAX_SEGMEXEC
87465 + if (vma_m)
87466 + kmem_cache_free(vm_area_cachep, vma_m);
87467 +#endif
87468 +
87469 kmem_cache_free(vm_area_cachep, vma);
87470 unacct_error:
87471 if (charged)
87472 @@ -1635,7 +1802,63 @@ unacct_error:
87473 return error;
87474 }
87475
87476 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87477 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87478 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87479 +{
87480 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87481 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87482 +
87483 + return 0;
87484 +}
87485 +#endif
87486 +
87487 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87488 +{
87489 + if (!vma) {
87490 +#ifdef CONFIG_STACK_GROWSUP
87491 + if (addr > sysctl_heap_stack_gap)
87492 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87493 + else
87494 + vma = find_vma(current->mm, 0);
87495 + if (vma && (vma->vm_flags & VM_GROWSUP))
87496 + return false;
87497 +#endif
87498 + return true;
87499 + }
87500 +
87501 + if (addr + len > vma->vm_start)
87502 + return false;
87503 +
87504 + if (vma->vm_flags & VM_GROWSDOWN)
87505 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87506 +#ifdef CONFIG_STACK_GROWSUP
87507 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87508 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87509 +#endif
87510 + else if (offset)
87511 + return offset <= vma->vm_start - addr - len;
87512 +
87513 + return true;
87514 +}
87515 +
87516 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87517 +{
87518 + if (vma->vm_start < len)
87519 + return -ENOMEM;
87520 +
87521 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87522 + if (offset <= vma->vm_start - len)
87523 + return vma->vm_start - len - offset;
87524 + else
87525 + return -ENOMEM;
87526 + }
87527 +
87528 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87529 + return vma->vm_start - len - sysctl_heap_stack_gap;
87530 + return -ENOMEM;
87531 +}
87532 +
87533 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87534 {
87535 /*
87536 * We implement the search by looking for an rbtree node that
87537 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87538 }
87539 }
87540
87541 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87542 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87543 check_current:
87544 /* Check if current node has a suitable gap */
87545 if (gap_start > high_limit)
87546 return -ENOMEM;
87547 +
87548 + if (gap_end - gap_start > info->threadstack_offset)
87549 + gap_start += info->threadstack_offset;
87550 + else
87551 + gap_start = gap_end;
87552 +
87553 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87554 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87555 + gap_start += sysctl_heap_stack_gap;
87556 + else
87557 + gap_start = gap_end;
87558 + }
87559 + if (vma->vm_flags & VM_GROWSDOWN) {
87560 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87561 + gap_end -= sysctl_heap_stack_gap;
87562 + else
87563 + gap_end = gap_start;
87564 + }
87565 if (gap_end >= low_limit && gap_end - gap_start >= length)
87566 goto found;
87567
87568 @@ -1737,7 +1978,7 @@ found:
87569 return gap_start;
87570 }
87571
87572 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87573 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87574 {
87575 struct mm_struct *mm = current->mm;
87576 struct vm_area_struct *vma;
87577 @@ -1791,6 +2032,24 @@ check_current:
87578 gap_end = vma->vm_start;
87579 if (gap_end < low_limit)
87580 return -ENOMEM;
87581 +
87582 + if (gap_end - gap_start > info->threadstack_offset)
87583 + gap_end -= info->threadstack_offset;
87584 + else
87585 + gap_end = gap_start;
87586 +
87587 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87588 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87589 + gap_start += sysctl_heap_stack_gap;
87590 + else
87591 + gap_start = gap_end;
87592 + }
87593 + if (vma->vm_flags & VM_GROWSDOWN) {
87594 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87595 + gap_end -= sysctl_heap_stack_gap;
87596 + else
87597 + gap_end = gap_start;
87598 + }
87599 if (gap_start <= high_limit && gap_end - gap_start >= length)
87600 goto found;
87601
87602 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87603 struct mm_struct *mm = current->mm;
87604 struct vm_area_struct *vma;
87605 struct vm_unmapped_area_info info;
87606 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87607
87608 if (len > TASK_SIZE)
87609 return -ENOMEM;
87610 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87611 if (flags & MAP_FIXED)
87612 return addr;
87613
87614 +#ifdef CONFIG_PAX_RANDMMAP
87615 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87616 +#endif
87617 +
87618 if (addr) {
87619 addr = PAGE_ALIGN(addr);
87620 vma = find_vma(mm, addr);
87621 - if (TASK_SIZE - len >= addr &&
87622 - (!vma || addr + len <= vma->vm_start))
87623 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87624 return addr;
87625 }
87626
87627 info.flags = 0;
87628 info.length = len;
87629 info.low_limit = TASK_UNMAPPED_BASE;
87630 +
87631 +#ifdef CONFIG_PAX_RANDMMAP
87632 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87633 + info.low_limit += mm->delta_mmap;
87634 +#endif
87635 +
87636 info.high_limit = TASK_SIZE;
87637 info.align_mask = 0;
87638 + info.threadstack_offset = offset;
87639 return vm_unmapped_area(&info);
87640 }
87641 #endif
87642 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87643 struct mm_struct *mm = current->mm;
87644 unsigned long addr = addr0;
87645 struct vm_unmapped_area_info info;
87646 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87647
87648 /* requested length too big for entire address space */
87649 if (len > TASK_SIZE)
87650 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87651 if (flags & MAP_FIXED)
87652 return addr;
87653
87654 +#ifdef CONFIG_PAX_RANDMMAP
87655 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87656 +#endif
87657 +
87658 /* requesting a specific address */
87659 if (addr) {
87660 addr = PAGE_ALIGN(addr);
87661 vma = find_vma(mm, addr);
87662 - if (TASK_SIZE - len >= addr &&
87663 - (!vma || addr + len <= vma->vm_start))
87664 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87665 return addr;
87666 }
87667
87668 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87669 info.low_limit = PAGE_SIZE;
87670 info.high_limit = mm->mmap_base;
87671 info.align_mask = 0;
87672 + info.threadstack_offset = offset;
87673 addr = vm_unmapped_area(&info);
87674
87675 /*
87676 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87677 VM_BUG_ON(addr != -ENOMEM);
87678 info.flags = 0;
87679 info.low_limit = TASK_UNMAPPED_BASE;
87680 +
87681 +#ifdef CONFIG_PAX_RANDMMAP
87682 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87683 + info.low_limit += mm->delta_mmap;
87684 +#endif
87685 +
87686 info.high_limit = TASK_SIZE;
87687 addr = vm_unmapped_area(&info);
87688 }
87689 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
87690 return vma;
87691 }
87692
87693 +#ifdef CONFIG_PAX_SEGMEXEC
87694 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
87695 +{
87696 + struct vm_area_struct *vma_m;
87697 +
87698 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
87699 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
87700 + BUG_ON(vma->vm_mirror);
87701 + return NULL;
87702 + }
87703 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
87704 + vma_m = vma->vm_mirror;
87705 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
87706 + BUG_ON(vma->vm_file != vma_m->vm_file);
87707 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
87708 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
87709 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
87710 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
87711 + return vma_m;
87712 +}
87713 +#endif
87714 +
87715 /*
87716 * Verify that the stack growth is acceptable and
87717 * update accounting. This is shared with both the
87718 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87719 return -ENOMEM;
87720
87721 /* Stack limit test */
87722 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
87723 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
87724 return -ENOMEM;
87725
87726 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87727 locked = mm->locked_vm + grow;
87728 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
87729 limit >>= PAGE_SHIFT;
87730 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87731 if (locked > limit && !capable(CAP_IPC_LOCK))
87732 return -ENOMEM;
87733 }
87734 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87735 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
87736 * vma is the last one with address > vma->vm_end. Have to extend vma.
87737 */
87738 +#ifndef CONFIG_IA64
87739 +static
87740 +#endif
87741 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
87742 {
87743 int error;
87744 + bool locknext;
87745
87746 if (!(vma->vm_flags & VM_GROWSUP))
87747 return -EFAULT;
87748
87749 + /* Also guard against wrapping around to address 0. */
87750 + if (address < PAGE_ALIGN(address+1))
87751 + address = PAGE_ALIGN(address+1);
87752 + else
87753 + return -ENOMEM;
87754 +
87755 /*
87756 * We must make sure the anon_vma is allocated
87757 * so that the anon_vma locking is not a noop.
87758 */
87759 if (unlikely(anon_vma_prepare(vma)))
87760 return -ENOMEM;
87761 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
87762 + if (locknext && anon_vma_prepare(vma->vm_next))
87763 + return -ENOMEM;
87764 vma_lock_anon_vma(vma);
87765 + if (locknext)
87766 + vma_lock_anon_vma(vma->vm_next);
87767
87768 /*
87769 * vma->vm_start/vm_end cannot change under us because the caller
87770 * is required to hold the mmap_sem in read mode. We need the
87771 - * anon_vma lock to serialize against concurrent expand_stacks.
87772 - * Also guard against wrapping around to address 0.
87773 + * anon_vma locks to serialize against concurrent expand_stacks
87774 + * and expand_upwards.
87775 */
87776 - if (address < PAGE_ALIGN(address+4))
87777 - address = PAGE_ALIGN(address+4);
87778 - else {
87779 - vma_unlock_anon_vma(vma);
87780 - return -ENOMEM;
87781 - }
87782 error = 0;
87783
87784 /* Somebody else might have raced and expanded it already */
87785 - if (address > vma->vm_end) {
87786 + 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)
87787 + error = -ENOMEM;
87788 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
87789 unsigned long size, grow;
87790
87791 size = address - vma->vm_start;
87792 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
87793 }
87794 }
87795 }
87796 + if (locknext)
87797 + vma_unlock_anon_vma(vma->vm_next);
87798 vma_unlock_anon_vma(vma);
87799 khugepaged_enter_vma_merge(vma);
87800 validate_mm(vma->vm_mm);
87801 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
87802 unsigned long address)
87803 {
87804 int error;
87805 + bool lockprev = false;
87806 + struct vm_area_struct *prev;
87807
87808 /*
87809 * We must make sure the anon_vma is allocated
87810 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
87811 if (error)
87812 return error;
87813
87814 + prev = vma->vm_prev;
87815 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
87816 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
87817 +#endif
87818 + if (lockprev && anon_vma_prepare(prev))
87819 + return -ENOMEM;
87820 + if (lockprev)
87821 + vma_lock_anon_vma(prev);
87822 +
87823 vma_lock_anon_vma(vma);
87824
87825 /*
87826 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
87827 */
87828
87829 /* Somebody else might have raced and expanded it already */
87830 - if (address < vma->vm_start) {
87831 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
87832 + error = -ENOMEM;
87833 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
87834 unsigned long size, grow;
87835
87836 +#ifdef CONFIG_PAX_SEGMEXEC
87837 + struct vm_area_struct *vma_m;
87838 +
87839 + vma_m = pax_find_mirror_vma(vma);
87840 +#endif
87841 +
87842 size = vma->vm_end - address;
87843 grow = (vma->vm_start - address) >> PAGE_SHIFT;
87844
87845 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
87846 vma->vm_pgoff -= grow;
87847 anon_vma_interval_tree_post_update_vma(vma);
87848 vma_gap_update(vma);
87849 +
87850 +#ifdef CONFIG_PAX_SEGMEXEC
87851 + if (vma_m) {
87852 + anon_vma_interval_tree_pre_update_vma(vma_m);
87853 + vma_m->vm_start -= grow << PAGE_SHIFT;
87854 + vma_m->vm_pgoff -= grow;
87855 + anon_vma_interval_tree_post_update_vma(vma_m);
87856 + vma_gap_update(vma_m);
87857 + }
87858 +#endif
87859 +
87860 spin_unlock(&vma->vm_mm->page_table_lock);
87861
87862 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
87863 perf_event_mmap(vma);
87864 }
87865 }
87866 }
87867 vma_unlock_anon_vma(vma);
87868 + if (lockprev)
87869 + vma_unlock_anon_vma(prev);
87870 khugepaged_enter_vma_merge(vma);
87871 validate_mm(vma->vm_mm);
87872 return error;
87873 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
87874 do {
87875 long nrpages = vma_pages(vma);
87876
87877 +#ifdef CONFIG_PAX_SEGMEXEC
87878 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
87879 + vma = remove_vma(vma);
87880 + continue;
87881 + }
87882 +#endif
87883 +
87884 if (vma->vm_flags & VM_ACCOUNT)
87885 nr_accounted += nrpages;
87886 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
87887 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
87888 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
87889 vma->vm_prev = NULL;
87890 do {
87891 +
87892 +#ifdef CONFIG_PAX_SEGMEXEC
87893 + if (vma->vm_mirror) {
87894 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
87895 + vma->vm_mirror->vm_mirror = NULL;
87896 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
87897 + vma->vm_mirror = NULL;
87898 + }
87899 +#endif
87900 +
87901 vma_rb_erase(vma, &mm->mm_rb);
87902 mm->map_count--;
87903 tail_vma = vma;
87904 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87905 struct vm_area_struct *new;
87906 int err = -ENOMEM;
87907
87908 +#ifdef CONFIG_PAX_SEGMEXEC
87909 + struct vm_area_struct *vma_m, *new_m = NULL;
87910 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
87911 +#endif
87912 +
87913 if (is_vm_hugetlb_page(vma) && (addr &
87914 ~(huge_page_mask(hstate_vma(vma)))))
87915 return -EINVAL;
87916
87917 +#ifdef CONFIG_PAX_SEGMEXEC
87918 + vma_m = pax_find_mirror_vma(vma);
87919 +#endif
87920 +
87921 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
87922 if (!new)
87923 goto out_err;
87924
87925 +#ifdef CONFIG_PAX_SEGMEXEC
87926 + if (vma_m) {
87927 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
87928 + if (!new_m) {
87929 + kmem_cache_free(vm_area_cachep, new);
87930 + goto out_err;
87931 + }
87932 + }
87933 +#endif
87934 +
87935 /* most fields are the same, copy all, and then fixup */
87936 *new = *vma;
87937
87938 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87939 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
87940 }
87941
87942 +#ifdef CONFIG_PAX_SEGMEXEC
87943 + if (vma_m) {
87944 + *new_m = *vma_m;
87945 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
87946 + new_m->vm_mirror = new;
87947 + new->vm_mirror = new_m;
87948 +
87949 + if (new_below)
87950 + new_m->vm_end = addr_m;
87951 + else {
87952 + new_m->vm_start = addr_m;
87953 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
87954 + }
87955 + }
87956 +#endif
87957 +
87958 pol = mpol_dup(vma_policy(vma));
87959 if (IS_ERR(pol)) {
87960 err = PTR_ERR(pol);
87961 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87962 else
87963 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
87964
87965 +#ifdef CONFIG_PAX_SEGMEXEC
87966 + if (!err && vma_m) {
87967 + if (anon_vma_clone(new_m, vma_m))
87968 + goto out_free_mpol;
87969 +
87970 + mpol_get(pol);
87971 + vma_set_policy(new_m, pol);
87972 +
87973 + if (new_m->vm_file)
87974 + get_file(new_m->vm_file);
87975 +
87976 + if (new_m->vm_ops && new_m->vm_ops->open)
87977 + new_m->vm_ops->open(new_m);
87978 +
87979 + if (new_below)
87980 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
87981 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
87982 + else
87983 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
87984 +
87985 + if (err) {
87986 + if (new_m->vm_ops && new_m->vm_ops->close)
87987 + new_m->vm_ops->close(new_m);
87988 + if (new_m->vm_file)
87989 + fput(new_m->vm_file);
87990 + mpol_put(pol);
87991 + }
87992 + }
87993 +#endif
87994 +
87995 /* Success. */
87996 if (!err)
87997 return 0;
87998 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87999 new->vm_ops->close(new);
88000 if (new->vm_file)
88001 fput(new->vm_file);
88002 - unlink_anon_vmas(new);
88003 out_free_mpol:
88004 mpol_put(pol);
88005 out_free_vma:
88006 +
88007 +#ifdef CONFIG_PAX_SEGMEXEC
88008 + if (new_m) {
88009 + unlink_anon_vmas(new_m);
88010 + kmem_cache_free(vm_area_cachep, new_m);
88011 + }
88012 +#endif
88013 +
88014 + unlink_anon_vmas(new);
88015 kmem_cache_free(vm_area_cachep, new);
88016 out_err:
88017 return err;
88018 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88019 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88020 unsigned long addr, int new_below)
88021 {
88022 +
88023 +#ifdef CONFIG_PAX_SEGMEXEC
88024 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88025 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88026 + if (mm->map_count >= sysctl_max_map_count-1)
88027 + return -ENOMEM;
88028 + } else
88029 +#endif
88030 +
88031 if (mm->map_count >= sysctl_max_map_count)
88032 return -ENOMEM;
88033
88034 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88035 * work. This now handles partial unmappings.
88036 * Jeremy Fitzhardinge <jeremy@goop.org>
88037 */
88038 +#ifdef CONFIG_PAX_SEGMEXEC
88039 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88040 {
88041 + int ret = __do_munmap(mm, start, len);
88042 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88043 + return ret;
88044 +
88045 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88046 +}
88047 +
88048 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88049 +#else
88050 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88051 +#endif
88052 +{
88053 unsigned long end;
88054 struct vm_area_struct *vma, *prev, *last;
88055
88056 + /*
88057 + * mm->mmap_sem is required to protect against another thread
88058 + * changing the mappings in case we sleep.
88059 + */
88060 + verify_mm_writelocked(mm);
88061 +
88062 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88063 return -EINVAL;
88064
88065 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88066 /* Fix up all other VM information */
88067 remove_vma_list(mm, vma);
88068
88069 + track_exec_limit(mm, start, end, 0UL);
88070 +
88071 return 0;
88072 }
88073
88074 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88075 int ret;
88076 struct mm_struct *mm = current->mm;
88077
88078 +
88079 +#ifdef CONFIG_PAX_SEGMEXEC
88080 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88081 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88082 + return -EINVAL;
88083 +#endif
88084 +
88085 down_write(&mm->mmap_sem);
88086 ret = do_munmap(mm, start, len);
88087 up_write(&mm->mmap_sem);
88088 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88089 return vm_munmap(addr, len);
88090 }
88091
88092 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88093 -{
88094 -#ifdef CONFIG_DEBUG_VM
88095 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88096 - WARN_ON(1);
88097 - up_read(&mm->mmap_sem);
88098 - }
88099 -#endif
88100 -}
88101 -
88102 /*
88103 * this is really a simplified "do_mmap". it only handles
88104 * anonymous maps. eventually we may be able to do some
88105 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88106 struct rb_node ** rb_link, * rb_parent;
88107 pgoff_t pgoff = addr >> PAGE_SHIFT;
88108 int error;
88109 + unsigned long charged;
88110
88111 len = PAGE_ALIGN(len);
88112 if (!len)
88113 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88114
88115 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88116
88117 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88118 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88119 + flags &= ~VM_EXEC;
88120 +
88121 +#ifdef CONFIG_PAX_MPROTECT
88122 + if (mm->pax_flags & MF_PAX_MPROTECT)
88123 + flags &= ~VM_MAYEXEC;
88124 +#endif
88125 +
88126 + }
88127 +#endif
88128 +
88129 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88130 if (error & ~PAGE_MASK)
88131 return error;
88132
88133 + charged = len >> PAGE_SHIFT;
88134 +
88135 /*
88136 * mlock MCL_FUTURE?
88137 */
88138 if (mm->def_flags & VM_LOCKED) {
88139 unsigned long locked, lock_limit;
88140 - locked = len >> PAGE_SHIFT;
88141 + locked = charged;
88142 locked += mm->locked_vm;
88143 lock_limit = rlimit(RLIMIT_MEMLOCK);
88144 lock_limit >>= PAGE_SHIFT;
88145 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88146 /*
88147 * Clear old maps. this also does some error checking for us
88148 */
88149 - munmap_back:
88150 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88151 if (do_munmap(mm, addr, len))
88152 return -ENOMEM;
88153 - goto munmap_back;
88154 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88155 }
88156
88157 /* Check against address space limits *after* clearing old maps... */
88158 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88159 + if (!may_expand_vm(mm, charged))
88160 return -ENOMEM;
88161
88162 if (mm->map_count > sysctl_max_map_count)
88163 return -ENOMEM;
88164
88165 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88166 + if (security_vm_enough_memory_mm(mm, charged))
88167 return -ENOMEM;
88168
88169 /* Can we just expand an old private anonymous mapping? */
88170 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88171 */
88172 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88173 if (!vma) {
88174 - vm_unacct_memory(len >> PAGE_SHIFT);
88175 + vm_unacct_memory(charged);
88176 return -ENOMEM;
88177 }
88178
88179 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88180 vma_link(mm, vma, prev, rb_link, rb_parent);
88181 out:
88182 perf_event_mmap(vma);
88183 - mm->total_vm += len >> PAGE_SHIFT;
88184 + mm->total_vm += charged;
88185 if (flags & VM_LOCKED)
88186 - mm->locked_vm += (len >> PAGE_SHIFT);
88187 + mm->locked_vm += charged;
88188 + track_exec_limit(mm, addr, addr + len, flags);
88189 return addr;
88190 }
88191
88192 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88193 while (vma) {
88194 if (vma->vm_flags & VM_ACCOUNT)
88195 nr_accounted += vma_pages(vma);
88196 + vma->vm_mirror = NULL;
88197 vma = remove_vma(vma);
88198 }
88199 vm_unacct_memory(nr_accounted);
88200 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88201 struct vm_area_struct *prev;
88202 struct rb_node **rb_link, *rb_parent;
88203
88204 +#ifdef CONFIG_PAX_SEGMEXEC
88205 + struct vm_area_struct *vma_m = NULL;
88206 +#endif
88207 +
88208 + if (security_mmap_addr(vma->vm_start))
88209 + return -EPERM;
88210 +
88211 /*
88212 * The vm_pgoff of a purely anonymous vma should be irrelevant
88213 * until its first write fault, when page's anon_vma and index
88214 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88215 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88216 return -ENOMEM;
88217
88218 +#ifdef CONFIG_PAX_SEGMEXEC
88219 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88220 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88221 + if (!vma_m)
88222 + return -ENOMEM;
88223 + }
88224 +#endif
88225 +
88226 vma_link(mm, vma, prev, rb_link, rb_parent);
88227 +
88228 +#ifdef CONFIG_PAX_SEGMEXEC
88229 + if (vma_m)
88230 + BUG_ON(pax_mirror_vma(vma_m, vma));
88231 +#endif
88232 +
88233 return 0;
88234 }
88235
88236 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88237 struct mempolicy *pol;
88238 bool faulted_in_anon_vma = true;
88239
88240 + BUG_ON(vma->vm_mirror);
88241 +
88242 /*
88243 * If anonymous vma has not yet been faulted, update new pgoff
88244 * to match new location, to increase its chance of merging.
88245 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88246 return NULL;
88247 }
88248
88249 +#ifdef CONFIG_PAX_SEGMEXEC
88250 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88251 +{
88252 + struct vm_area_struct *prev_m;
88253 + struct rb_node **rb_link_m, *rb_parent_m;
88254 + struct mempolicy *pol_m;
88255 +
88256 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88257 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88258 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88259 + *vma_m = *vma;
88260 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88261 + if (anon_vma_clone(vma_m, vma))
88262 + return -ENOMEM;
88263 + pol_m = vma_policy(vma_m);
88264 + mpol_get(pol_m);
88265 + vma_set_policy(vma_m, pol_m);
88266 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88267 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88268 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88269 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88270 + if (vma_m->vm_file)
88271 + get_file(vma_m->vm_file);
88272 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88273 + vma_m->vm_ops->open(vma_m);
88274 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88275 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88276 + vma_m->vm_mirror = vma;
88277 + vma->vm_mirror = vma_m;
88278 + return 0;
88279 +}
88280 +#endif
88281 +
88282 /*
88283 * Return true if the calling process may expand its vm space by the passed
88284 * number of pages
88285 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88286
88287 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88288
88289 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88290 if (cur + npages > lim)
88291 return 0;
88292 return 1;
88293 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88294 vma->vm_start = addr;
88295 vma->vm_end = addr + len;
88296
88297 +#ifdef CONFIG_PAX_MPROTECT
88298 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88299 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88300 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88301 + return -EPERM;
88302 + if (!(vm_flags & VM_EXEC))
88303 + vm_flags &= ~VM_MAYEXEC;
88304 +#else
88305 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88306 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88307 +#endif
88308 + else
88309 + vm_flags &= ~VM_MAYWRITE;
88310 + }
88311 +#endif
88312 +
88313 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88314 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88315
88316 diff --git a/mm/mprotect.c b/mm/mprotect.c
88317 index 94722a4..e661e29 100644
88318 --- a/mm/mprotect.c
88319 +++ b/mm/mprotect.c
88320 @@ -23,10 +23,18 @@
88321 #include <linux/mmu_notifier.h>
88322 #include <linux/migrate.h>
88323 #include <linux/perf_event.h>
88324 +#include <linux/sched/sysctl.h>
88325 +
88326 +#ifdef CONFIG_PAX_MPROTECT
88327 +#include <linux/elf.h>
88328 +#include <linux/binfmts.h>
88329 +#endif
88330 +
88331 #include <asm/uaccess.h>
88332 #include <asm/pgtable.h>
88333 #include <asm/cacheflush.h>
88334 #include <asm/tlbflush.h>
88335 +#include <asm/mmu_context.h>
88336
88337 #ifndef pgprot_modify
88338 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88339 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88340 return pages;
88341 }
88342
88343 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88344 +/* called while holding the mmap semaphor for writing except stack expansion */
88345 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88346 +{
88347 + unsigned long oldlimit, newlimit = 0UL;
88348 +
88349 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88350 + return;
88351 +
88352 + spin_lock(&mm->page_table_lock);
88353 + oldlimit = mm->context.user_cs_limit;
88354 + if ((prot & VM_EXEC) && oldlimit < end)
88355 + /* USER_CS limit moved up */
88356 + newlimit = end;
88357 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88358 + /* USER_CS limit moved down */
88359 + newlimit = start;
88360 +
88361 + if (newlimit) {
88362 + mm->context.user_cs_limit = newlimit;
88363 +
88364 +#ifdef CONFIG_SMP
88365 + wmb();
88366 + cpus_clear(mm->context.cpu_user_cs_mask);
88367 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88368 +#endif
88369 +
88370 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88371 + }
88372 + spin_unlock(&mm->page_table_lock);
88373 + if (newlimit == end) {
88374 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88375 +
88376 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88377 + if (is_vm_hugetlb_page(vma))
88378 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88379 + else
88380 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88381 + }
88382 +}
88383 +#endif
88384 +
88385 int
88386 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88387 unsigned long start, unsigned long end, unsigned long newflags)
88388 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88389 int error;
88390 int dirty_accountable = 0;
88391
88392 +#ifdef CONFIG_PAX_SEGMEXEC
88393 + struct vm_area_struct *vma_m = NULL;
88394 + unsigned long start_m, end_m;
88395 +
88396 + start_m = start + SEGMEXEC_TASK_SIZE;
88397 + end_m = end + SEGMEXEC_TASK_SIZE;
88398 +#endif
88399 +
88400 if (newflags == oldflags) {
88401 *pprev = vma;
88402 return 0;
88403 }
88404
88405 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88406 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88407 +
88408 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88409 + return -ENOMEM;
88410 +
88411 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88412 + return -ENOMEM;
88413 + }
88414 +
88415 /*
88416 * If we make a private mapping writable we increase our commit;
88417 * but (without finer accounting) cannot reduce our commit if we
88418 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88419 }
88420 }
88421
88422 +#ifdef CONFIG_PAX_SEGMEXEC
88423 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88424 + if (start != vma->vm_start) {
88425 + error = split_vma(mm, vma, start, 1);
88426 + if (error)
88427 + goto fail;
88428 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88429 + *pprev = (*pprev)->vm_next;
88430 + }
88431 +
88432 + if (end != vma->vm_end) {
88433 + error = split_vma(mm, vma, end, 0);
88434 + if (error)
88435 + goto fail;
88436 + }
88437 +
88438 + if (pax_find_mirror_vma(vma)) {
88439 + error = __do_munmap(mm, start_m, end_m - start_m);
88440 + if (error)
88441 + goto fail;
88442 + } else {
88443 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88444 + if (!vma_m) {
88445 + error = -ENOMEM;
88446 + goto fail;
88447 + }
88448 + vma->vm_flags = newflags;
88449 + error = pax_mirror_vma(vma_m, vma);
88450 + if (error) {
88451 + vma->vm_flags = oldflags;
88452 + goto fail;
88453 + }
88454 + }
88455 + }
88456 +#endif
88457 +
88458 /*
88459 * First try to merge with previous and/or next vma.
88460 */
88461 @@ -296,9 +400,21 @@ success:
88462 * vm_flags and vm_page_prot are protected by the mmap_sem
88463 * held in write mode.
88464 */
88465 +
88466 +#ifdef CONFIG_PAX_SEGMEXEC
88467 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88468 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88469 +#endif
88470 +
88471 vma->vm_flags = newflags;
88472 +
88473 +#ifdef CONFIG_PAX_MPROTECT
88474 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88475 + mm->binfmt->handle_mprotect(vma, newflags);
88476 +#endif
88477 +
88478 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88479 - vm_get_page_prot(newflags));
88480 + vm_get_page_prot(vma->vm_flags));
88481
88482 if (vma_wants_writenotify(vma)) {
88483 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88484 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88485 end = start + len;
88486 if (end <= start)
88487 return -ENOMEM;
88488 +
88489 +#ifdef CONFIG_PAX_SEGMEXEC
88490 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88491 + if (end > SEGMEXEC_TASK_SIZE)
88492 + return -EINVAL;
88493 + } else
88494 +#endif
88495 +
88496 + if (end > TASK_SIZE)
88497 + return -EINVAL;
88498 +
88499 if (!arch_validate_prot(prot))
88500 return -EINVAL;
88501
88502 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88503 /*
88504 * Does the application expect PROT_READ to imply PROT_EXEC:
88505 */
88506 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88507 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88508 prot |= PROT_EXEC;
88509
88510 vm_flags = calc_vm_prot_bits(prot);
88511 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88512 if (start > vma->vm_start)
88513 prev = vma;
88514
88515 +#ifdef CONFIG_PAX_MPROTECT
88516 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88517 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88518 +#endif
88519 +
88520 for (nstart = start ; ; ) {
88521 unsigned long newflags;
88522
88523 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88524
88525 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88526 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88527 + if (prot & (PROT_WRITE | PROT_EXEC))
88528 + gr_log_rwxmprotect(vma);
88529 +
88530 + error = -EACCES;
88531 + goto out;
88532 + }
88533 +
88534 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88535 error = -EACCES;
88536 goto out;
88537 }
88538 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88539 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88540 if (error)
88541 goto out;
88542 +
88543 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88544 +
88545 nstart = tmp;
88546
88547 if (nstart < prev->vm_end)
88548 diff --git a/mm/mremap.c b/mm/mremap.c
88549 index 0843feb..5607f47 100644
88550 --- a/mm/mremap.c
88551 +++ b/mm/mremap.c
88552 @@ -25,6 +25,7 @@
88553 #include <asm/uaccess.h>
88554 #include <asm/cacheflush.h>
88555 #include <asm/tlbflush.h>
88556 +#include <asm/pgalloc.h>
88557
88558 #include "internal.h"
88559
88560 @@ -62,8 +63,10 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma,
88561 return NULL;
88562
88563 pmd = pmd_alloc(mm, pud, addr);
88564 - if (!pmd)
88565 + if (!pmd) {
88566 + pud_free(mm, pud);
88567 return NULL;
88568 + }
88569
88570 VM_BUG_ON(pmd_trans_huge(*pmd));
88571
88572 @@ -144,6 +147,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88573 continue;
88574 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88575 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88576 +
88577 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88578 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88579 + pte = pte_exprotect(pte);
88580 +#endif
88581 +
88582 pte = move_soft_dirty_pte(pte);
88583 set_pte_at(mm, new_addr, new_pte, pte);
88584 }
88585 @@ -337,6 +346,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88586 if (is_vm_hugetlb_page(vma))
88587 goto Einval;
88588
88589 +#ifdef CONFIG_PAX_SEGMEXEC
88590 + if (pax_find_mirror_vma(vma))
88591 + goto Einval;
88592 +#endif
88593 +
88594 /* We can't remap across vm area boundaries */
88595 if (old_len > vma->vm_end - addr)
88596 goto Efault;
88597 @@ -392,20 +406,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88598 unsigned long ret = -EINVAL;
88599 unsigned long charged = 0;
88600 unsigned long map_flags;
88601 + unsigned long pax_task_size = TASK_SIZE;
88602
88603 if (new_addr & ~PAGE_MASK)
88604 goto out;
88605
88606 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88607 +#ifdef CONFIG_PAX_SEGMEXEC
88608 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88609 + pax_task_size = SEGMEXEC_TASK_SIZE;
88610 +#endif
88611 +
88612 + pax_task_size -= PAGE_SIZE;
88613 +
88614 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88615 goto out;
88616
88617 /* Check if the location we're moving into overlaps the
88618 * old location at all, and fail if it does.
88619 */
88620 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88621 - goto out;
88622 -
88623 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88624 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88625 goto out;
88626
88627 ret = do_munmap(mm, new_addr, new_len);
88628 @@ -474,6 +493,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88629 unsigned long ret = -EINVAL;
88630 unsigned long charged = 0;
88631 bool locked = false;
88632 + unsigned long pax_task_size = TASK_SIZE;
88633
88634 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88635 return ret;
88636 @@ -495,6 +515,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88637 if (!new_len)
88638 return ret;
88639
88640 +#ifdef CONFIG_PAX_SEGMEXEC
88641 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88642 + pax_task_size = SEGMEXEC_TASK_SIZE;
88643 +#endif
88644 +
88645 + pax_task_size -= PAGE_SIZE;
88646 +
88647 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
88648 + old_len > pax_task_size || addr > pax_task_size-old_len)
88649 + return ret;
88650 +
88651 down_write(&current->mm->mmap_sem);
88652
88653 if (flags & MREMAP_FIXED) {
88654 @@ -545,6 +576,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88655 new_addr = addr;
88656 }
88657 ret = addr;
88658 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
88659 goto out;
88660 }
88661 }
88662 @@ -568,7 +600,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88663 goto out;
88664 }
88665
88666 + map_flags = vma->vm_flags;
88667 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
88668 + if (!(ret & ~PAGE_MASK)) {
88669 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
88670 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
88671 + }
88672 }
88673 out:
88674 if (ret & ~PAGE_MASK)
88675 diff --git a/mm/nommu.c b/mm/nommu.c
88676 index ecd1f15..77039bd 100644
88677 --- a/mm/nommu.c
88678 +++ b/mm/nommu.c
88679 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
88680 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
88681 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88682 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88683 -int heap_stack_gap = 0;
88684
88685 atomic_long_t mmap_pages_allocated;
88686
88687 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
88688 EXPORT_SYMBOL(find_vma);
88689
88690 /*
88691 - * find a VMA
88692 - * - we don't extend stack VMAs under NOMMU conditions
88693 - */
88694 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
88695 -{
88696 - return find_vma(mm, addr);
88697 -}
88698 -
88699 -/*
88700 * expand a stack to a given address
88701 * - not supported under NOMMU conditions
88702 */
88703 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88704
88705 /* most fields are the same, copy all, and then fixup */
88706 *new = *vma;
88707 + INIT_LIST_HEAD(&new->anon_vma_chain);
88708 *region = *vma->vm_region;
88709 new->vm_region = region;
88710
88711 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
88712 }
88713 EXPORT_SYMBOL(generic_file_remap_pages);
88714
88715 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88716 - unsigned long addr, void *buf, int len, int write)
88717 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88718 + unsigned long addr, void *buf, size_t len, int write)
88719 {
88720 struct vm_area_struct *vma;
88721
88722 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88723 *
88724 * The caller must hold a reference on @mm.
88725 */
88726 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88727 - void *buf, int len, int write)
88728 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88729 + void *buf, size_t len, int write)
88730 {
88731 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88732 }
88733 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88734 * Access another process' address space.
88735 * - source/target buffer must be kernel space
88736 */
88737 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
88738 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
88739 {
88740 struct mm_struct *mm;
88741
88742 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
88743 index 3f0c895..60cd104 100644
88744 --- a/mm/page-writeback.c
88745 +++ b/mm/page-writeback.c
88746 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
88747 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
88748 * - the bdi dirty thresh drops quickly due to change of JBOD workload
88749 */
88750 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
88751 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
88752 unsigned long thresh,
88753 unsigned long bg_thresh,
88754 unsigned long dirty,
88755 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
88756 index b100255..fba1254 100644
88757 --- a/mm/page_alloc.c
88758 +++ b/mm/page_alloc.c
88759 @@ -60,6 +60,7 @@
88760 #include <linux/page-debug-flags.h>
88761 #include <linux/hugetlb.h>
88762 #include <linux/sched/rt.h>
88763 +#include <linux/random.h>
88764
88765 #include <asm/sections.h>
88766 #include <asm/tlbflush.h>
88767 @@ -353,7 +354,7 @@ out:
88768 * This usage means that zero-order pages may not be compound.
88769 */
88770
88771 -static void free_compound_page(struct page *page)
88772 +void free_compound_page(struct page *page)
88773 {
88774 __free_pages_ok(page, compound_order(page));
88775 }
88776 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
88777 int i;
88778 int bad = 0;
88779
88780 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88781 + unsigned long index = 1UL << order;
88782 +#endif
88783 +
88784 trace_mm_page_free(page, order);
88785 kmemcheck_free_shadow(page, order);
88786
88787 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
88788 debug_check_no_obj_freed(page_address(page),
88789 PAGE_SIZE << order);
88790 }
88791 +
88792 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88793 + for (; index; --index)
88794 + sanitize_highpage(page + index - 1);
88795 +#endif
88796 +
88797 arch_free_page(page, order);
88798 kernel_map_pages(page, 1 << order, 0);
88799
88800 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
88801 local_irq_restore(flags);
88802 }
88803
88804 +#ifdef CONFIG_PAX_LATENT_ENTROPY
88805 +bool __meminitdata extra_latent_entropy;
88806 +
88807 +static int __init setup_pax_extra_latent_entropy(char *str)
88808 +{
88809 + extra_latent_entropy = true;
88810 + return 0;
88811 +}
88812 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
88813 +
88814 +volatile u64 latent_entropy;
88815 +EXPORT_SYMBOL(latent_entropy);
88816 +#endif
88817 +
88818 void __init __free_pages_bootmem(struct page *page, unsigned int order)
88819 {
88820 unsigned int nr_pages = 1 << order;
88821 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
88822 set_page_count(p, 0);
88823 }
88824
88825 +#ifdef CONFIG_PAX_LATENT_ENTROPY
88826 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
88827 + u64 hash = 0;
88828 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
88829 + const u64 *data = lowmem_page_address(page);
88830 +
88831 + for (index = 0; index < end; index++)
88832 + hash ^= hash + data[index];
88833 + latent_entropy ^= hash;
88834 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
88835 + }
88836 +#endif
88837 +
88838 page_zone(page)->managed_pages += 1 << order;
88839 set_page_refcounted(page);
88840 __free_pages(page, order);
88841 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
88842 arch_alloc_page(page, order);
88843 kernel_map_pages(page, 1 << order, 1);
88844
88845 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
88846 if (gfp_flags & __GFP_ZERO)
88847 prep_zero_page(page, order, gfp_flags);
88848 +#endif
88849
88850 if (order && (gfp_flags & __GFP_COMP))
88851 prep_compound_page(page, order);
88852 diff --git a/mm/page_io.c b/mm/page_io.c
88853 index ba05b64..ef2f314 100644
88854 --- a/mm/page_io.c
88855 +++ b/mm/page_io.c
88856 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
88857 struct file *swap_file = sis->swap_file;
88858 struct address_space *mapping = swap_file->f_mapping;
88859 struct iovec iov = {
88860 - .iov_base = kmap(page),
88861 + .iov_base = (void __force_user *)kmap(page),
88862 .iov_len = PAGE_SIZE,
88863 };
88864
88865 diff --git a/mm/percpu.c b/mm/percpu.c
88866 index 8c8e08f..73a5cda 100644
88867 --- a/mm/percpu.c
88868 +++ b/mm/percpu.c
88869 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
88870 static unsigned int pcpu_high_unit_cpu __read_mostly;
88871
88872 /* the address of the first chunk which starts with the kernel static area */
88873 -void *pcpu_base_addr __read_mostly;
88874 +void *pcpu_base_addr __read_only;
88875 EXPORT_SYMBOL_GPL(pcpu_base_addr);
88876
88877 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
88878 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
88879 index fd26d04..0cea1b0 100644
88880 --- a/mm/process_vm_access.c
88881 +++ b/mm/process_vm_access.c
88882 @@ -13,6 +13,7 @@
88883 #include <linux/uio.h>
88884 #include <linux/sched.h>
88885 #include <linux/highmem.h>
88886 +#include <linux/security.h>
88887 #include <linux/ptrace.h>
88888 #include <linux/slab.h>
88889 #include <linux/syscalls.h>
88890 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
88891 size_t iov_l_curr_offset = 0;
88892 ssize_t iov_len;
88893
88894 + return -ENOSYS; // PaX: until properly audited
88895 +
88896 /*
88897 * Work out how many pages of struct pages we're going to need
88898 * when eventually calling get_user_pages
88899 */
88900 for (i = 0; i < riovcnt; i++) {
88901 iov_len = rvec[i].iov_len;
88902 - if (iov_len > 0) {
88903 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
88904 - + iov_len)
88905 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
88906 - / PAGE_SIZE + 1;
88907 - nr_pages = max(nr_pages, nr_pages_iov);
88908 - }
88909 + if (iov_len <= 0)
88910 + continue;
88911 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
88912 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
88913 + nr_pages = max(nr_pages, nr_pages_iov);
88914 }
88915
88916 if (nr_pages == 0)
88917 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
88918 goto free_proc_pages;
88919 }
88920
88921 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
88922 + rc = -EPERM;
88923 + goto put_task_struct;
88924 + }
88925 +
88926 mm = mm_access(task, PTRACE_MODE_ATTACH);
88927 if (!mm || IS_ERR(mm)) {
88928 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
88929 diff --git a/mm/rmap.c b/mm/rmap.c
88930 index b2e29ac..4168491 100644
88931 --- a/mm/rmap.c
88932 +++ b/mm/rmap.c
88933 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
88934 struct anon_vma *anon_vma = vma->anon_vma;
88935 struct anon_vma_chain *avc;
88936
88937 +#ifdef CONFIG_PAX_SEGMEXEC
88938 + struct anon_vma_chain *avc_m = NULL;
88939 +#endif
88940 +
88941 might_sleep();
88942 if (unlikely(!anon_vma)) {
88943 struct mm_struct *mm = vma->vm_mm;
88944 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
88945 if (!avc)
88946 goto out_enomem;
88947
88948 +#ifdef CONFIG_PAX_SEGMEXEC
88949 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
88950 + if (!avc_m)
88951 + goto out_enomem_free_avc;
88952 +#endif
88953 +
88954 anon_vma = find_mergeable_anon_vma(vma);
88955 allocated = NULL;
88956 if (!anon_vma) {
88957 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
88958 /* page_table_lock to protect against threads */
88959 spin_lock(&mm->page_table_lock);
88960 if (likely(!vma->anon_vma)) {
88961 +
88962 +#ifdef CONFIG_PAX_SEGMEXEC
88963 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
88964 +
88965 + if (vma_m) {
88966 + BUG_ON(vma_m->anon_vma);
88967 + vma_m->anon_vma = anon_vma;
88968 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
88969 + avc_m = NULL;
88970 + }
88971 +#endif
88972 +
88973 vma->anon_vma = anon_vma;
88974 anon_vma_chain_link(vma, avc, anon_vma);
88975 allocated = NULL;
88976 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
88977
88978 if (unlikely(allocated))
88979 put_anon_vma(allocated);
88980 +
88981 +#ifdef CONFIG_PAX_SEGMEXEC
88982 + if (unlikely(avc_m))
88983 + anon_vma_chain_free(avc_m);
88984 +#endif
88985 +
88986 if (unlikely(avc))
88987 anon_vma_chain_free(avc);
88988 }
88989 return 0;
88990
88991 out_enomem_free_avc:
88992 +
88993 +#ifdef CONFIG_PAX_SEGMEXEC
88994 + if (avc_m)
88995 + anon_vma_chain_free(avc_m);
88996 +#endif
88997 +
88998 anon_vma_chain_free(avc);
88999 out_enomem:
89000 return -ENOMEM;
89001 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89002 * Attach the anon_vmas from src to dst.
89003 * Returns 0 on success, -ENOMEM on failure.
89004 */
89005 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89006 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89007 {
89008 struct anon_vma_chain *avc, *pavc;
89009 struct anon_vma *root = NULL;
89010 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89011 * the corresponding VMA in the parent process is attached to.
89012 * Returns 0 on success, non-zero on failure.
89013 */
89014 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89015 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89016 {
89017 struct anon_vma_chain *avc;
89018 struct anon_vma *anon_vma;
89019 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89020 void __init anon_vma_init(void)
89021 {
89022 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89023 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89024 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89025 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89026 + anon_vma_ctor);
89027 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89028 + SLAB_PANIC|SLAB_NO_SANITIZE);
89029 }
89030
89031 /*
89032 diff --git a/mm/shmem.c b/mm/shmem.c
89033 index e43dc55..930e3a2 100644
89034 --- a/mm/shmem.c
89035 +++ b/mm/shmem.c
89036 @@ -33,7 +33,7 @@
89037 #include <linux/swap.h>
89038 #include <linux/aio.h>
89039
89040 -static struct vfsmount *shm_mnt;
89041 +struct vfsmount *shm_mnt;
89042
89043 #ifdef CONFIG_SHMEM
89044 /*
89045 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89046 #define BOGO_DIRENT_SIZE 20
89047
89048 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89049 -#define SHORT_SYMLINK_LEN 128
89050 +#define SHORT_SYMLINK_LEN 64
89051
89052 /*
89053 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89054 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89055 static int shmem_xattr_validate(const char *name)
89056 {
89057 struct { const char *prefix; size_t len; } arr[] = {
89058 +
89059 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89060 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89061 +#endif
89062 +
89063 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89064 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89065 };
89066 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89067 if (err)
89068 return err;
89069
89070 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89071 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89072 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89073 + return -EOPNOTSUPP;
89074 + if (size > 8)
89075 + return -EINVAL;
89076 + }
89077 +#endif
89078 +
89079 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89080 }
89081
89082 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89083 int err = -ENOMEM;
89084
89085 /* Round up to L1_CACHE_BYTES to resist false sharing */
89086 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89087 - L1_CACHE_BYTES), GFP_KERNEL);
89088 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89089 if (!sbinfo)
89090 return -ENOMEM;
89091
89092 diff --git a/mm/slab.c b/mm/slab.c
89093 index 2580db0..0523956 100644
89094 --- a/mm/slab.c
89095 +++ b/mm/slab.c
89096 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89097 if ((x)->max_freeable < i) \
89098 (x)->max_freeable = i; \
89099 } while (0)
89100 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89101 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89102 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89103 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89104 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89105 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89106 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89107 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89108 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89109 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89110 #else
89111 #define STATS_INC_ACTIVE(x) do { } while (0)
89112 #define STATS_DEC_ACTIVE(x) do { } while (0)
89113 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89114 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89115 #define STATS_INC_FREEHIT(x) do { } while (0)
89116 #define STATS_INC_FREEMISS(x) do { } while (0)
89117 +#define STATS_INC_SANITIZED(x) do { } while (0)
89118 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89119 #endif
89120
89121 #if DEBUG
89122 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89123 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89124 */
89125 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89126 - const struct slab *slab, void *obj)
89127 + const struct slab *slab, const void *obj)
89128 {
89129 u32 offset = (obj - slab->s_mem);
89130 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89131 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89132 */
89133
89134 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89135 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89136 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89137
89138 if (INDEX_AC != INDEX_NODE)
89139 kmalloc_caches[INDEX_NODE] =
89140 create_kmalloc_cache("kmalloc-node",
89141 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89142 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89143
89144 slab_early_init = 0;
89145
89146 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89147 struct array_cache *ac = cpu_cache_get(cachep);
89148
89149 check_irq_off();
89150 +
89151 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89152 + if (pax_sanitize_slab) {
89153 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89154 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89155 +
89156 + if (cachep->ctor)
89157 + cachep->ctor(objp);
89158 +
89159 + STATS_INC_SANITIZED(cachep);
89160 + } else
89161 + STATS_INC_NOT_SANITIZED(cachep);
89162 + }
89163 +#endif
89164 +
89165 kmemleak_free_recursive(objp, cachep->flags);
89166 objp = cache_free_debugcheck(cachep, objp, caller);
89167
89168 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89169
89170 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89171 return;
89172 + VM_BUG_ON(!virt_addr_valid(objp));
89173 local_irq_save(flags);
89174 kfree_debugcheck(objp);
89175 c = virt_to_cache(objp);
89176 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89177 }
89178 /* cpu stats */
89179 {
89180 - unsigned long allochit = atomic_read(&cachep->allochit);
89181 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89182 - unsigned long freehit = atomic_read(&cachep->freehit);
89183 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89184 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89185 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89186 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89187 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89188
89189 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89190 allochit, allocmiss, freehit, freemiss);
89191 }
89192 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89193 + {
89194 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89195 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89196 +
89197 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89198 + }
89199 +#endif
89200 #endif
89201 }
89202
89203 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89204 static int __init slab_proc_init(void)
89205 {
89206 #ifdef CONFIG_DEBUG_SLAB_LEAK
89207 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89208 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89209 #endif
89210 return 0;
89211 }
89212 module_init(slab_proc_init);
89213 #endif
89214
89215 +bool is_usercopy_object(const void *ptr)
89216 +{
89217 + struct page *page;
89218 + struct kmem_cache *cachep;
89219 +
89220 + if (ZERO_OR_NULL_PTR(ptr))
89221 + return false;
89222 +
89223 + if (!slab_is_available())
89224 + return false;
89225 +
89226 + if (!virt_addr_valid(ptr))
89227 + return false;
89228 +
89229 + page = virt_to_head_page(ptr);
89230 +
89231 + if (!PageSlab(page))
89232 + return false;
89233 +
89234 + cachep = page->slab_cache;
89235 + return cachep->flags & SLAB_USERCOPY;
89236 +}
89237 +
89238 +#ifdef CONFIG_PAX_USERCOPY
89239 +const char *check_heap_object(const void *ptr, unsigned long n)
89240 +{
89241 + struct page *page;
89242 + struct kmem_cache *cachep;
89243 + struct slab *slabp;
89244 + unsigned int objnr;
89245 + unsigned long offset;
89246 +
89247 + if (ZERO_OR_NULL_PTR(ptr))
89248 + return "<null>";
89249 +
89250 + if (!virt_addr_valid(ptr))
89251 + return NULL;
89252 +
89253 + page = virt_to_head_page(ptr);
89254 +
89255 + if (!PageSlab(page))
89256 + return NULL;
89257 +
89258 + cachep = page->slab_cache;
89259 + if (!(cachep->flags & SLAB_USERCOPY))
89260 + return cachep->name;
89261 +
89262 + slabp = page->slab_page;
89263 + objnr = obj_to_index(cachep, slabp, ptr);
89264 + BUG_ON(objnr >= cachep->num);
89265 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89266 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89267 + return NULL;
89268 +
89269 + return cachep->name;
89270 +}
89271 +#endif
89272 +
89273 /**
89274 * ksize - get the actual amount of memory allocated for a given object
89275 * @objp: Pointer to the object
89276 diff --git a/mm/slab.h b/mm/slab.h
89277 index a535033..2f98fe5 100644
89278 --- a/mm/slab.h
89279 +++ b/mm/slab.h
89280 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89281 /* The slab cache that manages slab cache information */
89282 extern struct kmem_cache *kmem_cache;
89283
89284 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89285 +#ifdef CONFIG_X86_64
89286 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89287 +#else
89288 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89289 +#endif
89290 +extern bool pax_sanitize_slab;
89291 +#endif
89292 +
89293 unsigned long calculate_alignment(unsigned long flags,
89294 unsigned long align, unsigned long size);
89295
89296 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89297
89298 /* Legal flag mask for kmem_cache_create(), for various configurations */
89299 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89300 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89301 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89302 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89303
89304 #if defined(CONFIG_DEBUG_SLAB)
89305 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89306 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89307 return s;
89308
89309 page = virt_to_head_page(x);
89310 +
89311 + BUG_ON(!PageSlab(page));
89312 +
89313 cachep = page->slab_cache;
89314 if (slab_equal_or_root(cachep, s))
89315 return cachep;
89316 diff --git a/mm/slab_common.c b/mm/slab_common.c
89317 index 538bade..36fed99 100644
89318 --- a/mm/slab_common.c
89319 +++ b/mm/slab_common.c
89320 @@ -22,11 +22,22 @@
89321
89322 #include "slab.h"
89323
89324 -enum slab_state slab_state;
89325 +enum slab_state slab_state __read_only;
89326 LIST_HEAD(slab_caches);
89327 DEFINE_MUTEX(slab_mutex);
89328 struct kmem_cache *kmem_cache;
89329
89330 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89331 +bool pax_sanitize_slab __read_only = true;
89332 +static int __init pax_sanitize_slab_setup(char *str)
89333 +{
89334 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89335 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89336 + return 1;
89337 +}
89338 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89339 +#endif
89340 +
89341 #ifdef CONFIG_DEBUG_VM
89342 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89343 size_t size)
89344 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89345
89346 err = __kmem_cache_create(s, flags);
89347 if (!err) {
89348 - s->refcount = 1;
89349 + atomic_set(&s->refcount, 1);
89350 list_add(&s->list, &slab_caches);
89351 memcg_cache_list_add(memcg, s);
89352 } else {
89353 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89354
89355 get_online_cpus();
89356 mutex_lock(&slab_mutex);
89357 - s->refcount--;
89358 - if (!s->refcount) {
89359 + if (atomic_dec_and_test(&s->refcount)) {
89360 list_del(&s->list);
89361
89362 if (!__kmem_cache_shutdown(s)) {
89363 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89364 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89365 name, size, err);
89366
89367 - s->refcount = -1; /* Exempt from merging for now */
89368 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89369 }
89370
89371 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89372 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89373
89374 create_boot_cache(s, name, size, flags);
89375 list_add(&s->list, &slab_caches);
89376 - s->refcount = 1;
89377 + atomic_set(&s->refcount, 1);
89378 return s;
89379 }
89380
89381 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89382 EXPORT_SYMBOL(kmalloc_dma_caches);
89383 #endif
89384
89385 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89386 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89387 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89388 +#endif
89389 +
89390 /*
89391 * Conversion table for small slabs sizes / 8 to the index in the
89392 * kmalloc array. This is necessary for slabs < 192 since we have non power
89393 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89394 return kmalloc_dma_caches[index];
89395
89396 #endif
89397 +
89398 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89399 + if (unlikely((flags & GFP_USERCOPY)))
89400 + return kmalloc_usercopy_caches[index];
89401 +
89402 +#endif
89403 +
89404 return kmalloc_caches[index];
89405 }
89406
89407 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89408 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89409 if (!kmalloc_caches[i]) {
89410 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89411 - 1 << i, flags);
89412 + 1 << i, SLAB_USERCOPY | flags);
89413 }
89414
89415 /*
89416 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89417 * earlier power of two caches
89418 */
89419 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89420 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89421 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89422
89423 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89424 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89425 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89426 }
89427
89428 /* Kmalloc array is now usable */
89429 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89430 }
89431 }
89432 #endif
89433 +
89434 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89435 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89436 + struct kmem_cache *s = kmalloc_caches[i];
89437 +
89438 + if (s) {
89439 + int size = kmalloc_size(i);
89440 + char *n = kasprintf(GFP_NOWAIT,
89441 + "usercopy-kmalloc-%d", size);
89442 +
89443 + BUG_ON(!n);
89444 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89445 + size, SLAB_USERCOPY | flags);
89446 + }
89447 + }
89448 +#endif
89449 +
89450 }
89451 #endif /* !CONFIG_SLOB */
89452
89453 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89454 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89455 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89456 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89457 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89458 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89459 +#endif
89460 #endif
89461 seq_putc(m, '\n');
89462 }
89463 diff --git a/mm/slob.c b/mm/slob.c
89464 index 91bd3f2..e2f549e 100644
89465 --- a/mm/slob.c
89466 +++ b/mm/slob.c
89467 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89468 /*
89469 * Return the size of a slob block.
89470 */
89471 -static slobidx_t slob_units(slob_t *s)
89472 +static slobidx_t slob_units(const slob_t *s)
89473 {
89474 if (s->units > 0)
89475 return s->units;
89476 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89477 /*
89478 * Return the next free slob block pointer after this one.
89479 */
89480 -static slob_t *slob_next(slob_t *s)
89481 +static slob_t *slob_next(const slob_t *s)
89482 {
89483 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89484 slobidx_t next;
89485 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89486 /*
89487 * Returns true if s is the last free block in its page.
89488 */
89489 -static int slob_last(slob_t *s)
89490 +static int slob_last(const slob_t *s)
89491 {
89492 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89493 }
89494
89495 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89496 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89497 {
89498 - void *page;
89499 + struct page *page;
89500
89501 #ifdef CONFIG_NUMA
89502 if (node != NUMA_NO_NODE)
89503 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89504 if (!page)
89505 return NULL;
89506
89507 - return page_address(page);
89508 + __SetPageSlab(page);
89509 + return page;
89510 }
89511
89512 -static void slob_free_pages(void *b, int order)
89513 +static void slob_free_pages(struct page *sp, int order)
89514 {
89515 if (current->reclaim_state)
89516 current->reclaim_state->reclaimed_slab += 1 << order;
89517 - free_pages((unsigned long)b, order);
89518 + __ClearPageSlab(sp);
89519 + page_mapcount_reset(sp);
89520 + sp->private = 0;
89521 + __free_pages(sp, order);
89522 }
89523
89524 /*
89525 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89526
89527 /* Not enough space: must allocate a new page */
89528 if (!b) {
89529 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89530 - if (!b)
89531 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89532 + if (!sp)
89533 return NULL;
89534 - sp = virt_to_page(b);
89535 - __SetPageSlab(sp);
89536 + b = page_address(sp);
89537
89538 spin_lock_irqsave(&slob_lock, flags);
89539 sp->units = SLOB_UNITS(PAGE_SIZE);
89540 sp->freelist = b;
89541 + sp->private = 0;
89542 INIT_LIST_HEAD(&sp->list);
89543 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89544 set_slob_page_free(sp, slob_list);
89545 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89546 if (slob_page_free(sp))
89547 clear_slob_page_free(sp);
89548 spin_unlock_irqrestore(&slob_lock, flags);
89549 - __ClearPageSlab(sp);
89550 - page_mapcount_reset(sp);
89551 - slob_free_pages(b, 0);
89552 + slob_free_pages(sp, 0);
89553 return;
89554 }
89555
89556 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89557 + if (pax_sanitize_slab)
89558 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89559 +#endif
89560 +
89561 if (!slob_page_free(sp)) {
89562 /* This slob page is about to become partially free. Easy! */
89563 sp->units = units;
89564 @@ -424,11 +431,10 @@ out:
89565 */
89566
89567 static __always_inline void *
89568 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89569 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89570 {
89571 - unsigned int *m;
89572 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89573 - void *ret;
89574 + slob_t *m;
89575 + void *ret = NULL;
89576
89577 gfp &= gfp_allowed_mask;
89578
89579 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89580
89581 if (!m)
89582 return NULL;
89583 - *m = size;
89584 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89585 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89586 + m[0].units = size;
89587 + m[1].units = align;
89588 ret = (void *)m + align;
89589
89590 trace_kmalloc_node(caller, ret,
89591 size, size + align, gfp, node);
89592 } else {
89593 unsigned int order = get_order(size);
89594 + struct page *page;
89595
89596 if (likely(order))
89597 gfp |= __GFP_COMP;
89598 - ret = slob_new_pages(gfp, order, node);
89599 + page = slob_new_pages(gfp, order, node);
89600 + if (page) {
89601 + ret = page_address(page);
89602 + page->private = size;
89603 + }
89604
89605 trace_kmalloc_node(caller, ret,
89606 size, PAGE_SIZE << order, gfp, node);
89607 }
89608
89609 - kmemleak_alloc(ret, size, 1, gfp);
89610 + return ret;
89611 +}
89612 +
89613 +static __always_inline void *
89614 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89615 +{
89616 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89617 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89618 +
89619 + if (!ZERO_OR_NULL_PTR(ret))
89620 + kmemleak_alloc(ret, size, 1, gfp);
89621 return ret;
89622 }
89623
89624 @@ -493,34 +517,112 @@ void kfree(const void *block)
89625 return;
89626 kmemleak_free(block);
89627
89628 + VM_BUG_ON(!virt_addr_valid(block));
89629 sp = virt_to_page(block);
89630 - if (PageSlab(sp)) {
89631 + VM_BUG_ON(!PageSlab(sp));
89632 + if (!sp->private) {
89633 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89634 - unsigned int *m = (unsigned int *)(block - align);
89635 - slob_free(m, *m + align);
89636 - } else
89637 + slob_t *m = (slob_t *)(block - align);
89638 + slob_free(m, m[0].units + align);
89639 + } else {
89640 + __ClearPageSlab(sp);
89641 + page_mapcount_reset(sp);
89642 + sp->private = 0;
89643 __free_pages(sp, compound_order(sp));
89644 + }
89645 }
89646 EXPORT_SYMBOL(kfree);
89647
89648 +bool is_usercopy_object(const void *ptr)
89649 +{
89650 + if (!slab_is_available())
89651 + return false;
89652 +
89653 + // PAX: TODO
89654 +
89655 + return false;
89656 +}
89657 +
89658 +#ifdef CONFIG_PAX_USERCOPY
89659 +const char *check_heap_object(const void *ptr, unsigned long n)
89660 +{
89661 + struct page *page;
89662 + const slob_t *free;
89663 + const void *base;
89664 + unsigned long flags;
89665 +
89666 + if (ZERO_OR_NULL_PTR(ptr))
89667 + return "<null>";
89668 +
89669 + if (!virt_addr_valid(ptr))
89670 + return NULL;
89671 +
89672 + page = virt_to_head_page(ptr);
89673 + if (!PageSlab(page))
89674 + return NULL;
89675 +
89676 + if (page->private) {
89677 + base = page;
89678 + if (base <= ptr && n <= page->private - (ptr - base))
89679 + return NULL;
89680 + return "<slob>";
89681 + }
89682 +
89683 + /* some tricky double walking to find the chunk */
89684 + spin_lock_irqsave(&slob_lock, flags);
89685 + base = (void *)((unsigned long)ptr & PAGE_MASK);
89686 + free = page->freelist;
89687 +
89688 + while (!slob_last(free) && (void *)free <= ptr) {
89689 + base = free + slob_units(free);
89690 + free = slob_next(free);
89691 + }
89692 +
89693 + while (base < (void *)free) {
89694 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
89695 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
89696 + int offset;
89697 +
89698 + if (ptr < base + align)
89699 + break;
89700 +
89701 + offset = ptr - base - align;
89702 + if (offset >= m) {
89703 + base += size;
89704 + continue;
89705 + }
89706 +
89707 + if (n > m - offset)
89708 + break;
89709 +
89710 + spin_unlock_irqrestore(&slob_lock, flags);
89711 + return NULL;
89712 + }
89713 +
89714 + spin_unlock_irqrestore(&slob_lock, flags);
89715 + return "<slob>";
89716 +}
89717 +#endif
89718 +
89719 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
89720 size_t ksize(const void *block)
89721 {
89722 struct page *sp;
89723 int align;
89724 - unsigned int *m;
89725 + slob_t *m;
89726
89727 BUG_ON(!block);
89728 if (unlikely(block == ZERO_SIZE_PTR))
89729 return 0;
89730
89731 sp = virt_to_page(block);
89732 - if (unlikely(!PageSlab(sp)))
89733 - return PAGE_SIZE << compound_order(sp);
89734 + VM_BUG_ON(!PageSlab(sp));
89735 + if (sp->private)
89736 + return sp->private;
89737
89738 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89739 - m = (unsigned int *)(block - align);
89740 - return SLOB_UNITS(*m) * SLOB_UNIT;
89741 + m = (slob_t *)(block - align);
89742 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
89743 }
89744 EXPORT_SYMBOL(ksize);
89745
89746 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
89747
89748 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
89749 {
89750 - void *b;
89751 + void *b = NULL;
89752
89753 flags &= gfp_allowed_mask;
89754
89755 lockdep_trace_alloc(flags);
89756
89757 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89758 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
89759 +#else
89760 if (c->size < PAGE_SIZE) {
89761 b = slob_alloc(c->size, flags, c->align, node);
89762 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
89763 SLOB_UNITS(c->size) * SLOB_UNIT,
89764 flags, node);
89765 } else {
89766 - b = slob_new_pages(flags, get_order(c->size), node);
89767 + struct page *sp;
89768 +
89769 + sp = slob_new_pages(flags, get_order(c->size), node);
89770 + if (sp) {
89771 + b = page_address(sp);
89772 + sp->private = c->size;
89773 + }
89774 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
89775 PAGE_SIZE << get_order(c->size),
89776 flags, node);
89777 }
89778 +#endif
89779
89780 if (b && c->ctor)
89781 c->ctor(b);
89782 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
89783
89784 static void __kmem_cache_free(void *b, int size)
89785 {
89786 - if (size < PAGE_SIZE)
89787 + struct page *sp;
89788 +
89789 + sp = virt_to_page(b);
89790 + BUG_ON(!PageSlab(sp));
89791 + if (!sp->private)
89792 slob_free(b, size);
89793 else
89794 - slob_free_pages(b, get_order(size));
89795 + slob_free_pages(sp, get_order(size));
89796 }
89797
89798 static void kmem_rcu_free(struct rcu_head *head)
89799 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
89800
89801 void kmem_cache_free(struct kmem_cache *c, void *b)
89802 {
89803 + int size = c->size;
89804 +
89805 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89806 + if (size + c->align < PAGE_SIZE) {
89807 + size += c->align;
89808 + b -= c->align;
89809 + }
89810 +#endif
89811 +
89812 kmemleak_free_recursive(b, c->flags);
89813 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
89814 struct slob_rcu *slob_rcu;
89815 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
89816 - slob_rcu->size = c->size;
89817 + slob_rcu = b + (size - sizeof(struct slob_rcu));
89818 + slob_rcu->size = size;
89819 call_rcu(&slob_rcu->head, kmem_rcu_free);
89820 } else {
89821 - __kmem_cache_free(b, c->size);
89822 + __kmem_cache_free(b, size);
89823 }
89824
89825 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89826 + trace_kfree(_RET_IP_, b);
89827 +#else
89828 trace_kmem_cache_free(_RET_IP_, b);
89829 +#endif
89830 +
89831 }
89832 EXPORT_SYMBOL(kmem_cache_free);
89833
89834 diff --git a/mm/slub.c b/mm/slub.c
89835 index e3ba1f2..bd45dac 100644
89836 --- a/mm/slub.c
89837 +++ b/mm/slub.c
89838 @@ -207,7 +207,7 @@ struct track {
89839
89840 enum track_item { TRACK_ALLOC, TRACK_FREE };
89841
89842 -#ifdef CONFIG_SYSFS
89843 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89844 static int sysfs_slab_add(struct kmem_cache *);
89845 static int sysfs_slab_alias(struct kmem_cache *, const char *);
89846 static void sysfs_slab_remove(struct kmem_cache *);
89847 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
89848 if (!t->addr)
89849 return;
89850
89851 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
89852 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
89853 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
89854 #ifdef CONFIG_STACKTRACE
89855 {
89856 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
89857
89858 slab_free_hook(s, x);
89859
89860 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89861 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
89862 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
89863 + if (s->ctor)
89864 + s->ctor(x);
89865 + }
89866 +#endif
89867 +
89868 redo:
89869 /*
89870 * Determine the currently cpus per cpu slab.
89871 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
89872 * Merge control. If this is set then no merging of slab caches will occur.
89873 * (Could be removed. This was introduced to pacify the merge skeptics.)
89874 */
89875 -static int slub_nomerge;
89876 +static int slub_nomerge = 1;
89877
89878 /*
89879 * Calculate the order of allocation given an slab object size.
89880 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
89881 s->inuse = size;
89882
89883 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
89884 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89885 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
89886 +#endif
89887 s->ctor)) {
89888 /*
89889 * Relocate free pointer after the object if it is not
89890 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
89891 EXPORT_SYMBOL(__kmalloc_node);
89892 #endif
89893
89894 +bool is_usercopy_object(const void *ptr)
89895 +{
89896 + struct page *page;
89897 + struct kmem_cache *s;
89898 +
89899 + if (ZERO_OR_NULL_PTR(ptr))
89900 + return false;
89901 +
89902 + if (!slab_is_available())
89903 + return false;
89904 +
89905 + if (!virt_addr_valid(ptr))
89906 + return false;
89907 +
89908 + page = virt_to_head_page(ptr);
89909 +
89910 + if (!PageSlab(page))
89911 + return false;
89912 +
89913 + s = page->slab_cache;
89914 + return s->flags & SLAB_USERCOPY;
89915 +}
89916 +
89917 +#ifdef CONFIG_PAX_USERCOPY
89918 +const char *check_heap_object(const void *ptr, unsigned long n)
89919 +{
89920 + struct page *page;
89921 + struct kmem_cache *s;
89922 + unsigned long offset;
89923 +
89924 + if (ZERO_OR_NULL_PTR(ptr))
89925 + return "<null>";
89926 +
89927 + if (!virt_addr_valid(ptr))
89928 + return NULL;
89929 +
89930 + page = virt_to_head_page(ptr);
89931 +
89932 + if (!PageSlab(page))
89933 + return NULL;
89934 +
89935 + s = page->slab_cache;
89936 + if (!(s->flags & SLAB_USERCOPY))
89937 + return s->name;
89938 +
89939 + offset = (ptr - page_address(page)) % s->size;
89940 + if (offset <= s->object_size && n <= s->object_size - offset)
89941 + return NULL;
89942 +
89943 + return s->name;
89944 +}
89945 +#endif
89946 +
89947 size_t ksize(const void *object)
89948 {
89949 struct page *page;
89950 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
89951 if (unlikely(ZERO_OR_NULL_PTR(x)))
89952 return;
89953
89954 + VM_BUG_ON(!virt_addr_valid(x));
89955 page = virt_to_head_page(x);
89956 if (unlikely(!PageSlab(page))) {
89957 BUG_ON(!PageCompound(page));
89958 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
89959 /*
89960 * We may have set a slab to be unmergeable during bootstrap.
89961 */
89962 - if (s->refcount < 0)
89963 + if (atomic_read(&s->refcount) < 0)
89964 return 1;
89965
89966 return 0;
89967 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89968
89969 s = find_mergeable(memcg, size, align, flags, name, ctor);
89970 if (s) {
89971 - s->refcount++;
89972 + atomic_inc(&s->refcount);
89973 /*
89974 * Adjust the object sizes so that we clear
89975 * the complete object on kzalloc.
89976 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89977 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
89978
89979 if (sysfs_slab_alias(s, name)) {
89980 - s->refcount--;
89981 + atomic_dec(&s->refcount);
89982 s = NULL;
89983 }
89984 }
89985 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
89986 }
89987 #endif
89988
89989 -#ifdef CONFIG_SYSFS
89990 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89991 static int count_inuse(struct page *page)
89992 {
89993 return page->inuse;
89994 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
89995 validate_slab_cache(kmalloc_caches[9]);
89996 }
89997 #else
89998 -#ifdef CONFIG_SYSFS
89999 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90000 static void resiliency_test(void) {};
90001 #endif
90002 #endif
90003
90004 -#ifdef CONFIG_SYSFS
90005 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90006 enum slab_stat_type {
90007 SL_ALL, /* All slabs */
90008 SL_PARTIAL, /* Only partially allocated slabs */
90009 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90010
90011 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90012 {
90013 - return sprintf(buf, "%d\n", s->refcount - 1);
90014 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90015 }
90016 SLAB_ATTR_RO(aliases);
90017
90018 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90019 SLAB_ATTR_RO(cache_dma);
90020 #endif
90021
90022 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90023 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90024 +{
90025 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90026 +}
90027 +SLAB_ATTR_RO(usercopy);
90028 +#endif
90029 +
90030 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90031 {
90032 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90033 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90034 #ifdef CONFIG_ZONE_DMA
90035 &cache_dma_attr.attr,
90036 #endif
90037 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90038 + &usercopy_attr.attr,
90039 +#endif
90040 #ifdef CONFIG_NUMA
90041 &remote_node_defrag_ratio_attr.attr,
90042 #endif
90043 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90044 return name;
90045 }
90046
90047 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90048 static int sysfs_slab_add(struct kmem_cache *s)
90049 {
90050 int err;
90051 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90052 }
90053
90054 s->kobj.kset = slab_kset;
90055 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90056 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90057 if (err) {
90058 kobject_put(&s->kobj);
90059 return err;
90060 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90061 kobject_del(&s->kobj);
90062 kobject_put(&s->kobj);
90063 }
90064 +#endif
90065
90066 /*
90067 * Need to buffer aliases during bootup until sysfs becomes
90068 @@ -5213,6 +5291,7 @@ struct saved_alias {
90069
90070 static struct saved_alias *alias_list;
90071
90072 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90073 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90074 {
90075 struct saved_alias *al;
90076 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90077 alias_list = al;
90078 return 0;
90079 }
90080 +#endif
90081
90082 static int __init slab_sysfs_init(void)
90083 {
90084 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90085 index 27eeab3..7c3f7f2 100644
90086 --- a/mm/sparse-vmemmap.c
90087 +++ b/mm/sparse-vmemmap.c
90088 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90089 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90090 if (!p)
90091 return NULL;
90092 - pud_populate(&init_mm, pud, p);
90093 + pud_populate_kernel(&init_mm, pud, p);
90094 }
90095 return pud;
90096 }
90097 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90098 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90099 if (!p)
90100 return NULL;
90101 - pgd_populate(&init_mm, pgd, p);
90102 + pgd_populate_kernel(&init_mm, pgd, p);
90103 }
90104 return pgd;
90105 }
90106 diff --git a/mm/sparse.c b/mm/sparse.c
90107 index 308d503..3dbbd04 100644
90108 --- a/mm/sparse.c
90109 +++ b/mm/sparse.c
90110 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90111
90112 for (i = 0; i < PAGES_PER_SECTION; i++) {
90113 if (PageHWPoison(&memmap[i])) {
90114 - atomic_long_sub(1, &num_poisoned_pages);
90115 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90116 ClearPageHWPoison(&memmap[i]);
90117 }
90118 }
90119 diff --git a/mm/swap.c b/mm/swap.c
90120 index c899502..d4dc2cd 100644
90121 --- a/mm/swap.c
90122 +++ b/mm/swap.c
90123 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
90124
90125 __page_cache_release(page);
90126 dtor = get_compound_page_dtor(page);
90127 + if (!PageHuge(page))
90128 + BUG_ON(dtor != free_compound_page);
90129 (*dtor)(page);
90130 }
90131
90132 diff --git a/mm/swapfile.c b/mm/swapfile.c
90133 index 6cf2e60..d204b3e 100644
90134 --- a/mm/swapfile.c
90135 +++ b/mm/swapfile.c
90136 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90137
90138 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90139 /* Activity counter to indicate that a swapon or swapoff has occurred */
90140 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90141 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90142
90143 static inline unsigned char swap_count(unsigned char ent)
90144 {
90145 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90146 }
90147 filp_close(swap_file, NULL);
90148 err = 0;
90149 - atomic_inc(&proc_poll_event);
90150 + atomic_inc_unchecked(&proc_poll_event);
90151 wake_up_interruptible(&proc_poll_wait);
90152
90153 out_dput:
90154 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90155
90156 poll_wait(file, &proc_poll_wait, wait);
90157
90158 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90159 - seq->poll_event = atomic_read(&proc_poll_event);
90160 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90161 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90162 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90163 }
90164
90165 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90166 return ret;
90167
90168 seq = file->private_data;
90169 - seq->poll_event = atomic_read(&proc_poll_event);
90170 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90171 return 0;
90172 }
90173
90174 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90175 (frontswap_map) ? "FS" : "");
90176
90177 mutex_unlock(&swapon_mutex);
90178 - atomic_inc(&proc_poll_event);
90179 + atomic_inc_unchecked(&proc_poll_event);
90180 wake_up_interruptible(&proc_poll_wait);
90181
90182 if (S_ISREG(inode->i_mode))
90183 diff --git a/mm/util.c b/mm/util.c
90184 index 7441c41..c3de793 100644
90185 --- a/mm/util.c
90186 +++ b/mm/util.c
90187 @@ -294,6 +294,12 @@ done:
90188 void arch_pick_mmap_layout(struct mm_struct *mm)
90189 {
90190 mm->mmap_base = TASK_UNMAPPED_BASE;
90191 +
90192 +#ifdef CONFIG_PAX_RANDMMAP
90193 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90194 + mm->mmap_base += mm->delta_mmap;
90195 +#endif
90196 +
90197 mm->get_unmapped_area = arch_get_unmapped_area;
90198 }
90199 #endif
90200 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90201 index 13a5495..6707d97 100644
90202 --- a/mm/vmalloc.c
90203 +++ b/mm/vmalloc.c
90204 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90205
90206 pte = pte_offset_kernel(pmd, addr);
90207 do {
90208 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90209 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90210 +
90211 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90212 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90213 + BUG_ON(!pte_exec(*pte));
90214 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90215 + continue;
90216 + }
90217 +#endif
90218 +
90219 + {
90220 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90221 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90222 + }
90223 } while (pte++, addr += PAGE_SIZE, addr != end);
90224 }
90225
90226 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90227 pte = pte_alloc_kernel(pmd, addr);
90228 if (!pte)
90229 return -ENOMEM;
90230 +
90231 + pax_open_kernel();
90232 do {
90233 struct page *page = pages[*nr];
90234
90235 - if (WARN_ON(!pte_none(*pte)))
90236 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90237 + if (pgprot_val(prot) & _PAGE_NX)
90238 +#endif
90239 +
90240 + if (!pte_none(*pte)) {
90241 + pax_close_kernel();
90242 + WARN_ON(1);
90243 return -EBUSY;
90244 - if (WARN_ON(!page))
90245 + }
90246 + if (!page) {
90247 + pax_close_kernel();
90248 + WARN_ON(1);
90249 return -ENOMEM;
90250 + }
90251 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90252 (*nr)++;
90253 } while (pte++, addr += PAGE_SIZE, addr != end);
90254 + pax_close_kernel();
90255 return 0;
90256 }
90257
90258 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90259 pmd_t *pmd;
90260 unsigned long next;
90261
90262 - pmd = pmd_alloc(&init_mm, pud, addr);
90263 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90264 if (!pmd)
90265 return -ENOMEM;
90266 do {
90267 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90268 pud_t *pud;
90269 unsigned long next;
90270
90271 - pud = pud_alloc(&init_mm, pgd, addr);
90272 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90273 if (!pud)
90274 return -ENOMEM;
90275 do {
90276 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90277 if (addr >= MODULES_VADDR && addr < MODULES_END)
90278 return 1;
90279 #endif
90280 +
90281 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90282 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90283 + return 1;
90284 +#endif
90285 +
90286 return is_vmalloc_addr(x);
90287 }
90288
90289 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90290
90291 if (!pgd_none(*pgd)) {
90292 pud_t *pud = pud_offset(pgd, addr);
90293 +#ifdef CONFIG_X86
90294 + if (!pud_large(*pud))
90295 +#endif
90296 if (!pud_none(*pud)) {
90297 pmd_t *pmd = pmd_offset(pud, addr);
90298 +#ifdef CONFIG_X86
90299 + if (!pmd_large(*pmd))
90300 +#endif
90301 if (!pmd_none(*pmd)) {
90302 pte_t *ptep, pte;
90303
90304 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90305 * Allocate a region of KVA of the specified size and alignment, within the
90306 * vstart and vend.
90307 */
90308 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90309 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90310 unsigned long align,
90311 unsigned long vstart, unsigned long vend,
90312 int node, gfp_t gfp_mask)
90313 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90314 struct vm_struct *area;
90315
90316 BUG_ON(in_interrupt());
90317 +
90318 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90319 + if (flags & VM_KERNEXEC) {
90320 + if (start != VMALLOC_START || end != VMALLOC_END)
90321 + return NULL;
90322 + start = (unsigned long)MODULES_EXEC_VADDR;
90323 + end = (unsigned long)MODULES_EXEC_END;
90324 + }
90325 +#endif
90326 +
90327 if (flags & VM_IOREMAP)
90328 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90329
90330 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90331 if (count > totalram_pages)
90332 return NULL;
90333
90334 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90335 + if (!(pgprot_val(prot) & _PAGE_NX))
90336 + flags |= VM_KERNEXEC;
90337 +#endif
90338 +
90339 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90340 __builtin_return_address(0));
90341 if (!area)
90342 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90343 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90344 goto fail;
90345
90346 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90347 + if (!(pgprot_val(prot) & _PAGE_NX))
90348 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90349 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90350 + else
90351 +#endif
90352 +
90353 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90354 start, end, node, gfp_mask, caller);
90355 if (!area)
90356 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90357 * For tight control over page level allocator and protection flags
90358 * use __vmalloc() instead.
90359 */
90360 -
90361 void *vmalloc_exec(unsigned long size)
90362 {
90363 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90364 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90365 NUMA_NO_NODE, __builtin_return_address(0));
90366 }
90367
90368 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90369 {
90370 struct vm_struct *area;
90371
90372 + BUG_ON(vma->vm_mirror);
90373 +
90374 size = PAGE_ALIGN(size);
90375
90376 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90377 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90378 v->addr, v->addr + v->size, v->size);
90379
90380 if (v->caller)
90381 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90382 + seq_printf(m, " %pK", v->caller);
90383 +#else
90384 seq_printf(m, " %pS", v->caller);
90385 +#endif
90386
90387 if (v->nr_pages)
90388 seq_printf(m, " pages=%d", v->nr_pages);
90389 diff --git a/mm/vmstat.c b/mm/vmstat.c
90390 index 20c2ef4..15e7ab7 100644
90391 --- a/mm/vmstat.c
90392 +++ b/mm/vmstat.c
90393 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90394 *
90395 * vm_stat contains the global counters
90396 */
90397 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90398 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90399 EXPORT_SYMBOL(vm_stat);
90400
90401 #ifdef CONFIG_SMP
90402 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90403 v = p->vm_stat_diff[i];
90404 p->vm_stat_diff[i] = 0;
90405 local_irq_restore(flags);
90406 - atomic_long_add(v, &zone->vm_stat[i]);
90407 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90408 global_diff[i] += v;
90409 #ifdef CONFIG_NUMA
90410 /* 3 seconds idle till flush */
90411 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90412
90413 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90414 if (global_diff[i])
90415 - atomic_long_add(global_diff[i], &vm_stat[i]);
90416 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90417 }
90418
90419 /*
90420 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90421 if (pset->vm_stat_diff[i]) {
90422 int v = pset->vm_stat_diff[i];
90423 pset->vm_stat_diff[i] = 0;
90424 - atomic_long_add(v, &zone->vm_stat[i]);
90425 - atomic_long_add(v, &vm_stat[i]);
90426 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90427 + atomic_long_add_unchecked(v, &vm_stat[i]);
90428 }
90429 }
90430 #endif
90431 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90432 start_cpu_timer(cpu);
90433 #endif
90434 #ifdef CONFIG_PROC_FS
90435 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90436 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90437 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90438 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90439 + {
90440 + mode_t gr_mode = S_IRUGO;
90441 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90442 + gr_mode = S_IRUSR;
90443 +#endif
90444 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90445 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90446 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90447 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90448 +#else
90449 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90450 +#endif
90451 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90452 + }
90453 #endif
90454 return 0;
90455 }
90456 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90457 index 2fb2d88..8c06e40 100644
90458 --- a/net/8021q/vlan.c
90459 +++ b/net/8021q/vlan.c
90460 @@ -469,7 +469,7 @@ out:
90461 return NOTIFY_DONE;
90462 }
90463
90464 -static struct notifier_block vlan_notifier_block __read_mostly = {
90465 +static struct notifier_block vlan_notifier_block = {
90466 .notifier_call = vlan_device_event,
90467 };
90468
90469 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90470 err = -EPERM;
90471 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90472 break;
90473 - if ((args.u.name_type >= 0) &&
90474 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90475 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90476 struct vlan_net *vn;
90477
90478 vn = net_generic(net, vlan_net_id);
90479 diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
90480 index 3091297..c7e634a 100644
90481 --- a/net/8021q/vlan_netlink.c
90482 +++ b/net/8021q/vlan_netlink.c
90483 @@ -171,7 +171,7 @@ static size_t vlan_get_size(const struct net_device *dev)
90484
90485 return nla_total_size(2) + /* IFLA_VLAN_PROTOCOL */
90486 nla_total_size(2) + /* IFLA_VLAN_ID */
90487 - sizeof(struct ifla_vlan_flags) + /* IFLA_VLAN_FLAGS */
90488 + nla_total_size(sizeof(struct ifla_vlan_flags)) + /* IFLA_VLAN_FLAGS */
90489 vlan_qos_map_size(vlan->nr_ingress_mappings) +
90490 vlan_qos_map_size(vlan->nr_egress_mappings);
90491 }
90492 diff --git a/net/9p/mod.c b/net/9p/mod.c
90493 index 6ab36ae..6f1841b 100644
90494 --- a/net/9p/mod.c
90495 +++ b/net/9p/mod.c
90496 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90497 void v9fs_register_trans(struct p9_trans_module *m)
90498 {
90499 spin_lock(&v9fs_trans_lock);
90500 - list_add_tail(&m->list, &v9fs_trans_list);
90501 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90502 spin_unlock(&v9fs_trans_lock);
90503 }
90504 EXPORT_SYMBOL(v9fs_register_trans);
90505 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90506 void v9fs_unregister_trans(struct p9_trans_module *m)
90507 {
90508 spin_lock(&v9fs_trans_lock);
90509 - list_del_init(&m->list);
90510 + pax_list_del_init((struct list_head *)&m->list);
90511 spin_unlock(&v9fs_trans_lock);
90512 }
90513 EXPORT_SYMBOL(v9fs_unregister_trans);
90514 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90515 index 3ffda1b..fceac96 100644
90516 --- a/net/9p/trans_fd.c
90517 +++ b/net/9p/trans_fd.c
90518 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90519 oldfs = get_fs();
90520 set_fs(get_ds());
90521 /* The cast to a user pointer is valid due to the set_fs() */
90522 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90523 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90524 set_fs(oldfs);
90525
90526 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90527 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90528 index 876fbe8..8bbea9f 100644
90529 --- a/net/atm/atm_misc.c
90530 +++ b/net/atm/atm_misc.c
90531 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90532 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90533 return 1;
90534 atm_return(vcc, truesize);
90535 - atomic_inc(&vcc->stats->rx_drop);
90536 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90537 return 0;
90538 }
90539 EXPORT_SYMBOL(atm_charge);
90540 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90541 }
90542 }
90543 atm_return(vcc, guess);
90544 - atomic_inc(&vcc->stats->rx_drop);
90545 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90546 return NULL;
90547 }
90548 EXPORT_SYMBOL(atm_alloc_charge);
90549 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90550
90551 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90552 {
90553 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90554 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90555 __SONET_ITEMS
90556 #undef __HANDLE_ITEM
90557 }
90558 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90559
90560 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90561 {
90562 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90563 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90564 __SONET_ITEMS
90565 #undef __HANDLE_ITEM
90566 }
90567 diff --git a/net/atm/lec.h b/net/atm/lec.h
90568 index 4149db1..f2ab682 100644
90569 --- a/net/atm/lec.h
90570 +++ b/net/atm/lec.h
90571 @@ -48,7 +48,7 @@ struct lane2_ops {
90572 const u8 *tlvs, u32 sizeoftlvs);
90573 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90574 const u8 *tlvs, u32 sizeoftlvs);
90575 -};
90576 +} __no_const;
90577
90578 /*
90579 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90580 diff --git a/net/atm/proc.c b/net/atm/proc.c
90581 index bbb6461..cf04016 100644
90582 --- a/net/atm/proc.c
90583 +++ b/net/atm/proc.c
90584 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90585 const struct k_atm_aal_stats *stats)
90586 {
90587 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90588 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90589 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90590 - atomic_read(&stats->rx_drop));
90591 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90592 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90593 + atomic_read_unchecked(&stats->rx_drop));
90594 }
90595
90596 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90597 diff --git a/net/atm/resources.c b/net/atm/resources.c
90598 index 0447d5d..3cf4728 100644
90599 --- a/net/atm/resources.c
90600 +++ b/net/atm/resources.c
90601 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90602 static void copy_aal_stats(struct k_atm_aal_stats *from,
90603 struct atm_aal_stats *to)
90604 {
90605 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90606 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90607 __AAL_STAT_ITEMS
90608 #undef __HANDLE_ITEM
90609 }
90610 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90611 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90612 struct atm_aal_stats *to)
90613 {
90614 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90615 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90616 __AAL_STAT_ITEMS
90617 #undef __HANDLE_ITEM
90618 }
90619 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90620 index 919a5ce..cc6b444 100644
90621 --- a/net/ax25/sysctl_net_ax25.c
90622 +++ b/net/ax25/sysctl_net_ax25.c
90623 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90624 {
90625 char path[sizeof("net/ax25/") + IFNAMSIZ];
90626 int k;
90627 - struct ctl_table *table;
90628 + ctl_table_no_const *table;
90629
90630 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90631 if (!table)
90632 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90633 index 62da527..aa27535 100644
90634 --- a/net/batman-adv/bat_iv_ogm.c
90635 +++ b/net/batman-adv/bat_iv_ogm.c
90636 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90637
90638 /* randomize initial seqno to avoid collision */
90639 get_random_bytes(&random_seqno, sizeof(random_seqno));
90640 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90641 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90642
90643 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90644 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
90645 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
90646 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
90647
90648 /* change sequence number to network order */
90649 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
90650 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
90651 batadv_ogm_packet->seqno = htonl(seqno);
90652 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
90653 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
90654
90655 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
90656 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
90657 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
90658 return;
90659
90660 /* could be changed by schedule_own_packet() */
90661 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
90662 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
90663
90664 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
90665 has_directlink_flag = 1;
90666 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
90667 index c478e6b..469fd2f 100644
90668 --- a/net/batman-adv/hard-interface.c
90669 +++ b/net/batman-adv/hard-interface.c
90670 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
90671 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
90672 dev_add_pack(&hard_iface->batman_adv_ptype);
90673
90674 - atomic_set(&hard_iface->frag_seqno, 1);
90675 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
90676 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
90677 hard_iface->net_dev->name);
90678
90679 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
90680 index 33b6144..3212ac5 100644
90681 --- a/net/batman-adv/soft-interface.c
90682 +++ b/net/batman-adv/soft-interface.c
90683 @@ -261,7 +261,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
90684 primary_if->net_dev->dev_addr, ETH_ALEN);
90685
90686 /* set broadcast sequence number */
90687 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
90688 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
90689 bcast_packet->seqno = htonl(seqno);
90690
90691 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
90692 @@ -481,7 +481,7 @@ static int batadv_softif_init_late(struct net_device *dev)
90693 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
90694
90695 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
90696 - atomic_set(&bat_priv->bcast_seqno, 1);
90697 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
90698 atomic_set(&bat_priv->tt.vn, 0);
90699 atomic_set(&bat_priv->tt.local_changes, 0);
90700 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
90701 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
90702 index b2c94e1..3d47e07 100644
90703 --- a/net/batman-adv/types.h
90704 +++ b/net/batman-adv/types.h
90705 @@ -51,7 +51,7 @@
90706 struct batadv_hard_iface_bat_iv {
90707 unsigned char *ogm_buff;
90708 int ogm_buff_len;
90709 - atomic_t ogm_seqno;
90710 + atomic_unchecked_t ogm_seqno;
90711 };
90712
90713 /**
90714 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
90715 int16_t if_num;
90716 char if_status;
90717 struct net_device *net_dev;
90718 - atomic_t frag_seqno;
90719 + atomic_unchecked_t frag_seqno;
90720 uint8_t num_bcasts;
90721 struct kobject *hardif_obj;
90722 atomic_t refcount;
90723 @@ -560,7 +560,7 @@ struct batadv_priv {
90724 #ifdef CONFIG_BATMAN_ADV_DEBUG
90725 atomic_t log_level;
90726 #endif
90727 - atomic_t bcast_seqno;
90728 + atomic_unchecked_t bcast_seqno;
90729 atomic_t bcast_queue_left;
90730 atomic_t batman_queue_left;
90731 char num_ifaces;
90732 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
90733 index 857e1b8..5ad07b2 100644
90734 --- a/net/batman-adv/unicast.c
90735 +++ b/net/batman-adv/unicast.c
90736 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
90737 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
90738 frag2->flags = large_tail;
90739
90740 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
90741 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
90742 frag1->seqno = htons(seqno - 1);
90743 frag2->seqno = htons(seqno);
90744
90745 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
90746 index 9bd7d95..6c4884f 100644
90747 --- a/net/bluetooth/hci_sock.c
90748 +++ b/net/bluetooth/hci_sock.c
90749 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
90750 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
90751 }
90752
90753 - len = min_t(unsigned int, len, sizeof(uf));
90754 + len = min((size_t)len, sizeof(uf));
90755 if (copy_from_user(&uf, optval, len)) {
90756 err = -EFAULT;
90757 break;
90758 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
90759 index 8c3499b..2661c6a 100644
90760 --- a/net/bluetooth/l2cap_core.c
90761 +++ b/net/bluetooth/l2cap_core.c
90762 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
90763 break;
90764
90765 case L2CAP_CONF_RFC:
90766 - if (olen == sizeof(rfc))
90767 - memcpy(&rfc, (void *)val, olen);
90768 + if (olen != sizeof(rfc))
90769 + break;
90770 +
90771 + memcpy(&rfc, (void *)val, olen);
90772
90773 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
90774 rfc.mode != chan->mode)
90775 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
90776 index 0098af8..fb5a31f 100644
90777 --- a/net/bluetooth/l2cap_sock.c
90778 +++ b/net/bluetooth/l2cap_sock.c
90779 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
90780 struct sock *sk = sock->sk;
90781 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
90782 struct l2cap_options opts;
90783 - int len, err = 0;
90784 + int err = 0;
90785 + size_t len = optlen;
90786 u32 opt;
90787
90788 BT_DBG("sk %p", sk);
90789 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
90790 opts.max_tx = chan->max_tx;
90791 opts.txwin_size = chan->tx_win;
90792
90793 - len = min_t(unsigned int, sizeof(opts), optlen);
90794 + len = min(sizeof(opts), len);
90795 if (copy_from_user((char *) &opts, optval, len)) {
90796 err = -EFAULT;
90797 break;
90798 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90799 struct bt_security sec;
90800 struct bt_power pwr;
90801 struct l2cap_conn *conn;
90802 - int len, err = 0;
90803 + int err = 0;
90804 + size_t len = optlen;
90805 u32 opt;
90806
90807 BT_DBG("sk %p", sk);
90808 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90809
90810 sec.level = BT_SECURITY_LOW;
90811
90812 - len = min_t(unsigned int, sizeof(sec), optlen);
90813 + len = min(sizeof(sec), len);
90814 if (copy_from_user((char *) &sec, optval, len)) {
90815 err = -EFAULT;
90816 break;
90817 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90818
90819 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
90820
90821 - len = min_t(unsigned int, sizeof(pwr), optlen);
90822 + len = min(sizeof(pwr), len);
90823 if (copy_from_user((char *) &pwr, optval, len)) {
90824 err = -EFAULT;
90825 break;
90826 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
90827 index 30b3721..c1bd0a0 100644
90828 --- a/net/bluetooth/rfcomm/sock.c
90829 +++ b/net/bluetooth/rfcomm/sock.c
90830 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
90831 struct sock *sk = sock->sk;
90832 struct bt_security sec;
90833 int err = 0;
90834 - size_t len;
90835 + size_t len = optlen;
90836 u32 opt;
90837
90838 BT_DBG("sk %p", sk);
90839 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
90840
90841 sec.level = BT_SECURITY_LOW;
90842
90843 - len = min_t(unsigned int, sizeof(sec), optlen);
90844 + len = min(sizeof(sec), len);
90845 if (copy_from_user((char *) &sec, optval, len)) {
90846 err = -EFAULT;
90847 break;
90848 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
90849 index b6e44ad..5b0d514 100644
90850 --- a/net/bluetooth/rfcomm/tty.c
90851 +++ b/net/bluetooth/rfcomm/tty.c
90852 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
90853 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
90854
90855 spin_lock_irqsave(&dev->port.lock, flags);
90856 - if (dev->port.count > 0) {
90857 + if (atomic_read(&dev->port.count) > 0) {
90858 spin_unlock_irqrestore(&dev->port.lock, flags);
90859 return;
90860 }
90861 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
90862 return -ENODEV;
90863
90864 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
90865 - dev->channel, dev->port.count);
90866 + dev->channel, atomic_read(&dev->port.count));
90867
90868 spin_lock_irqsave(&dev->port.lock, flags);
90869 - if (++dev->port.count > 1) {
90870 + if (atomic_inc_return(&dev->port.count) > 1) {
90871 spin_unlock_irqrestore(&dev->port.lock, flags);
90872 return 0;
90873 }
90874 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
90875 return;
90876
90877 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
90878 - dev->port.count);
90879 + atomic_read(&dev->port.count));
90880
90881 spin_lock_irqsave(&dev->port.lock, flags);
90882 - if (!--dev->port.count) {
90883 + if (!atomic_dec_return(&dev->port.count)) {
90884 spin_unlock_irqrestore(&dev->port.lock, flags);
90885 if (dev->tty_dev->parent)
90886 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
90887 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
90888 index 5180938..7c470c3 100644
90889 --- a/net/bridge/netfilter/ebt_ulog.c
90890 +++ b/net/bridge/netfilter/ebt_ulog.c
90891 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
90892 ub->qlen++;
90893
90894 pm = nlmsg_data(nlh);
90895 + memset(pm, 0, sizeof(*pm));
90896
90897 /* Fill in the ulog data */
90898 pm->version = EBT_ULOG_VERSION;
90899 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
90900 pm->hook = hooknr;
90901 if (uloginfo->prefix != NULL)
90902 strcpy(pm->prefix, uloginfo->prefix);
90903 - else
90904 - *(pm->prefix) = '\0';
90905
90906 if (in) {
90907 strcpy(pm->physindev, in->name);
90908 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
90909 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
90910 else
90911 strcpy(pm->indev, in->name);
90912 - } else
90913 - pm->indev[0] = pm->physindev[0] = '\0';
90914 + }
90915
90916 if (out) {
90917 /* If out exists, then out is a bridge port */
90918 strcpy(pm->physoutdev, out->name);
90919 /* rcu_read_lock()ed by nf_hook_slow */
90920 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
90921 - } else
90922 - pm->outdev[0] = pm->physoutdev[0] = '\0';
90923 + }
90924
90925 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
90926 BUG();
90927 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
90928 index ac78024..161a80c 100644
90929 --- a/net/bridge/netfilter/ebtables.c
90930 +++ b/net/bridge/netfilter/ebtables.c
90931 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
90932 tmp.valid_hooks = t->table->valid_hooks;
90933 }
90934 mutex_unlock(&ebt_mutex);
90935 - if (copy_to_user(user, &tmp, *len) != 0){
90936 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
90937 BUGPRINT("c2u Didn't work\n");
90938 ret = -EFAULT;
90939 break;
90940 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
90941 goto out;
90942 tmp.valid_hooks = t->valid_hooks;
90943
90944 - if (copy_to_user(user, &tmp, *len) != 0) {
90945 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
90946 ret = -EFAULT;
90947 break;
90948 }
90949 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
90950 tmp.entries_size = t->table->entries_size;
90951 tmp.valid_hooks = t->table->valid_hooks;
90952
90953 - if (copy_to_user(user, &tmp, *len) != 0) {
90954 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
90955 ret = -EFAULT;
90956 break;
90957 }
90958 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
90959 index 0f45522..dab651f 100644
90960 --- a/net/caif/cfctrl.c
90961 +++ b/net/caif/cfctrl.c
90962 @@ -10,6 +10,7 @@
90963 #include <linux/spinlock.h>
90964 #include <linux/slab.h>
90965 #include <linux/pkt_sched.h>
90966 +#include <linux/sched.h>
90967 #include <net/caif/caif_layer.h>
90968 #include <net/caif/cfpkt.h>
90969 #include <net/caif/cfctrl.h>
90970 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
90971 memset(&dev_info, 0, sizeof(dev_info));
90972 dev_info.id = 0xff;
90973 cfsrvl_init(&this->serv, 0, &dev_info, false);
90974 - atomic_set(&this->req_seq_no, 1);
90975 - atomic_set(&this->rsp_seq_no, 1);
90976 + atomic_set_unchecked(&this->req_seq_no, 1);
90977 + atomic_set_unchecked(&this->rsp_seq_no, 1);
90978 this->serv.layer.receive = cfctrl_recv;
90979 sprintf(this->serv.layer.name, "ctrl");
90980 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
90981 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
90982 struct cfctrl_request_info *req)
90983 {
90984 spin_lock_bh(&ctrl->info_list_lock);
90985 - atomic_inc(&ctrl->req_seq_no);
90986 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
90987 + atomic_inc_unchecked(&ctrl->req_seq_no);
90988 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
90989 list_add_tail(&req->list, &ctrl->list);
90990 spin_unlock_bh(&ctrl->info_list_lock);
90991 }
90992 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
90993 if (p != first)
90994 pr_warn("Requests are not received in order\n");
90995
90996 - atomic_set(&ctrl->rsp_seq_no,
90997 + atomic_set_unchecked(&ctrl->rsp_seq_no,
90998 p->sequence_no);
90999 list_del(&p->list);
91000 goto out;
91001 diff --git a/net/can/af_can.c b/net/can/af_can.c
91002 index 3ab8dd2..b9aef13 100644
91003 --- a/net/can/af_can.c
91004 +++ b/net/can/af_can.c
91005 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91006 };
91007
91008 /* notifier block for netdevice event */
91009 -static struct notifier_block can_netdev_notifier __read_mostly = {
91010 +static struct notifier_block can_netdev_notifier = {
91011 .notifier_call = can_notifier,
91012 };
91013
91014 diff --git a/net/can/gw.c b/net/can/gw.c
91015 index 2f291f9..98c986a 100644
91016 --- a/net/can/gw.c
91017 +++ b/net/can/gw.c
91018 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91019 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91020
91021 static HLIST_HEAD(cgw_list);
91022 -static struct notifier_block notifier;
91023
91024 static struct kmem_cache *cgw_cache __read_mostly;
91025
91026 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91027 return err;
91028 }
91029
91030 +static struct notifier_block notifier = {
91031 + .notifier_call = cgw_notifier
91032 +};
91033 +
91034 static __init int cgw_module_init(void)
91035 {
91036 /* sanitize given module parameter */
91037 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91038 return -ENOMEM;
91039
91040 /* set notifier */
91041 - notifier.notifier_call = cgw_notifier;
91042 register_netdevice_notifier(&notifier);
91043
91044 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91045 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91046 index eb0a46a..5f3bae8 100644
91047 --- a/net/ceph/messenger.c
91048 +++ b/net/ceph/messenger.c
91049 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91050 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91051
91052 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91053 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91054 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91055
91056 static struct page *zero_page; /* used in certain error cases */
91057
91058 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91059 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91060 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91061
91062 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91063 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91064 s = addr_str[i];
91065
91066 switch (ss->ss_family) {
91067 diff --git a/net/compat.c b/net/compat.c
91068 index f0a1ba6..0541331 100644
91069 --- a/net/compat.c
91070 +++ b/net/compat.c
91071 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91072 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
91073 __get_user(kmsg->msg_flags, &umsg->msg_flags))
91074 return -EFAULT;
91075 - kmsg->msg_name = compat_ptr(tmp1);
91076 - kmsg->msg_iov = compat_ptr(tmp2);
91077 - kmsg->msg_control = compat_ptr(tmp3);
91078 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91079 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91080 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91081 return 0;
91082 }
91083
91084 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91085
91086 if (kern_msg->msg_namelen) {
91087 if (mode == VERIFY_READ) {
91088 - int err = move_addr_to_kernel(kern_msg->msg_name,
91089 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91090 kern_msg->msg_namelen,
91091 kern_address);
91092 if (err < 0)
91093 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91094 kern_msg->msg_name = NULL;
91095
91096 tot_len = iov_from_user_compat_to_kern(kern_iov,
91097 - (struct compat_iovec __user *)kern_msg->msg_iov,
91098 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91099 kern_msg->msg_iovlen);
91100 if (tot_len >= 0)
91101 kern_msg->msg_iov = kern_iov;
91102 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91103
91104 #define CMSG_COMPAT_FIRSTHDR(msg) \
91105 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91106 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91107 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91108 (struct compat_cmsghdr __user *)NULL)
91109
91110 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91111 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91112 (ucmlen) <= (unsigned long) \
91113 ((mhdr)->msg_controllen - \
91114 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91115 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91116
91117 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91118 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91119 {
91120 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91121 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91122 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91123 msg->msg_controllen)
91124 return NULL;
91125 return (struct compat_cmsghdr __user *)ptr;
91126 @@ -219,7 +219,7 @@ Efault:
91127
91128 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91129 {
91130 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91131 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91132 struct compat_cmsghdr cmhdr;
91133 struct compat_timeval ctv;
91134 struct compat_timespec cts[3];
91135 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91136
91137 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91138 {
91139 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91140 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91141 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91142 int fdnum = scm->fp->count;
91143 struct file **fp = scm->fp->fp;
91144 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91145 return -EFAULT;
91146 old_fs = get_fs();
91147 set_fs(KERNEL_DS);
91148 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91149 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91150 set_fs(old_fs);
91151
91152 return err;
91153 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91154 len = sizeof(ktime);
91155 old_fs = get_fs();
91156 set_fs(KERNEL_DS);
91157 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91158 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91159 set_fs(old_fs);
91160
91161 if (!err) {
91162 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91163 case MCAST_JOIN_GROUP:
91164 case MCAST_LEAVE_GROUP:
91165 {
91166 - struct compat_group_req __user *gr32 = (void *)optval;
91167 + struct compat_group_req __user *gr32 = (void __user *)optval;
91168 struct group_req __user *kgr =
91169 compat_alloc_user_space(sizeof(struct group_req));
91170 u32 interface;
91171 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91172 case MCAST_BLOCK_SOURCE:
91173 case MCAST_UNBLOCK_SOURCE:
91174 {
91175 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91176 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91177 struct group_source_req __user *kgsr = compat_alloc_user_space(
91178 sizeof(struct group_source_req));
91179 u32 interface;
91180 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91181 }
91182 case MCAST_MSFILTER:
91183 {
91184 - struct compat_group_filter __user *gf32 = (void *)optval;
91185 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91186 struct group_filter __user *kgf;
91187 u32 interface, fmode, numsrc;
91188
91189 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91190 char __user *optval, int __user *optlen,
91191 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91192 {
91193 - struct compat_group_filter __user *gf32 = (void *)optval;
91194 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91195 struct group_filter __user *kgf;
91196 int __user *koptlen;
91197 u32 interface, fmode, numsrc;
91198 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91199
91200 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91201 return -EINVAL;
91202 - if (copy_from_user(a, args, nas[call]))
91203 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91204 return -EFAULT;
91205 a0 = a[0];
91206 a1 = a[1];
91207 diff --git a/net/core/datagram.c b/net/core/datagram.c
91208 index 8ab48cd..57b1a80 100644
91209 --- a/net/core/datagram.c
91210 +++ b/net/core/datagram.c
91211 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91212 }
91213
91214 kfree_skb(skb);
91215 - atomic_inc(&sk->sk_drops);
91216 + atomic_inc_unchecked(&sk->sk_drops);
91217 sk_mem_reclaim_partial(sk);
91218
91219 return err;
91220 diff --git a/net/core/dev.c b/net/core/dev.c
91221 index 26755dd..2a232de 100644
91222 --- a/net/core/dev.c
91223 +++ b/net/core/dev.c
91224 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91225 {
91226 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91227 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91228 - atomic_long_inc(&dev->rx_dropped);
91229 + atomic_long_inc_unchecked(&dev->rx_dropped);
91230 kfree_skb(skb);
91231 return NET_RX_DROP;
91232 }
91233 }
91234
91235 if (unlikely(!is_skb_forwardable(dev, skb))) {
91236 - atomic_long_inc(&dev->rx_dropped);
91237 + atomic_long_inc_unchecked(&dev->rx_dropped);
91238 kfree_skb(skb);
91239 return NET_RX_DROP;
91240 }
91241 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91242
91243 struct dev_gso_cb {
91244 void (*destructor)(struct sk_buff *skb);
91245 -};
91246 +} __no_const;
91247
91248 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91249
91250 @@ -3206,7 +3206,7 @@ enqueue:
91251
91252 local_irq_restore(flags);
91253
91254 - atomic_long_inc(&skb->dev->rx_dropped);
91255 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91256 kfree_skb(skb);
91257 return NET_RX_DROP;
91258 }
91259 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91260 }
91261 EXPORT_SYMBOL(netif_rx_ni);
91262
91263 -static void net_tx_action(struct softirq_action *h)
91264 +static __latent_entropy void net_tx_action(void)
91265 {
91266 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91267
91268 @@ -3612,7 +3612,7 @@ ncls:
91269 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91270 } else {
91271 drop:
91272 - atomic_long_inc(&skb->dev->rx_dropped);
91273 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91274 kfree_skb(skb);
91275 /* Jamal, now you will not able to escape explaining
91276 * me how you were going to use this. :-)
91277 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91278 }
91279 EXPORT_SYMBOL(netif_napi_del);
91280
91281 -static void net_rx_action(struct softirq_action *h)
91282 +static __latent_entropy void net_rx_action(void)
91283 {
91284 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91285 unsigned long time_limit = jiffies + 2;
91286 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91287 } else {
91288 netdev_stats_to_stats64(storage, &dev->stats);
91289 }
91290 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91291 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91292 return storage;
91293 }
91294 EXPORT_SYMBOL(dev_get_stats);
91295 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91296 index 5b7d0e1..cb960fc 100644
91297 --- a/net/core/dev_ioctl.c
91298 +++ b/net/core/dev_ioctl.c
91299 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91300 if (no_module && capable(CAP_NET_ADMIN))
91301 no_module = request_module("netdev-%s", name);
91302 if (no_module && capable(CAP_SYS_MODULE)) {
91303 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91304 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91305 +#else
91306 if (!request_module("%s", name))
91307 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91308 name);
91309 +#endif
91310 }
91311 }
91312 EXPORT_SYMBOL(dev_load);
91313 diff --git a/net/core/flow.c b/net/core/flow.c
91314 index dfa602c..3103d88 100644
91315 --- a/net/core/flow.c
91316 +++ b/net/core/flow.c
91317 @@ -61,7 +61,7 @@ struct flow_cache {
91318 struct timer_list rnd_timer;
91319 };
91320
91321 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91322 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91323 EXPORT_SYMBOL(flow_cache_genid);
91324 static struct flow_cache flow_cache_global;
91325 static struct kmem_cache *flow_cachep __read_mostly;
91326 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91327
91328 static int flow_entry_valid(struct flow_cache_entry *fle)
91329 {
91330 - if (atomic_read(&flow_cache_genid) != fle->genid)
91331 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91332 return 0;
91333 if (fle->object && !fle->object->ops->check(fle->object))
91334 return 0;
91335 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91336 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91337 fcp->hash_count++;
91338 }
91339 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91340 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91341 flo = fle->object;
91342 if (!flo)
91343 goto ret_object;
91344 @@ -279,7 +279,7 @@ nocache:
91345 }
91346 flo = resolver(net, key, family, dir, flo, ctx);
91347 if (fle) {
91348 - fle->genid = atomic_read(&flow_cache_genid);
91349 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91350 if (!IS_ERR(flo))
91351 fle->object = flo;
91352 else
91353 diff --git a/net/core/iovec.c b/net/core/iovec.c
91354 index de178e4..1dabd8b 100644
91355 --- a/net/core/iovec.c
91356 +++ b/net/core/iovec.c
91357 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91358 if (m->msg_namelen) {
91359 if (mode == VERIFY_READ) {
91360 void __user *namep;
91361 - namep = (void __user __force *) m->msg_name;
91362 + namep = (void __force_user *) m->msg_name;
91363 err = move_addr_to_kernel(namep, m->msg_namelen,
91364 address);
91365 if (err < 0)
91366 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91367 }
91368
91369 size = m->msg_iovlen * sizeof(struct iovec);
91370 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91371 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91372 return -EFAULT;
91373
91374 m->msg_iov = iov;
91375 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91376 index 60533db..14842cc 100644
91377 --- a/net/core/neighbour.c
91378 +++ b/net/core/neighbour.c
91379 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91380 void __user *buffer, size_t *lenp, loff_t *ppos)
91381 {
91382 int size, ret;
91383 - struct ctl_table tmp = *ctl;
91384 + ctl_table_no_const tmp = *ctl;
91385
91386 tmp.extra1 = &zero;
91387 tmp.extra2 = &unres_qlen_max;
91388 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91389 index 2bf8329..7960607 100644
91390 --- a/net/core/net-procfs.c
91391 +++ b/net/core/net-procfs.c
91392 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91393 else
91394 seq_printf(seq, "%04x", ntohs(pt->type));
91395
91396 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91397 + seq_printf(seq, " %-8s %pf\n",
91398 + pt->dev ? pt->dev->name : "", NULL);
91399 +#else
91400 seq_printf(seq, " %-8s %pf\n",
91401 pt->dev ? pt->dev->name : "", pt->func);
91402 +#endif
91403 }
91404
91405 return 0;
91406 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91407 index 981fed3..536af34 100644
91408 --- a/net/core/net-sysfs.c
91409 +++ b/net/core/net-sysfs.c
91410 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91411 }
91412 EXPORT_SYMBOL(netdev_class_remove_file);
91413
91414 -int netdev_kobject_init(void)
91415 +int __init netdev_kobject_init(void)
91416 {
91417 kobj_ns_type_register(&net_ns_type_operations);
91418 return class_register(&net_class);
91419 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91420 index f9765203..9feaef8 100644
91421 --- a/net/core/net_namespace.c
91422 +++ b/net/core/net_namespace.c
91423 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91424 int error;
91425 LIST_HEAD(net_exit_list);
91426
91427 - list_add_tail(&ops->list, list);
91428 + pax_list_add_tail((struct list_head *)&ops->list, list);
91429 if (ops->init || (ops->id && ops->size)) {
91430 for_each_net(net) {
91431 error = ops_init(ops, net);
91432 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91433
91434 out_undo:
91435 /* If I have an error cleanup all namespaces I initialized */
91436 - list_del(&ops->list);
91437 + pax_list_del((struct list_head *)&ops->list);
91438 ops_exit_list(ops, &net_exit_list);
91439 ops_free_list(ops, &net_exit_list);
91440 return error;
91441 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91442 struct net *net;
91443 LIST_HEAD(net_exit_list);
91444
91445 - list_del(&ops->list);
91446 + pax_list_del((struct list_head *)&ops->list);
91447 for_each_net(net)
91448 list_add_tail(&net->exit_list, &net_exit_list);
91449 ops_exit_list(ops, &net_exit_list);
91450 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91451 mutex_lock(&net_mutex);
91452 error = register_pernet_operations(&pernet_list, ops);
91453 if (!error && (first_device == &pernet_list))
91454 - first_device = &ops->list;
91455 + first_device = (struct list_head *)&ops->list;
91456 mutex_unlock(&net_mutex);
91457 return error;
91458 }
91459 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91460 index fc75c9e..8c8e9be 100644
91461 --- a/net/core/netpoll.c
91462 +++ b/net/core/netpoll.c
91463 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91464 struct udphdr *udph;
91465 struct iphdr *iph;
91466 struct ethhdr *eth;
91467 - static atomic_t ip_ident;
91468 + static atomic_unchecked_t ip_ident;
91469 struct ipv6hdr *ip6h;
91470
91471 udp_len = len + sizeof(*udph);
91472 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91473 put_unaligned(0x45, (unsigned char *)iph);
91474 iph->tos = 0;
91475 put_unaligned(htons(ip_len), &(iph->tot_len));
91476 - iph->id = htons(atomic_inc_return(&ip_ident));
91477 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91478 iph->frag_off = 0;
91479 iph->ttl = 64;
91480 iph->protocol = IPPROTO_UDP;
91481 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91482 index ca198c1d1..125372f 100644
91483 --- a/net/core/rtnetlink.c
91484 +++ b/net/core/rtnetlink.c
91485 @@ -58,7 +58,7 @@ struct rtnl_link {
91486 rtnl_doit_func doit;
91487 rtnl_dumpit_func dumpit;
91488 rtnl_calcit_func calcit;
91489 -};
91490 +} __no_const;
91491
91492 static DEFINE_MUTEX(rtnl_mutex);
91493
91494 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91495 if (rtnl_link_ops_get(ops->kind))
91496 return -EEXIST;
91497
91498 - if (!ops->dellink)
91499 - ops->dellink = unregister_netdevice_queue;
91500 + if (!ops->dellink) {
91501 + pax_open_kernel();
91502 + *(void **)&ops->dellink = unregister_netdevice_queue;
91503 + pax_close_kernel();
91504 + }
91505
91506 - list_add_tail(&ops->list, &link_ops);
91507 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91508 return 0;
91509 }
91510 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91511 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91512 for_each_net(net) {
91513 __rtnl_kill_links(net, ops);
91514 }
91515 - list_del(&ops->list);
91516 + pax_list_del((struct list_head *)&ops->list);
91517 }
91518 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91519
91520 diff --git a/net/core/scm.c b/net/core/scm.c
91521 index b4da80b..98d6bdb 100644
91522 --- a/net/core/scm.c
91523 +++ b/net/core/scm.c
91524 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91525 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91526 {
91527 struct cmsghdr __user *cm
91528 - = (__force struct cmsghdr __user *)msg->msg_control;
91529 + = (struct cmsghdr __force_user *)msg->msg_control;
91530 struct cmsghdr cmhdr;
91531 int cmlen = CMSG_LEN(len);
91532 int err;
91533 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91534 err = -EFAULT;
91535 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91536 goto out;
91537 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91538 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91539 goto out;
91540 cmlen = CMSG_SPACE(len);
91541 if (msg->msg_controllen < cmlen)
91542 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91543 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91544 {
91545 struct cmsghdr __user *cm
91546 - = (__force struct cmsghdr __user*)msg->msg_control;
91547 + = (struct cmsghdr __force_user *)msg->msg_control;
91548
91549 int fdmax = 0;
91550 int fdnum = scm->fp->count;
91551 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91552 if (fdnum < fdmax)
91553 fdmax = fdnum;
91554
91555 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91556 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91557 i++, cmfptr++)
91558 {
91559 struct socket *sock;
91560 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91561 index 2c3d0f5..f5a326f 100644
91562 --- a/net/core/skbuff.c
91563 +++ b/net/core/skbuff.c
91564 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91565 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91566 sizeof(struct sk_buff),
91567 0,
91568 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91569 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91570 + SLAB_NO_SANITIZE,
91571 NULL);
91572 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91573 (2*sizeof(struct sk_buff)) +
91574 sizeof(atomic_t),
91575 0,
91576 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91577 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91578 + SLAB_NO_SANITIZE,
91579 NULL);
91580 }
91581
91582 diff --git a/net/core/sock.c b/net/core/sock.c
91583 index 2c097c5..bf72858 100644
91584 --- a/net/core/sock.c
91585 +++ b/net/core/sock.c
91586 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91587 struct sk_buff_head *list = &sk->sk_receive_queue;
91588
91589 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91590 - atomic_inc(&sk->sk_drops);
91591 + atomic_inc_unchecked(&sk->sk_drops);
91592 trace_sock_rcvqueue_full(sk, skb);
91593 return -ENOMEM;
91594 }
91595 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91596 return err;
91597
91598 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91599 - atomic_inc(&sk->sk_drops);
91600 + atomic_inc_unchecked(&sk->sk_drops);
91601 return -ENOBUFS;
91602 }
91603
91604 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91605 skb_dst_force(skb);
91606
91607 spin_lock_irqsave(&list->lock, flags);
91608 - skb->dropcount = atomic_read(&sk->sk_drops);
91609 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91610 __skb_queue_tail(list, skb);
91611 spin_unlock_irqrestore(&list->lock, flags);
91612
91613 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91614 skb->dev = NULL;
91615
91616 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91617 - atomic_inc(&sk->sk_drops);
91618 + atomic_inc_unchecked(&sk->sk_drops);
91619 goto discard_and_relse;
91620 }
91621 if (nested)
91622 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91623 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91624 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91625 bh_unlock_sock(sk);
91626 - atomic_inc(&sk->sk_drops);
91627 + atomic_inc_unchecked(&sk->sk_drops);
91628 goto discard_and_relse;
91629 }
91630
91631 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91632 struct timeval tm;
91633 } v;
91634
91635 - int lv = sizeof(int);
91636 - int len;
91637 + unsigned int lv = sizeof(int);
91638 + unsigned int len;
91639
91640 if (get_user(len, optlen))
91641 return -EFAULT;
91642 - if (len < 0)
91643 + if (len > INT_MAX)
91644 return -EINVAL;
91645
91646 memset(&v, 0, sizeof(v));
91647 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91648
91649 case SO_PEERNAME:
91650 {
91651 - char address[128];
91652 + char address[_K_SS_MAXSIZE];
91653
91654 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
91655 return -ENOTCONN;
91656 - if (lv < len)
91657 + if (lv < len || sizeof address < len)
91658 return -EINVAL;
91659 if (copy_to_user(optval, address, len))
91660 return -EFAULT;
91661 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91662
91663 if (len > lv)
91664 len = lv;
91665 - if (copy_to_user(optval, &v, len))
91666 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
91667 return -EFAULT;
91668 lenout:
91669 if (put_user(len, optlen))
91670 @@ -2303,7 +2303,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
91671 */
91672 smp_wmb();
91673 atomic_set(&sk->sk_refcnt, 1);
91674 - atomic_set(&sk->sk_drops, 0);
91675 + atomic_set_unchecked(&sk->sk_drops, 0);
91676 }
91677 EXPORT_SYMBOL(sock_init_data);
91678
91679 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
91680 index a0e9cf6..ef7f9ed 100644
91681 --- a/net/core/sock_diag.c
91682 +++ b/net/core/sock_diag.c
91683 @@ -9,26 +9,33 @@
91684 #include <linux/inet_diag.h>
91685 #include <linux/sock_diag.h>
91686
91687 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
91688 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
91689 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
91690 static DEFINE_MUTEX(sock_diag_table_mutex);
91691
91692 int sock_diag_check_cookie(void *sk, __u32 *cookie)
91693 {
91694 +#ifndef CONFIG_GRKERNSEC_HIDESYM
91695 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
91696 cookie[1] != INET_DIAG_NOCOOKIE) &&
91697 ((u32)(unsigned long)sk != cookie[0] ||
91698 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
91699 return -ESTALE;
91700 else
91701 +#endif
91702 return 0;
91703 }
91704 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
91705
91706 void sock_diag_save_cookie(void *sk, __u32 *cookie)
91707 {
91708 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91709 + cookie[0] = 0;
91710 + cookie[1] = 0;
91711 +#else
91712 cookie[0] = (u32)(unsigned long)sk;
91713 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
91714 +#endif
91715 }
91716 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
91717
91718 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
91719 mutex_lock(&sock_diag_table_mutex);
91720 if (sock_diag_handlers[hndl->family])
91721 err = -EBUSY;
91722 - else
91723 + else {
91724 + pax_open_kernel();
91725 sock_diag_handlers[hndl->family] = hndl;
91726 + pax_close_kernel();
91727 + }
91728 mutex_unlock(&sock_diag_table_mutex);
91729
91730 return err;
91731 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
91732
91733 mutex_lock(&sock_diag_table_mutex);
91734 BUG_ON(sock_diag_handlers[family] != hnld);
91735 + pax_open_kernel();
91736 sock_diag_handlers[family] = NULL;
91737 + pax_close_kernel();
91738 mutex_unlock(&sock_diag_table_mutex);
91739 }
91740 EXPORT_SYMBOL_GPL(sock_diag_unregister);
91741 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
91742 index 31107ab..ae03d5a 100644
91743 --- a/net/core/sysctl_net_core.c
91744 +++ b/net/core/sysctl_net_core.c
91745 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
91746 {
91747 unsigned int orig_size, size;
91748 int ret, i;
91749 - struct ctl_table tmp = {
91750 + ctl_table_no_const tmp = {
91751 .data = &size,
91752 .maxlen = sizeof(size),
91753 .mode = table->mode
91754 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
91755
91756 static __net_init int sysctl_core_net_init(struct net *net)
91757 {
91758 - struct ctl_table *tbl;
91759 + ctl_table_no_const *tbl = NULL;
91760
91761 net->core.sysctl_somaxconn = SOMAXCONN;
91762
91763 - tbl = netns_core_table;
91764 if (!net_eq(net, &init_net)) {
91765 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
91766 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
91767 if (tbl == NULL)
91768 goto err_dup;
91769
91770 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
91771 if (net->user_ns != &init_user_ns) {
91772 tbl[0].procname = NULL;
91773 }
91774 - }
91775 -
91776 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
91777 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
91778 + } else
91779 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
91780 if (net->core.sysctl_hdr == NULL)
91781 goto err_reg;
91782
91783 return 0;
91784
91785 err_reg:
91786 - if (tbl != netns_core_table)
91787 - kfree(tbl);
91788 + kfree(tbl);
91789 err_dup:
91790 return -ENOMEM;
91791 }
91792 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
91793 kfree(tbl);
91794 }
91795
91796 -static __net_initdata struct pernet_operations sysctl_core_ops = {
91797 +static __net_initconst struct pernet_operations sysctl_core_ops = {
91798 .init = sysctl_core_net_init,
91799 .exit = sysctl_core_net_exit,
91800 };
91801 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
91802 index dd4d506..fb2fb87 100644
91803 --- a/net/decnet/af_decnet.c
91804 +++ b/net/decnet/af_decnet.c
91805 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
91806 .sysctl_rmem = sysctl_decnet_rmem,
91807 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
91808 .obj_size = sizeof(struct dn_sock),
91809 + .slab_flags = SLAB_USERCOPY,
91810 };
91811
91812 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
91813 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
91814 index 5325b54..a0d4d69 100644
91815 --- a/net/decnet/sysctl_net_decnet.c
91816 +++ b/net/decnet/sysctl_net_decnet.c
91817 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
91818
91819 if (len > *lenp) len = *lenp;
91820
91821 - if (copy_to_user(buffer, addr, len))
91822 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
91823 return -EFAULT;
91824
91825 *lenp = len;
91826 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
91827
91828 if (len > *lenp) len = *lenp;
91829
91830 - if (copy_to_user(buffer, devname, len))
91831 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
91832 return -EFAULT;
91833
91834 *lenp = len;
91835 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
91836 index 3b9d5f2..d7015c6 100644
91837 --- a/net/ieee802154/6lowpan.c
91838 +++ b/net/ieee802154/6lowpan.c
91839 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
91840 hc06_ptr += 3;
91841 } else {
91842 /* compress nothing */
91843 - memcpy(hc06_ptr, &hdr, 4);
91844 + memcpy(hc06_ptr, hdr, 4);
91845 /* replace the top byte with new ECN | DSCP format */
91846 *hc06_ptr = tmp;
91847 hc06_ptr += 4;
91848 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
91849 index dd6b523..dfe558f 100644
91850 --- a/net/ipv4/af_inet.c
91851 +++ b/net/ipv4/af_inet.c
91852 @@ -1687,13 +1687,9 @@ static int __init inet_init(void)
91853
91854 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
91855
91856 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
91857 - if (!sysctl_local_reserved_ports)
91858 - goto out;
91859 -
91860 rc = proto_register(&tcp_prot, 1);
91861 if (rc)
91862 - goto out_free_reserved_ports;
91863 + goto out;
91864
91865 rc = proto_register(&udp_prot, 1);
91866 if (rc)
91867 @@ -1802,8 +1798,6 @@ out_unregister_udp_proto:
91868 proto_unregister(&udp_prot);
91869 out_unregister_tcp_proto:
91870 proto_unregister(&tcp_prot);
91871 -out_free_reserved_ports:
91872 - kfree(sysctl_local_reserved_ports);
91873 goto out;
91874 }
91875
91876 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
91877 index 34ca6d5..b6421e8 100644
91878 --- a/net/ipv4/devinet.c
91879 +++ b/net/ipv4/devinet.c
91880 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
91881 idx = 0;
91882 head = &net->dev_index_head[h];
91883 rcu_read_lock();
91884 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
91885 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
91886 net->dev_base_seq;
91887 hlist_for_each_entry_rcu(dev, head, index_hlist) {
91888 if (idx < s_idx)
91889 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
91890 idx = 0;
91891 head = &net->dev_index_head[h];
91892 rcu_read_lock();
91893 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
91894 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
91895 net->dev_base_seq;
91896 hlist_for_each_entry_rcu(dev, head, index_hlist) {
91897 if (idx < s_idx)
91898 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
91899 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
91900 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
91901
91902 -static struct devinet_sysctl_table {
91903 +static const struct devinet_sysctl_table {
91904 struct ctl_table_header *sysctl_header;
91905 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
91906 } devinet_sysctl = {
91907 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
91908 int err;
91909 struct ipv4_devconf *all, *dflt;
91910 #ifdef CONFIG_SYSCTL
91911 - struct ctl_table *tbl = ctl_forward_entry;
91912 + ctl_table_no_const *tbl = NULL;
91913 struct ctl_table_header *forw_hdr;
91914 #endif
91915
91916 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
91917 goto err_alloc_dflt;
91918
91919 #ifdef CONFIG_SYSCTL
91920 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
91921 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
91922 if (tbl == NULL)
91923 goto err_alloc_ctl;
91924
91925 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
91926 goto err_reg_dflt;
91927
91928 err = -ENOMEM;
91929 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
91930 + if (!net_eq(net, &init_net))
91931 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
91932 + else
91933 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
91934 if (forw_hdr == NULL)
91935 goto err_reg_ctl;
91936 net->ipv4.forw_hdr = forw_hdr;
91937 @@ -2240,8 +2243,7 @@ err_reg_ctl:
91938 err_reg_dflt:
91939 __devinet_sysctl_unregister(all);
91940 err_reg_all:
91941 - if (tbl != ctl_forward_entry)
91942 - kfree(tbl);
91943 + kfree(tbl);
91944 err_alloc_ctl:
91945 #endif
91946 if (dflt != &ipv4_devconf_dflt)
91947 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
91948 index b3f627a..b0f3e99 100644
91949 --- a/net/ipv4/fib_frontend.c
91950 +++ b/net/ipv4/fib_frontend.c
91951 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
91952 #ifdef CONFIG_IP_ROUTE_MULTIPATH
91953 fib_sync_up(dev);
91954 #endif
91955 - atomic_inc(&net->ipv4.dev_addr_genid);
91956 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
91957 rt_cache_flush(dev_net(dev));
91958 break;
91959 case NETDEV_DOWN:
91960 fib_del_ifaddr(ifa, NULL);
91961 - atomic_inc(&net->ipv4.dev_addr_genid);
91962 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
91963 if (ifa->ifa_dev->ifa_list == NULL) {
91964 /* Last address was deleted from this interface.
91965 * Disable IP.
91966 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
91967 #ifdef CONFIG_IP_ROUTE_MULTIPATH
91968 fib_sync_up(dev);
91969 #endif
91970 - atomic_inc(&net->ipv4.dev_addr_genid);
91971 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
91972 rt_cache_flush(net);
91973 break;
91974 case NETDEV_DOWN:
91975 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
91976 index d5dbca5..6251d5f 100644
91977 --- a/net/ipv4/fib_semantics.c
91978 +++ b/net/ipv4/fib_semantics.c
91979 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
91980 nh->nh_saddr = inet_select_addr(nh->nh_dev,
91981 nh->nh_gw,
91982 nh->nh_parent->fib_scope);
91983 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
91984 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
91985
91986 return nh->nh_saddr;
91987 }
91988 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
91989 index 6acb541..9ea617d 100644
91990 --- a/net/ipv4/inet_connection_sock.c
91991 +++ b/net/ipv4/inet_connection_sock.c
91992 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
91993 .range = { 32768, 61000 },
91994 };
91995
91996 -unsigned long *sysctl_local_reserved_ports;
91997 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
91998 EXPORT_SYMBOL(sysctl_local_reserved_ports);
91999
92000 void inet_get_local_port_range(int *low, int *high)
92001 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92002 index 7bd8983..3abdcf6 100644
92003 --- a/net/ipv4/inet_hashtables.c
92004 +++ b/net/ipv4/inet_hashtables.c
92005 @@ -18,12 +18,15 @@
92006 #include <linux/sched.h>
92007 #include <linux/slab.h>
92008 #include <linux/wait.h>
92009 +#include <linux/security.h>
92010
92011 #include <net/inet_connection_sock.h>
92012 #include <net/inet_hashtables.h>
92013 #include <net/secure_seq.h>
92014 #include <net/ip.h>
92015
92016 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92017 +
92018 /*
92019 * Allocate and initialize a new local port bind bucket.
92020 * The bindhash mutex for snum's hash chain must be held here.
92021 @@ -554,6 +557,8 @@ ok:
92022 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92023 spin_unlock(&head->lock);
92024
92025 + gr_update_task_in_ip_table(current, inet_sk(sk));
92026 +
92027 if (tw) {
92028 inet_twsk_deschedule(tw, death_row);
92029 while (twrefcnt) {
92030 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92031 index 33d5537..da337a4 100644
92032 --- a/net/ipv4/inetpeer.c
92033 +++ b/net/ipv4/inetpeer.c
92034 @@ -503,8 +503,8 @@ relookup:
92035 if (p) {
92036 p->daddr = *daddr;
92037 atomic_set(&p->refcnt, 1);
92038 - atomic_set(&p->rid, 0);
92039 - atomic_set(&p->ip_id_count,
92040 + atomic_set_unchecked(&p->rid, 0);
92041 + atomic_set_unchecked(&p->ip_id_count,
92042 (daddr->family == AF_INET) ?
92043 secure_ip_id(daddr->addr.a4) :
92044 secure_ipv6_id(daddr->addr.a6));
92045 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92046 index b66910a..cfe416e 100644
92047 --- a/net/ipv4/ip_fragment.c
92048 +++ b/net/ipv4/ip_fragment.c
92049 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92050 return 0;
92051
92052 start = qp->rid;
92053 - end = atomic_inc_return(&peer->rid);
92054 + end = atomic_inc_return_unchecked(&peer->rid);
92055 qp->rid = end;
92056
92057 rc = qp->q.fragments && (end - start) > max;
92058 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92059
92060 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92061 {
92062 - struct ctl_table *table;
92063 + ctl_table_no_const *table = NULL;
92064 struct ctl_table_header *hdr;
92065
92066 - table = ip4_frags_ns_ctl_table;
92067 if (!net_eq(net, &init_net)) {
92068 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92069 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92070 if (table == NULL)
92071 goto err_alloc;
92072
92073 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92074 /* Don't export sysctls to unprivileged users */
92075 if (net->user_ns != &init_user_ns)
92076 table[0].procname = NULL;
92077 - }
92078 + hdr = register_net_sysctl(net, "net/ipv4", table);
92079 + } else
92080 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92081
92082 - hdr = register_net_sysctl(net, "net/ipv4", table);
92083 if (hdr == NULL)
92084 goto err_reg;
92085
92086 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92087 return 0;
92088
92089 err_reg:
92090 - if (!net_eq(net, &init_net))
92091 - kfree(table);
92092 + kfree(table);
92093 err_alloc:
92094 return -ENOMEM;
92095 }
92096 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92097 index 8d6939e..19d0a95 100644
92098 --- a/net/ipv4/ip_gre.c
92099 +++ b/net/ipv4/ip_gre.c
92100 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92101 module_param(log_ecn_error, bool, 0644);
92102 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92103
92104 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92105 +static struct rtnl_link_ops ipgre_link_ops;
92106 static int ipgre_tunnel_init(struct net_device *dev);
92107
92108 static int ipgre_net_id __read_mostly;
92109 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92110 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92111 };
92112
92113 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92114 +static struct rtnl_link_ops ipgre_link_ops = {
92115 .kind = "gre",
92116 .maxtype = IFLA_GRE_MAX,
92117 .policy = ipgre_policy,
92118 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92119 .fill_info = ipgre_fill_info,
92120 };
92121
92122 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92123 +static struct rtnl_link_ops ipgre_tap_ops = {
92124 .kind = "gretap",
92125 .maxtype = IFLA_GRE_MAX,
92126 .policy = ipgre_policy,
92127 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92128 index d9c4f11..02b82dbc 100644
92129 --- a/net/ipv4/ip_sockglue.c
92130 +++ b/net/ipv4/ip_sockglue.c
92131 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92132 len = min_t(unsigned int, len, opt->optlen);
92133 if (put_user(len, optlen))
92134 return -EFAULT;
92135 - if (copy_to_user(optval, opt->__data, len))
92136 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92137 + copy_to_user(optval, opt->__data, len))
92138 return -EFAULT;
92139 return 0;
92140 }
92141 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92142 if (sk->sk_type != SOCK_STREAM)
92143 return -ENOPROTOOPT;
92144
92145 - msg.msg_control = optval;
92146 + msg.msg_control = (void __force_kernel *)optval;
92147 msg.msg_controllen = len;
92148 msg.msg_flags = flags;
92149
92150 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92151 index 17cc0ff..63856c4 100644
92152 --- a/net/ipv4/ip_vti.c
92153 +++ b/net/ipv4/ip_vti.c
92154 @@ -47,7 +47,7 @@
92155 #define HASH_SIZE 16
92156 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92157
92158 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92159 +static struct rtnl_link_ops vti_link_ops;
92160
92161 static int vti_net_id __read_mostly;
92162 struct vti_net {
92163 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92164 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92165 };
92166
92167 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92168 +static struct rtnl_link_ops vti_link_ops = {
92169 .kind = "vti",
92170 .maxtype = IFLA_VTI_MAX,
92171 .policy = vti_policy,
92172 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92173 index efa1138..20dbba0 100644
92174 --- a/net/ipv4/ipconfig.c
92175 +++ b/net/ipv4/ipconfig.c
92176 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92177
92178 mm_segment_t oldfs = get_fs();
92179 set_fs(get_ds());
92180 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92181 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92182 set_fs(oldfs);
92183 return res;
92184 }
92185 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92186
92187 mm_segment_t oldfs = get_fs();
92188 set_fs(get_ds());
92189 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92190 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92191 set_fs(oldfs);
92192 return res;
92193 }
92194 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92195
92196 mm_segment_t oldfs = get_fs();
92197 set_fs(get_ds());
92198 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92199 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92200 set_fs(oldfs);
92201 return res;
92202 }
92203 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92204 index b3ac3c3..ec6bd95 100644
92205 --- a/net/ipv4/ipip.c
92206 +++ b/net/ipv4/ipip.c
92207 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92208 static int ipip_net_id __read_mostly;
92209
92210 static int ipip_tunnel_init(struct net_device *dev);
92211 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92212 +static struct rtnl_link_ops ipip_link_ops;
92213
92214 static int ipip_err(struct sk_buff *skb, u32 info)
92215 {
92216 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92217 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92218 };
92219
92220 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92221 +static struct rtnl_link_ops ipip_link_ops = {
92222 .kind = "ipip",
92223 .maxtype = IFLA_IPTUN_MAX,
92224 .policy = ipip_policy,
92225 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92226 index 85a4f21..1beb1f5 100644
92227 --- a/net/ipv4/netfilter/arp_tables.c
92228 +++ b/net/ipv4/netfilter/arp_tables.c
92229 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92230 #endif
92231
92232 static int get_info(struct net *net, void __user *user,
92233 - const int *len, int compat)
92234 + int len, int compat)
92235 {
92236 char name[XT_TABLE_MAXNAMELEN];
92237 struct xt_table *t;
92238 int ret;
92239
92240 - if (*len != sizeof(struct arpt_getinfo)) {
92241 - duprintf("length %u != %Zu\n", *len,
92242 + if (len != sizeof(struct arpt_getinfo)) {
92243 + duprintf("length %u != %Zu\n", len,
92244 sizeof(struct arpt_getinfo));
92245 return -EINVAL;
92246 }
92247 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92248 info.size = private->size;
92249 strcpy(info.name, name);
92250
92251 - if (copy_to_user(user, &info, *len) != 0)
92252 + if (copy_to_user(user, &info, len) != 0)
92253 ret = -EFAULT;
92254 else
92255 ret = 0;
92256 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92257
92258 switch (cmd) {
92259 case ARPT_SO_GET_INFO:
92260 - ret = get_info(sock_net(sk), user, len, 1);
92261 + ret = get_info(sock_net(sk), user, *len, 1);
92262 break;
92263 case ARPT_SO_GET_ENTRIES:
92264 ret = compat_get_entries(sock_net(sk), user, len);
92265 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92266
92267 switch (cmd) {
92268 case ARPT_SO_GET_INFO:
92269 - ret = get_info(sock_net(sk), user, len, 0);
92270 + ret = get_info(sock_net(sk), user, *len, 0);
92271 break;
92272
92273 case ARPT_SO_GET_ENTRIES:
92274 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92275 index d23118d..6ad7277 100644
92276 --- a/net/ipv4/netfilter/ip_tables.c
92277 +++ b/net/ipv4/netfilter/ip_tables.c
92278 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92279 #endif
92280
92281 static int get_info(struct net *net, void __user *user,
92282 - const int *len, int compat)
92283 + int len, int compat)
92284 {
92285 char name[XT_TABLE_MAXNAMELEN];
92286 struct xt_table *t;
92287 int ret;
92288
92289 - if (*len != sizeof(struct ipt_getinfo)) {
92290 - duprintf("length %u != %zu\n", *len,
92291 + if (len != sizeof(struct ipt_getinfo)) {
92292 + duprintf("length %u != %zu\n", len,
92293 sizeof(struct ipt_getinfo));
92294 return -EINVAL;
92295 }
92296 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92297 info.size = private->size;
92298 strcpy(info.name, name);
92299
92300 - if (copy_to_user(user, &info, *len) != 0)
92301 + if (copy_to_user(user, &info, len) != 0)
92302 ret = -EFAULT;
92303 else
92304 ret = 0;
92305 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92306
92307 switch (cmd) {
92308 case IPT_SO_GET_INFO:
92309 - ret = get_info(sock_net(sk), user, len, 1);
92310 + ret = get_info(sock_net(sk), user, *len, 1);
92311 break;
92312 case IPT_SO_GET_ENTRIES:
92313 ret = compat_get_entries(sock_net(sk), user, len);
92314 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92315
92316 switch (cmd) {
92317 case IPT_SO_GET_INFO:
92318 - ret = get_info(sock_net(sk), user, len, 0);
92319 + ret = get_info(sock_net(sk), user, *len, 0);
92320 break;
92321
92322 case IPT_SO_GET_ENTRIES:
92323 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
92324 index cbc2215..9cb993c 100644
92325 --- a/net/ipv4/netfilter/ipt_ULOG.c
92326 +++ b/net/ipv4/netfilter/ipt_ULOG.c
92327 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
92328 ub->qlen++;
92329
92330 pm = nlmsg_data(nlh);
92331 + memset(pm, 0, sizeof(*pm));
92332
92333 /* We might not have a timestamp, get one */
92334 if (skb->tstamp.tv64 == 0)
92335 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
92336 }
92337 else if (loginfo->prefix[0] != '\0')
92338 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
92339 - else
92340 - *(pm->prefix) = '\0';
92341
92342 if (in && in->hard_header_len > 0 &&
92343 skb->mac_header != skb->network_header &&
92344 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
92345
92346 if (in)
92347 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
92348 - else
92349 - pm->indev_name[0] = '\0';
92350
92351 if (out)
92352 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
92353 - else
92354 - pm->outdev_name[0] = '\0';
92355
92356 /* copy_len <= skb->len, so can't fail. */
92357 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
92358 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92359 index 746427c..80eab72 100644
92360 --- a/net/ipv4/ping.c
92361 +++ b/net/ipv4/ping.c
92362 @@ -55,7 +55,7 @@
92363
92364
92365 struct ping_table ping_table;
92366 -struct pingv6_ops pingv6_ops;
92367 +struct pingv6_ops *pingv6_ops;
92368 EXPORT_SYMBOL_GPL(pingv6_ops);
92369
92370 static u16 ping_port_rover;
92371 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92372 return -ENODEV;
92373 }
92374 }
92375 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92376 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92377 scoped);
92378 rcu_read_unlock();
92379
92380 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92381 }
92382 #if IS_ENABLED(CONFIG_IPV6)
92383 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92384 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92385 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92386 #endif
92387 }
92388
92389 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92390 info, (u8 *)icmph);
92391 #if IS_ENABLED(CONFIG_IPV6)
92392 } else if (family == AF_INET6) {
92393 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92394 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92395 info, (u8 *)icmph);
92396 #endif
92397 }
92398 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92399 return ip_recv_error(sk, msg, len);
92400 #if IS_ENABLED(CONFIG_IPV6)
92401 } else if (family == AF_INET6) {
92402 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92403 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92404 #endif
92405 }
92406 }
92407 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92408 IP6CB(skb)->iif);
92409
92410 if (inet6_sk(sk)->rxopt.all)
92411 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92412 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92413 #endif
92414 } else {
92415 BUG();
92416 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92417 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92418 0, sock_i_ino(sp),
92419 atomic_read(&sp->sk_refcnt), sp,
92420 - atomic_read(&sp->sk_drops), len);
92421 + atomic_read_unchecked(&sp->sk_drops), len);
92422 }
92423
92424 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92425 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92426 index 6fb2337..9cd6b20 100644
92427 --- a/net/ipv4/raw.c
92428 +++ b/net/ipv4/raw.c
92429 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92430 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92431 {
92432 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92433 - atomic_inc(&sk->sk_drops);
92434 + atomic_inc_unchecked(&sk->sk_drops);
92435 kfree_skb(skb);
92436 return NET_RX_DROP;
92437 }
92438 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
92439
92440 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92441 {
92442 + struct icmp_filter filter;
92443 +
92444 if (optlen > sizeof(struct icmp_filter))
92445 optlen = sizeof(struct icmp_filter);
92446 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92447 + if (copy_from_user(&filter, optval, optlen))
92448 return -EFAULT;
92449 + raw_sk(sk)->filter = filter;
92450 return 0;
92451 }
92452
92453 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92454 {
92455 int len, ret = -EFAULT;
92456 + struct icmp_filter filter;
92457
92458 if (get_user(len, optlen))
92459 goto out;
92460 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92461 if (len > sizeof(struct icmp_filter))
92462 len = sizeof(struct icmp_filter);
92463 ret = -EFAULT;
92464 - if (put_user(len, optlen) ||
92465 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92466 + filter = raw_sk(sk)->filter;
92467 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92468 goto out;
92469 ret = 0;
92470 out: return ret;
92471 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92472 0, 0L, 0,
92473 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92474 0, sock_i_ino(sp),
92475 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92476 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92477 }
92478
92479 static int raw_seq_show(struct seq_file *seq, void *v)
92480 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92481 index a9a54a2..647316e 100644
92482 --- a/net/ipv4/route.c
92483 +++ b/net/ipv4/route.c
92484 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92485 .maxlen = sizeof(int),
92486 .mode = 0200,
92487 .proc_handler = ipv4_sysctl_rtcache_flush,
92488 + .extra1 = &init_net,
92489 },
92490 { },
92491 };
92492
92493 static __net_init int sysctl_route_net_init(struct net *net)
92494 {
92495 - struct ctl_table *tbl;
92496 + ctl_table_no_const *tbl = NULL;
92497
92498 - tbl = ipv4_route_flush_table;
92499 if (!net_eq(net, &init_net)) {
92500 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92501 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92502 if (tbl == NULL)
92503 goto err_dup;
92504
92505 /* Don't export sysctls to unprivileged users */
92506 if (net->user_ns != &init_user_ns)
92507 tbl[0].procname = NULL;
92508 - }
92509 - tbl[0].extra1 = net;
92510 + tbl[0].extra1 = net;
92511 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92512 + } else
92513 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92514
92515 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92516 if (net->ipv4.route_hdr == NULL)
92517 goto err_reg;
92518 return 0;
92519
92520 err_reg:
92521 - if (tbl != ipv4_route_flush_table)
92522 - kfree(tbl);
92523 + kfree(tbl);
92524 err_dup:
92525 return -ENOMEM;
92526 }
92527 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92528
92529 static __net_init int rt_genid_init(struct net *net)
92530 {
92531 - atomic_set(&net->rt_genid, 0);
92532 - atomic_set(&net->fnhe_genid, 0);
92533 + atomic_set_unchecked(&net->rt_genid, 0);
92534 + atomic_set_unchecked(&net->fnhe_genid, 0);
92535 get_random_bytes(&net->ipv4.dev_addr_genid,
92536 sizeof(net->ipv4.dev_addr_genid));
92537 return 0;
92538 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92539 index 610e324..fd42e75 100644
92540 --- a/net/ipv4/sysctl_net_ipv4.c
92541 +++ b/net/ipv4/sysctl_net_ipv4.c
92542 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92543 {
92544 int ret;
92545 int range[2];
92546 - struct ctl_table tmp = {
92547 + ctl_table_no_const tmp = {
92548 .data = &range,
92549 .maxlen = sizeof(range),
92550 .mode = table->mode,
92551 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92552 int ret;
92553 gid_t urange[2];
92554 kgid_t low, high;
92555 - struct ctl_table tmp = {
92556 + ctl_table_no_const tmp = {
92557 .data = &urange,
92558 .maxlen = sizeof(urange),
92559 .mode = table->mode,
92560 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92561 void __user *buffer, size_t *lenp, loff_t *ppos)
92562 {
92563 char val[TCP_CA_NAME_MAX];
92564 - struct ctl_table tbl = {
92565 + ctl_table_no_const tbl = {
92566 .data = val,
92567 .maxlen = TCP_CA_NAME_MAX,
92568 };
92569 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92570 void __user *buffer, size_t *lenp,
92571 loff_t *ppos)
92572 {
92573 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92574 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92575 int ret;
92576
92577 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92578 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92579 void __user *buffer, size_t *lenp,
92580 loff_t *ppos)
92581 {
92582 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92583 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92584 int ret;
92585
92586 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92587 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
92588 struct mem_cgroup *memcg;
92589 #endif
92590
92591 - struct ctl_table tmp = {
92592 + ctl_table_no_const tmp = {
92593 .data = &vec,
92594 .maxlen = sizeof(vec),
92595 .mode = ctl->mode,
92596 };
92597
92598 if (!write) {
92599 - ctl->data = &net->ipv4.sysctl_tcp_mem;
92600 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
92601 + ctl_table_no_const tcp_mem = *ctl;
92602 +
92603 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
92604 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
92605 }
92606
92607 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
92608 @@ -239,7 +241,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
92609 void __user *buffer, size_t *lenp,
92610 loff_t *ppos)
92611 {
92612 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92613 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92614 struct tcp_fastopen_context *ctxt;
92615 int ret;
92616 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
92617 @@ -482,7 +484,7 @@ static struct ctl_table ipv4_table[] = {
92618 },
92619 {
92620 .procname = "ip_local_reserved_ports",
92621 - .data = NULL, /* initialized in sysctl_ipv4_init */
92622 + .data = sysctl_local_reserved_ports,
92623 .maxlen = 65536,
92624 .mode = 0644,
92625 .proc_handler = proc_do_large_bitmap,
92626 @@ -847,11 +849,10 @@ static struct ctl_table ipv4_net_table[] = {
92627
92628 static __net_init int ipv4_sysctl_init_net(struct net *net)
92629 {
92630 - struct ctl_table *table;
92631 + ctl_table_no_const *table = NULL;
92632
92633 - table = ipv4_net_table;
92634 if (!net_eq(net, &init_net)) {
92635 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
92636 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
92637 if (table == NULL)
92638 goto err_alloc;
92639
92640 @@ -886,15 +887,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
92641
92642 tcp_init_mem(net);
92643
92644 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92645 + if (!net_eq(net, &init_net))
92646 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92647 + else
92648 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
92649 if (net->ipv4.ipv4_hdr == NULL)
92650 goto err_reg;
92651
92652 return 0;
92653
92654 err_reg:
92655 - if (!net_eq(net, &init_net))
92656 - kfree(table);
92657 + kfree(table);
92658 err_alloc:
92659 return -ENOMEM;
92660 }
92661 @@ -916,16 +919,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
92662 static __init int sysctl_ipv4_init(void)
92663 {
92664 struct ctl_table_header *hdr;
92665 - struct ctl_table *i;
92666 -
92667 - for (i = ipv4_table; i->procname; i++) {
92668 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
92669 - i->data = sysctl_local_reserved_ports;
92670 - break;
92671 - }
92672 - }
92673 - if (!i->procname)
92674 - return -EINVAL;
92675
92676 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
92677 if (hdr == NULL)
92678 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
92679 index 3ca2139..c4cc060 100644
92680 --- a/net/ipv4/tcp_input.c
92681 +++ b/net/ipv4/tcp_input.c
92682 @@ -4379,7 +4379,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
92683 * simplifies code)
92684 */
92685 static void
92686 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92687 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92688 struct sk_buff *head, struct sk_buff *tail,
92689 u32 start, u32 end)
92690 {
92691 @@ -5465,6 +5465,7 @@ discard:
92692 tcp_paws_reject(&tp->rx_opt, 0))
92693 goto discard_and_undo;
92694
92695 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
92696 if (th->syn) {
92697 /* We see SYN without ACK. It is attempt of
92698 * simultaneous connect with crossed SYNs.
92699 @@ -5515,6 +5516,7 @@ discard:
92700 goto discard;
92701 #endif
92702 }
92703 +#endif
92704 /* "fifth, if neither of the SYN or RST bits is set then
92705 * drop the segment and return."
92706 */
92707 @@ -5560,7 +5562,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
92708 goto discard;
92709
92710 if (th->syn) {
92711 - if (th->fin)
92712 + if (th->fin || th->urg || th->psh)
92713 goto discard;
92714 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
92715 return 1;
92716 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
92717 index b299da5..097db06 100644
92718 --- a/net/ipv4/tcp_ipv4.c
92719 +++ b/net/ipv4/tcp_ipv4.c
92720 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
92721 EXPORT_SYMBOL(sysctl_tcp_low_latency);
92722
92723
92724 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92725 +extern int grsec_enable_blackhole;
92726 +#endif
92727 +
92728 #ifdef CONFIG_TCP_MD5SIG
92729 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
92730 __be32 daddr, __be32 saddr, const struct tcphdr *th);
92731 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
92732 return 0;
92733
92734 reset:
92735 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92736 + if (!grsec_enable_blackhole)
92737 +#endif
92738 tcp_v4_send_reset(rsk, skb);
92739 discard:
92740 kfree_skb(skb);
92741 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
92742 TCP_SKB_CB(skb)->sacked = 0;
92743
92744 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
92745 - if (!sk)
92746 + if (!sk) {
92747 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92748 + ret = 1;
92749 +#endif
92750 goto no_tcp_socket;
92751 -
92752 + }
92753 process:
92754 - if (sk->sk_state == TCP_TIME_WAIT)
92755 + if (sk->sk_state == TCP_TIME_WAIT) {
92756 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92757 + ret = 2;
92758 +#endif
92759 goto do_time_wait;
92760 + }
92761
92762 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
92763 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
92764 @@ -2034,6 +2048,10 @@ csum_error:
92765 bad_packet:
92766 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
92767 } else {
92768 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92769 + if (!grsec_enable_blackhole || (ret == 1 &&
92770 + (skb->dev->flags & IFF_LOOPBACK)))
92771 +#endif
92772 tcp_v4_send_reset(NULL, skb);
92773 }
92774
92775 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
92776 index ab1c086..2a8d76b 100644
92777 --- a/net/ipv4/tcp_minisocks.c
92778 +++ b/net/ipv4/tcp_minisocks.c
92779 @@ -27,6 +27,10 @@
92780 #include <net/inet_common.h>
92781 #include <net/xfrm.h>
92782
92783 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92784 +extern int grsec_enable_blackhole;
92785 +#endif
92786 +
92787 int sysctl_tcp_syncookies __read_mostly = 1;
92788 EXPORT_SYMBOL(sysctl_tcp_syncookies);
92789
92790 @@ -715,7 +719,10 @@ embryonic_reset:
92791 * avoid becoming vulnerable to outside attack aiming at
92792 * resetting legit local connections.
92793 */
92794 - req->rsk_ops->send_reset(sk, skb);
92795 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92796 + if (!grsec_enable_blackhole)
92797 +#endif
92798 + req->rsk_ops->send_reset(sk, skb);
92799 } else if (fastopen) { /* received a valid RST pkt */
92800 reqsk_fastopen_remove(sk, req, true);
92801 tcp_reset(sk);
92802 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
92803 index d4943f6..e7a74a5 100644
92804 --- a/net/ipv4/tcp_probe.c
92805 +++ b/net/ipv4/tcp_probe.c
92806 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
92807 if (cnt + width >= len)
92808 break;
92809
92810 - if (copy_to_user(buf + cnt, tbuf, width))
92811 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
92812 return -EFAULT;
92813 cnt += width;
92814 }
92815 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
92816 index 4b85e6f..22f9ac9 100644
92817 --- a/net/ipv4/tcp_timer.c
92818 +++ b/net/ipv4/tcp_timer.c
92819 @@ -22,6 +22,10 @@
92820 #include <linux/gfp.h>
92821 #include <net/tcp.h>
92822
92823 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92824 +extern int grsec_lastack_retries;
92825 +#endif
92826 +
92827 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
92828 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
92829 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
92830 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
92831 }
92832 }
92833
92834 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92835 + if ((sk->sk_state == TCP_LAST_ACK) &&
92836 + (grsec_lastack_retries > 0) &&
92837 + (grsec_lastack_retries < retry_until))
92838 + retry_until = grsec_lastack_retries;
92839 +#endif
92840 +
92841 if (retransmits_timed_out(sk, retry_until,
92842 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
92843 /* Has it gone just too far? */
92844 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
92845 index 766e6ba..aff2f8d 100644
92846 --- a/net/ipv4/udp.c
92847 +++ b/net/ipv4/udp.c
92848 @@ -87,6 +87,7 @@
92849 #include <linux/types.h>
92850 #include <linux/fcntl.h>
92851 #include <linux/module.h>
92852 +#include <linux/security.h>
92853 #include <linux/socket.h>
92854 #include <linux/sockios.h>
92855 #include <linux/igmp.h>
92856 @@ -112,6 +113,10 @@
92857 #include <net/busy_poll.h>
92858 #include "udp_impl.h"
92859
92860 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92861 +extern int grsec_enable_blackhole;
92862 +#endif
92863 +
92864 struct udp_table udp_table __read_mostly;
92865 EXPORT_SYMBOL(udp_table);
92866
92867 @@ -595,6 +600,9 @@ found:
92868 return s;
92869 }
92870
92871 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
92872 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
92873 +
92874 /*
92875 * This routine is called by the ICMP module when it gets some
92876 * sort of error condition. If err < 0 then the socket should
92877 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92878 dport = usin->sin_port;
92879 if (dport == 0)
92880 return -EINVAL;
92881 +
92882 + err = gr_search_udp_sendmsg(sk, usin);
92883 + if (err)
92884 + return err;
92885 } else {
92886 if (sk->sk_state != TCP_ESTABLISHED)
92887 return -EDESTADDRREQ;
92888 +
92889 + err = gr_search_udp_sendmsg(sk, NULL);
92890 + if (err)
92891 + return err;
92892 +
92893 daddr = inet->inet_daddr;
92894 dport = inet->inet_dport;
92895 /* Open fast path for connected socket.
92896 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
92897 IS_UDPLITE(sk));
92898 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
92899 IS_UDPLITE(sk));
92900 - atomic_inc(&sk->sk_drops);
92901 + atomic_inc_unchecked(&sk->sk_drops);
92902 __skb_unlink(skb, rcvq);
92903 __skb_queue_tail(&list_kill, skb);
92904 }
92905 @@ -1223,6 +1240,10 @@ try_again:
92906 if (!skb)
92907 goto out;
92908
92909 + err = gr_search_udp_recvmsg(sk, skb);
92910 + if (err)
92911 + goto out_free;
92912 +
92913 ulen = skb->len - sizeof(struct udphdr);
92914 copied = len;
92915 if (copied > ulen)
92916 @@ -1256,7 +1277,7 @@ try_again:
92917 if (unlikely(err)) {
92918 trace_kfree_skb(skb, udp_recvmsg);
92919 if (!peeked) {
92920 - atomic_inc(&sk->sk_drops);
92921 + atomic_inc_unchecked(&sk->sk_drops);
92922 UDP_INC_STATS_USER(sock_net(sk),
92923 UDP_MIB_INERRORS, is_udplite);
92924 }
92925 @@ -1543,7 +1564,7 @@ csum_error:
92926 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
92927 drop:
92928 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
92929 - atomic_inc(&sk->sk_drops);
92930 + atomic_inc_unchecked(&sk->sk_drops);
92931 kfree_skb(skb);
92932 return -1;
92933 }
92934 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
92935 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
92936
92937 if (!skb1) {
92938 - atomic_inc(&sk->sk_drops);
92939 + atomic_inc_unchecked(&sk->sk_drops);
92940 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
92941 IS_UDPLITE(sk));
92942 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
92943 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
92944 goto csum_error;
92945
92946 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
92947 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92948 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
92949 +#endif
92950 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
92951
92952 /*
92953 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
92954 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92955 0, sock_i_ino(sp),
92956 atomic_read(&sp->sk_refcnt), sp,
92957 - atomic_read(&sp->sk_drops), len);
92958 + atomic_read_unchecked(&sp->sk_drops), len);
92959 }
92960
92961 int udp4_seq_show(struct seq_file *seq, void *v)
92962 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
92963 index 9a459be..c7bc04c 100644
92964 --- a/net/ipv4/xfrm4_policy.c
92965 +++ b/net/ipv4/xfrm4_policy.c
92966 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
92967 fl4->flowi4_tos = iph->tos;
92968 }
92969
92970 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
92971 +static int xfrm4_garbage_collect(struct dst_ops *ops)
92972 {
92973 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
92974
92975 - xfrm4_policy_afinfo.garbage_collect(net);
92976 + xfrm_garbage_collect_deferred(net);
92977 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
92978 }
92979
92980 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
92981
92982 static int __net_init xfrm4_net_init(struct net *net)
92983 {
92984 - struct ctl_table *table;
92985 + ctl_table_no_const *table = NULL;
92986 struct ctl_table_header *hdr;
92987
92988 - table = xfrm4_policy_table;
92989 if (!net_eq(net, &init_net)) {
92990 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
92991 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
92992 if (!table)
92993 goto err_alloc;
92994
92995 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
92996 - }
92997 -
92998 - hdr = register_net_sysctl(net, "net/ipv4", table);
92999 + hdr = register_net_sysctl(net, "net/ipv4", table);
93000 + } else
93001 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93002 if (!hdr)
93003 goto err_reg;
93004
93005 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93006 return 0;
93007
93008 err_reg:
93009 - if (!net_eq(net, &init_net))
93010 - kfree(table);
93011 + kfree(table);
93012 err_alloc:
93013 return -ENOMEM;
93014 }
93015 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93016 index 0f99f7b..9375cf5 100644
93017 --- a/net/ipv6/addrconf.c
93018 +++ b/net/ipv6/addrconf.c
93019 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93020 idx = 0;
93021 head = &net->dev_index_head[h];
93022 rcu_read_lock();
93023 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93024 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93025 net->dev_base_seq;
93026 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93027 if (idx < s_idx)
93028 @@ -2408,7 +2408,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93029 p.iph.ihl = 5;
93030 p.iph.protocol = IPPROTO_IPV6;
93031 p.iph.ttl = 64;
93032 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93033 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93034
93035 if (ops->ndo_do_ioctl) {
93036 mm_segment_t oldfs = get_fs();
93037 @@ -4057,7 +4057,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93038 s_ip_idx = ip_idx = cb->args[2];
93039
93040 rcu_read_lock();
93041 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93042 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93043 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93044 idx = 0;
93045 head = &net->dev_index_head[h];
93046 @@ -4678,7 +4678,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93047 dst_free(&ifp->rt->dst);
93048 break;
93049 }
93050 - atomic_inc(&net->ipv6.dev_addr_genid);
93051 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93052 }
93053
93054 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93055 @@ -4698,7 +4698,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93056 int *valp = ctl->data;
93057 int val = *valp;
93058 loff_t pos = *ppos;
93059 - struct ctl_table lctl;
93060 + ctl_table_no_const lctl;
93061 int ret;
93062
93063 /*
93064 @@ -4783,7 +4783,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93065 int *valp = ctl->data;
93066 int val = *valp;
93067 loff_t pos = *ppos;
93068 - struct ctl_table lctl;
93069 + ctl_table_no_const lctl;
93070 int ret;
93071
93072 /*
93073 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93074 index 197e6f4..16d8396 100644
93075 --- a/net/ipv6/datagram.c
93076 +++ b/net/ipv6/datagram.c
93077 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93078 0,
93079 sock_i_ino(sp),
93080 atomic_read(&sp->sk_refcnt), sp,
93081 - atomic_read(&sp->sk_drops));
93082 + atomic_read_unchecked(&sp->sk_drops));
93083 }
93084 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93085 index 7cfc8d2..c5394b6 100644
93086 --- a/net/ipv6/icmp.c
93087 +++ b/net/ipv6/icmp.c
93088 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93089
93090 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93091 {
93092 - struct ctl_table *table;
93093 + ctl_table_no_const *table;
93094
93095 table = kmemdup(ipv6_icmp_table_template,
93096 sizeof(ipv6_icmp_table_template),
93097 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93098 index 8bc717b..76fbb5d 100644
93099 --- a/net/ipv6/ip6_gre.c
93100 +++ b/net/ipv6/ip6_gre.c
93101 @@ -74,7 +74,7 @@ struct ip6gre_net {
93102 struct net_device *fb_tunnel_dev;
93103 };
93104
93105 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93106 +static struct rtnl_link_ops ip6gre_link_ops;
93107 static int ip6gre_tunnel_init(struct net_device *dev);
93108 static void ip6gre_tunnel_setup(struct net_device *dev);
93109 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93110 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93111 }
93112
93113
93114 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93115 +static struct inet6_protocol ip6gre_protocol = {
93116 .handler = ip6gre_rcv,
93117 .err_handler = ip6gre_err,
93118 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93119 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93120 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93121 };
93122
93123 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93124 +static struct rtnl_link_ops ip6gre_link_ops = {
93125 .kind = "ip6gre",
93126 .maxtype = IFLA_GRE_MAX,
93127 .policy = ip6gre_policy,
93128 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93129 .fill_info = ip6gre_fill_info,
93130 };
93131
93132 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93133 +static struct rtnl_link_ops ip6gre_tap_ops = {
93134 .kind = "ip6gretap",
93135 .maxtype = IFLA_GRE_MAX,
93136 .policy = ip6gre_policy,
93137 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93138 index cf5d490..30946f0 100644
93139 --- a/net/ipv6/ip6_tunnel.c
93140 +++ b/net/ipv6/ip6_tunnel.c
93141 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93142
93143 static int ip6_tnl_dev_init(struct net_device *dev);
93144 static void ip6_tnl_dev_setup(struct net_device *dev);
93145 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93146 +static struct rtnl_link_ops ip6_link_ops;
93147
93148 static int ip6_tnl_net_id __read_mostly;
93149 struct ip6_tnl_net {
93150 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93151 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93152 };
93153
93154 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93155 +static struct rtnl_link_ops ip6_link_ops = {
93156 .kind = "ip6tnl",
93157 .maxtype = IFLA_IPTUN_MAX,
93158 .policy = ip6_tnl_policy,
93159 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93160 index d1e2e8e..51c19ae 100644
93161 --- a/net/ipv6/ipv6_sockglue.c
93162 +++ b/net/ipv6/ipv6_sockglue.c
93163 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93164 if (sk->sk_type != SOCK_STREAM)
93165 return -ENOPROTOOPT;
93166
93167 - msg.msg_control = optval;
93168 + msg.msg_control = (void __force_kernel *)optval;
93169 msg.msg_controllen = len;
93170 msg.msg_flags = flags;
93171
93172 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93173 index 44400c2..8e11f52 100644
93174 --- a/net/ipv6/netfilter/ip6_tables.c
93175 +++ b/net/ipv6/netfilter/ip6_tables.c
93176 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93177 #endif
93178
93179 static int get_info(struct net *net, void __user *user,
93180 - const int *len, int compat)
93181 + int len, int compat)
93182 {
93183 char name[XT_TABLE_MAXNAMELEN];
93184 struct xt_table *t;
93185 int ret;
93186
93187 - if (*len != sizeof(struct ip6t_getinfo)) {
93188 - duprintf("length %u != %zu\n", *len,
93189 + if (len != sizeof(struct ip6t_getinfo)) {
93190 + duprintf("length %u != %zu\n", len,
93191 sizeof(struct ip6t_getinfo));
93192 return -EINVAL;
93193 }
93194 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93195 info.size = private->size;
93196 strcpy(info.name, name);
93197
93198 - if (copy_to_user(user, &info, *len) != 0)
93199 + if (copy_to_user(user, &info, len) != 0)
93200 ret = -EFAULT;
93201 else
93202 ret = 0;
93203 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93204
93205 switch (cmd) {
93206 case IP6T_SO_GET_INFO:
93207 - ret = get_info(sock_net(sk), user, len, 1);
93208 + ret = get_info(sock_net(sk), user, *len, 1);
93209 break;
93210 case IP6T_SO_GET_ENTRIES:
93211 ret = compat_get_entries(sock_net(sk), user, len);
93212 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93213
93214 switch (cmd) {
93215 case IP6T_SO_GET_INFO:
93216 - ret = get_info(sock_net(sk), user, len, 0);
93217 + ret = get_info(sock_net(sk), user, *len, 0);
93218 break;
93219
93220 case IP6T_SO_GET_ENTRIES:
93221 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93222 index dffdc1a..ccc6678 100644
93223 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93224 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93225 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93226
93227 static int nf_ct_frag6_sysctl_register(struct net *net)
93228 {
93229 - struct ctl_table *table;
93230 + ctl_table_no_const *table = NULL;
93231 struct ctl_table_header *hdr;
93232
93233 - table = nf_ct_frag6_sysctl_table;
93234 if (!net_eq(net, &init_net)) {
93235 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93236 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93237 GFP_KERNEL);
93238 if (table == NULL)
93239 goto err_alloc;
93240 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93241 table[0].data = &net->nf_frag.frags.timeout;
93242 table[1].data = &net->nf_frag.frags.low_thresh;
93243 table[2].data = &net->nf_frag.frags.high_thresh;
93244 - }
93245 -
93246 - hdr = register_net_sysctl(net, "net/netfilter", table);
93247 + hdr = register_net_sysctl(net, "net/netfilter", table);
93248 + } else
93249 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93250 if (hdr == NULL)
93251 goto err_reg;
93252
93253 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93254 return 0;
93255
93256 err_reg:
93257 - if (!net_eq(net, &init_net))
93258 - kfree(table);
93259 + kfree(table);
93260 err_alloc:
93261 return -ENOMEM;
93262 }
93263 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93264 index ab92a36..bb4a528 100644
93265 --- a/net/ipv6/output_core.c
93266 +++ b/net/ipv6/output_core.c
93267 @@ -8,8 +8,8 @@
93268
93269 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93270 {
93271 - static atomic_t ipv6_fragmentation_id;
93272 - int old, new;
93273 + static atomic_unchecked_t ipv6_fragmentation_id;
93274 + int id;
93275
93276 #if IS_ENABLED(CONFIG_IPV6)
93277 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93278 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93279 }
93280 }
93281 #endif
93282 - do {
93283 - old = atomic_read(&ipv6_fragmentation_id);
93284 - new = old + 1;
93285 - if (!new)
93286 - new = 1;
93287 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93288 - fhdr->identification = htonl(new);
93289 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93290 + if (!id)
93291 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93292 + fhdr->identification = htonl(id);
93293 }
93294 EXPORT_SYMBOL(ipv6_select_ident);
93295
93296 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93297 index 18f19df..b46ada1 100644
93298 --- a/net/ipv6/ping.c
93299 +++ b/net/ipv6/ping.c
93300 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93301 };
93302 #endif
93303
93304 +static struct pingv6_ops real_pingv6_ops = {
93305 + .ipv6_recv_error = ipv6_recv_error,
93306 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93307 + .icmpv6_err_convert = icmpv6_err_convert,
93308 + .ipv6_icmp_error = ipv6_icmp_error,
93309 + .ipv6_chk_addr = ipv6_chk_addr,
93310 +};
93311 +
93312 +static struct pingv6_ops dummy_pingv6_ops = {
93313 + .ipv6_recv_error = dummy_ipv6_recv_error,
93314 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93315 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93316 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93317 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93318 +};
93319 +
93320 int __init pingv6_init(void)
93321 {
93322 #ifdef CONFIG_PROC_FS
93323 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93324 if (ret)
93325 return ret;
93326 #endif
93327 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93328 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93329 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93330 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93331 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93332 + pingv6_ops = &real_pingv6_ops;
93333 return inet6_register_protosw(&pingv6_protosw);
93334 }
93335
93336 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93337 */
93338 void pingv6_exit(void)
93339 {
93340 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93341 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93342 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93343 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93344 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93345 + pingv6_ops = &dummy_pingv6_ops;
93346 #ifdef CONFIG_PROC_FS
93347 unregister_pernet_subsys(&ping_v6_net_ops);
93348 #endif
93349 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93350 index cdaed47..515edde9 100644
93351 --- a/net/ipv6/raw.c
93352 +++ b/net/ipv6/raw.c
93353 @@ -108,7 +108,7 @@ found:
93354 */
93355 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93356 {
93357 - struct icmp6hdr *_hdr;
93358 + struct icmp6hdr _hdr;
93359 const struct icmp6hdr *hdr;
93360
93361 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93362 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93363 {
93364 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93365 skb_checksum_complete(skb)) {
93366 - atomic_inc(&sk->sk_drops);
93367 + atomic_inc_unchecked(&sk->sk_drops);
93368 kfree_skb(skb);
93369 return NET_RX_DROP;
93370 }
93371 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93372 struct raw6_sock *rp = raw6_sk(sk);
93373
93374 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93375 - atomic_inc(&sk->sk_drops);
93376 + atomic_inc_unchecked(&sk->sk_drops);
93377 kfree_skb(skb);
93378 return NET_RX_DROP;
93379 }
93380 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93381
93382 if (inet->hdrincl) {
93383 if (skb_checksum_complete(skb)) {
93384 - atomic_inc(&sk->sk_drops);
93385 + atomic_inc_unchecked(&sk->sk_drops);
93386 kfree_skb(skb);
93387 return NET_RX_DROP;
93388 }
93389 @@ -602,7 +602,7 @@ out:
93390 return err;
93391 }
93392
93393 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93394 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93395 struct flowi6 *fl6, struct dst_entry **dstp,
93396 unsigned int flags)
93397 {
93398 @@ -915,12 +915,15 @@ do_confirm:
93399 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93400 char __user *optval, int optlen)
93401 {
93402 + struct icmp6_filter filter;
93403 +
93404 switch (optname) {
93405 case ICMPV6_FILTER:
93406 if (optlen > sizeof(struct icmp6_filter))
93407 optlen = sizeof(struct icmp6_filter);
93408 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93409 + if (copy_from_user(&filter, optval, optlen))
93410 return -EFAULT;
93411 + raw6_sk(sk)->filter = filter;
93412 return 0;
93413 default:
93414 return -ENOPROTOOPT;
93415 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93416 char __user *optval, int __user *optlen)
93417 {
93418 int len;
93419 + struct icmp6_filter filter;
93420
93421 switch (optname) {
93422 case ICMPV6_FILTER:
93423 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93424 len = sizeof(struct icmp6_filter);
93425 if (put_user(len, optlen))
93426 return -EFAULT;
93427 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93428 + filter = raw6_sk(sk)->filter;
93429 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93430 return -EFAULT;
93431 return 0;
93432 default:
93433 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93434 index 1aeb473..bea761c 100644
93435 --- a/net/ipv6/reassembly.c
93436 +++ b/net/ipv6/reassembly.c
93437 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93438
93439 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93440 {
93441 - struct ctl_table *table;
93442 + ctl_table_no_const *table = NULL;
93443 struct ctl_table_header *hdr;
93444
93445 - table = ip6_frags_ns_ctl_table;
93446 if (!net_eq(net, &init_net)) {
93447 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93448 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93449 if (table == NULL)
93450 goto err_alloc;
93451
93452 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93453 /* Don't export sysctls to unprivileged users */
93454 if (net->user_ns != &init_user_ns)
93455 table[0].procname = NULL;
93456 - }
93457 + hdr = register_net_sysctl(net, "net/ipv6", table);
93458 + } else
93459 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93460
93461 - hdr = register_net_sysctl(net, "net/ipv6", table);
93462 if (hdr == NULL)
93463 goto err_reg;
93464
93465 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93466 return 0;
93467
93468 err_reg:
93469 - if (!net_eq(net, &init_net))
93470 - kfree(table);
93471 + kfree(table);
93472 err_alloc:
93473 return -ENOMEM;
93474 }
93475 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93476 index 8d9a93ed..cd89616 100644
93477 --- a/net/ipv6/route.c
93478 +++ b/net/ipv6/route.c
93479 @@ -2926,7 +2926,7 @@ struct ctl_table ipv6_route_table_template[] = {
93480
93481 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93482 {
93483 - struct ctl_table *table;
93484 + ctl_table_no_const *table;
93485
93486 table = kmemdup(ipv6_route_table_template,
93487 sizeof(ipv6_route_table_template),
93488 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93489 index 86f639b..71e355e 100644
93490 --- a/net/ipv6/sit.c
93491 +++ b/net/ipv6/sit.c
93492 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93493 static void ipip6_dev_free(struct net_device *dev);
93494 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93495 __be32 *v4dst);
93496 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93497 +static struct rtnl_link_ops sit_link_ops;
93498
93499 static int sit_net_id __read_mostly;
93500 struct sit_net {
93501 @@ -1601,7 +1601,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93502 #endif
93503 };
93504
93505 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93506 +static struct rtnl_link_ops sit_link_ops = {
93507 .kind = "sit",
93508 .maxtype = IFLA_IPTUN_MAX,
93509 .policy = ipip6_policy,
93510 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93511 index 107b2f1..72741a9 100644
93512 --- a/net/ipv6/sysctl_net_ipv6.c
93513 +++ b/net/ipv6/sysctl_net_ipv6.c
93514 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93515
93516 static int __net_init ipv6_sysctl_net_init(struct net *net)
93517 {
93518 - struct ctl_table *ipv6_table;
93519 + ctl_table_no_const *ipv6_table;
93520 struct ctl_table *ipv6_route_table;
93521 struct ctl_table *ipv6_icmp_table;
93522 int err;
93523 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93524 index 6e1649d..75ddb4c 100644
93525 --- a/net/ipv6/tcp_ipv6.c
93526 +++ b/net/ipv6/tcp_ipv6.c
93527 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93528 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93529 }
93530
93531 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93532 +extern int grsec_enable_blackhole;
93533 +#endif
93534 +
93535 static void tcp_v6_hash(struct sock *sk)
93536 {
93537 if (sk->sk_state != TCP_CLOSE) {
93538 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93539 return 0;
93540
93541 reset:
93542 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93543 + if (!grsec_enable_blackhole)
93544 +#endif
93545 tcp_v6_send_reset(sk, skb);
93546 discard:
93547 if (opt_skb)
93548 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
93549 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
93550 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
93551 if (np->rxopt.bits.rxtclass)
93552 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
93553 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
93554 if (ipv6_opt_accepted(sk, opt_skb)) {
93555 skb_set_owner_r(opt_skb, sk);
93556 opt_skb = xchg(&np->pktoptions, opt_skb);
93557 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
93558 TCP_SKB_CB(skb)->sacked = 0;
93559
93560 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93561 - if (!sk)
93562 + if (!sk) {
93563 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93564 + ret = 1;
93565 +#endif
93566 goto no_tcp_socket;
93567 + }
93568
93569 process:
93570 - if (sk->sk_state == TCP_TIME_WAIT)
93571 + if (sk->sk_state == TCP_TIME_WAIT) {
93572 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93573 + ret = 2;
93574 +#endif
93575 goto do_time_wait;
93576 + }
93577
93578 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
93579 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93580 @@ -1538,6 +1553,10 @@ csum_error:
93581 bad_packet:
93582 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93583 } else {
93584 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93585 + if (!grsec_enable_blackhole || (ret == 1 &&
93586 + (skb->dev->flags & IFF_LOOPBACK)))
93587 +#endif
93588 tcp_v6_send_reset(NULL, skb);
93589 }
93590
93591 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
93592 index f405815..45a68a6 100644
93593 --- a/net/ipv6/udp.c
93594 +++ b/net/ipv6/udp.c
93595 @@ -53,6 +53,10 @@
93596 #include <trace/events/skb.h>
93597 #include "udp_impl.h"
93598
93599 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93600 +extern int grsec_enable_blackhole;
93601 +#endif
93602 +
93603 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
93604 {
93605 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
93606 @@ -420,7 +424,7 @@ try_again:
93607 if (unlikely(err)) {
93608 trace_kfree_skb(skb, udpv6_recvmsg);
93609 if (!peeked) {
93610 - atomic_inc(&sk->sk_drops);
93611 + atomic_inc_unchecked(&sk->sk_drops);
93612 if (is_udp4)
93613 UDP_INC_STATS_USER(sock_net(sk),
93614 UDP_MIB_INERRORS,
93615 @@ -666,7 +670,7 @@ csum_error:
93616 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93617 drop:
93618 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93619 - atomic_inc(&sk->sk_drops);
93620 + atomic_inc_unchecked(&sk->sk_drops);
93621 kfree_skb(skb);
93622 return -1;
93623 }
93624 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93625 if (likely(skb1 == NULL))
93626 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93627 if (!skb1) {
93628 - atomic_inc(&sk->sk_drops);
93629 + atomic_inc_unchecked(&sk->sk_drops);
93630 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93631 IS_UDPLITE(sk));
93632 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93633 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93634 goto csum_error;
93635
93636 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93637 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93638 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93639 +#endif
93640 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
93641
93642 kfree_skb(skb);
93643 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
93644 index 23ed03d..6532e67 100644
93645 --- a/net/ipv6/xfrm6_policy.c
93646 +++ b/net/ipv6/xfrm6_policy.c
93647 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
93648 }
93649 }
93650
93651 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
93652 +static int xfrm6_garbage_collect(struct dst_ops *ops)
93653 {
93654 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
93655
93656 - xfrm6_policy_afinfo.garbage_collect(net);
93657 + xfrm_garbage_collect_deferred(net);
93658 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
93659 }
93660
93661 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
93662
93663 static int __net_init xfrm6_net_init(struct net *net)
93664 {
93665 - struct ctl_table *table;
93666 + ctl_table_no_const *table = NULL;
93667 struct ctl_table_header *hdr;
93668
93669 - table = xfrm6_policy_table;
93670 if (!net_eq(net, &init_net)) {
93671 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93672 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93673 if (!table)
93674 goto err_alloc;
93675
93676 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
93677 - }
93678 + hdr = register_net_sysctl(net, "net/ipv6", table);
93679 + } else
93680 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
93681
93682 - hdr = register_net_sysctl(net, "net/ipv6", table);
93683 if (!hdr)
93684 goto err_reg;
93685
93686 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
93687 return 0;
93688
93689 err_reg:
93690 - if (!net_eq(net, &init_net))
93691 - kfree(table);
93692 + kfree(table);
93693 err_alloc:
93694 return -ENOMEM;
93695 }
93696 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
93697 index 41ac7938..75e3bb1 100644
93698 --- a/net/irda/ircomm/ircomm_tty.c
93699 +++ b/net/irda/ircomm/ircomm_tty.c
93700 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93701 add_wait_queue(&port->open_wait, &wait);
93702
93703 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
93704 - __FILE__, __LINE__, tty->driver->name, port->count);
93705 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93706
93707 spin_lock_irqsave(&port->lock, flags);
93708 if (!tty_hung_up_p(filp))
93709 - port->count--;
93710 + atomic_dec(&port->count);
93711 port->blocked_open++;
93712 spin_unlock_irqrestore(&port->lock, flags);
93713
93714 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93715 }
93716
93717 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
93718 - __FILE__, __LINE__, tty->driver->name, port->count);
93719 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93720
93721 schedule();
93722 }
93723 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93724
93725 spin_lock_irqsave(&port->lock, flags);
93726 if (!tty_hung_up_p(filp))
93727 - port->count++;
93728 + atomic_inc(&port->count);
93729 port->blocked_open--;
93730 spin_unlock_irqrestore(&port->lock, flags);
93731
93732 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
93733 - __FILE__, __LINE__, tty->driver->name, port->count);
93734 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93735
93736 if (!retval)
93737 port->flags |= ASYNC_NORMAL_ACTIVE;
93738 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
93739
93740 /* ++ is not atomic, so this should be protected - Jean II */
93741 spin_lock_irqsave(&self->port.lock, flags);
93742 - self->port.count++;
93743 + atomic_inc(&self->port.count);
93744 spin_unlock_irqrestore(&self->port.lock, flags);
93745 tty_port_tty_set(&self->port, tty);
93746
93747 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
93748 - self->line, self->port.count);
93749 + self->line, atomic_read(&self->port.count));
93750
93751 /* Not really used by us, but lets do it anyway */
93752 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
93753 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
93754 tty_kref_put(port->tty);
93755 }
93756 port->tty = NULL;
93757 - port->count = 0;
93758 + atomic_set(&port->count, 0);
93759 spin_unlock_irqrestore(&port->lock, flags);
93760
93761 wake_up_interruptible(&port->open_wait);
93762 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
93763 seq_putc(m, '\n');
93764
93765 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
93766 - seq_printf(m, "Open count: %d\n", self->port.count);
93767 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
93768 seq_printf(m, "Max data size: %d\n", self->max_data_size);
93769 seq_printf(m, "Max header size: %d\n", self->max_header_size);
93770
93771 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
93772 index 168aff5..9d43132 100644
93773 --- a/net/iucv/af_iucv.c
93774 +++ b/net/iucv/af_iucv.c
93775 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
93776
93777 write_lock_bh(&iucv_sk_list.lock);
93778
93779 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
93780 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
93781 while (__iucv_get_sock_by_name(name)) {
93782 sprintf(name, "%08x",
93783 - atomic_inc_return(&iucv_sk_list.autobind_name));
93784 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
93785 }
93786
93787 write_unlock_bh(&iucv_sk_list.lock);
93788 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
93789 index cd5b8ec..f205e6b 100644
93790 --- a/net/iucv/iucv.c
93791 +++ b/net/iucv/iucv.c
93792 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
93793 return NOTIFY_OK;
93794 }
93795
93796 -static struct notifier_block __refdata iucv_cpu_notifier = {
93797 +static struct notifier_block iucv_cpu_notifier = {
93798 .notifier_call = iucv_cpu_notify,
93799 };
93800
93801 diff --git a/net/key/af_key.c b/net/key/af_key.c
93802 index ab8bd2c..3a3eb81 100644
93803 --- a/net/key/af_key.c
93804 +++ b/net/key/af_key.c
93805 @@ -1098,7 +1098,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
93806
93807 x->id.proto = proto;
93808 x->id.spi = sa->sadb_sa_spi;
93809 - x->props.replay_window = sa->sadb_sa_replay;
93810 + x->props.replay_window = min_t(unsigned int, sa->sadb_sa_replay,
93811 + (sizeof(x->replay.bitmap) * 8));
93812 if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN)
93813 x->props.flags |= XFRM_STATE_NOECN;
93814 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP)
93815 @@ -3048,10 +3049,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
93816 static u32 get_acqseq(void)
93817 {
93818 u32 res;
93819 - static atomic_t acqseq;
93820 + static atomic_unchecked_t acqseq;
93821
93822 do {
93823 - res = atomic_inc_return(&acqseq);
93824 + res = atomic_inc_return_unchecked(&acqseq);
93825 } while (!res);
93826 return res;
93827 }
93828 diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
93829 index feae495..aedaa2c 100644
93830 --- a/net/l2tp/l2tp_core.c
93831 +++ b/net/l2tp/l2tp_core.c
93832 @@ -496,6 +496,7 @@ out:
93833 static inline int l2tp_verify_udp_checksum(struct sock *sk,
93834 struct sk_buff *skb)
93835 {
93836 + struct l2tp_tunnel *tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
93837 struct udphdr *uh = udp_hdr(skb);
93838 u16 ulen = ntohs(uh->len);
93839 __wsum psum;
93840 @@ -504,7 +505,7 @@ static inline int l2tp_verify_udp_checksum(struct sock *sk,
93841 return 0;
93842
93843 #if IS_ENABLED(CONFIG_IPV6)
93844 - if (sk->sk_family == PF_INET6) {
93845 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped) {
93846 if (!uh->check) {
93847 LIMIT_NETDEBUG(KERN_INFO "L2TP: IPv6: checksum is 0\n");
93848 return 1;
93849 @@ -1128,7 +1129,7 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
93850 /* Queue the packet to IP for output */
93851 skb->local_df = 1;
93852 #if IS_ENABLED(CONFIG_IPV6)
93853 - if (skb->sk->sk_family == PF_INET6)
93854 + if (skb->sk->sk_family == PF_INET6 && !tunnel->v4mapped)
93855 error = inet6_csk_xmit(skb, NULL);
93856 else
93857 #endif
93858 @@ -1255,7 +1256,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
93859
93860 /* Calculate UDP checksum if configured to do so */
93861 #if IS_ENABLED(CONFIG_IPV6)
93862 - if (sk->sk_family == PF_INET6)
93863 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped)
93864 l2tp_xmit_ipv6_csum(sk, skb, udp_len);
93865 else
93866 #endif
93867 @@ -1704,6 +1705,24 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
93868 if (cfg != NULL)
93869 tunnel->debug = cfg->debug;
93870
93871 +#if IS_ENABLED(CONFIG_IPV6)
93872 + if (sk->sk_family == PF_INET6) {
93873 + struct ipv6_pinfo *np = inet6_sk(sk);
93874 +
93875 + if (ipv6_addr_v4mapped(&np->saddr) &&
93876 + ipv6_addr_v4mapped(&np->daddr)) {
93877 + struct inet_sock *inet = inet_sk(sk);
93878 +
93879 + tunnel->v4mapped = true;
93880 + inet->inet_saddr = np->saddr.s6_addr32[3];
93881 + inet->inet_rcv_saddr = np->rcv_saddr.s6_addr32[3];
93882 + inet->inet_daddr = np->daddr.s6_addr32[3];
93883 + } else {
93884 + tunnel->v4mapped = false;
93885 + }
93886 + }
93887 +#endif
93888 +
93889 /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */
93890 tunnel->encap = encap;
93891 if (encap == L2TP_ENCAPTYPE_UDP) {
93892 @@ -1712,7 +1731,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
93893 udp_sk(sk)->encap_rcv = l2tp_udp_encap_recv;
93894 udp_sk(sk)->encap_destroy = l2tp_udp_encap_destroy;
93895 #if IS_ENABLED(CONFIG_IPV6)
93896 - if (sk->sk_family == PF_INET6)
93897 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped)
93898 udpv6_encap_enable();
93899 else
93900 #endif
93901 diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
93902 index 66a559b..6f251cb 100644
93903 --- a/net/l2tp/l2tp_core.h
93904 +++ b/net/l2tp/l2tp_core.h
93905 @@ -194,6 +194,9 @@ struct l2tp_tunnel {
93906 struct sock *sock; /* Parent socket */
93907 int fd; /* Parent fd, if tunnel socket
93908 * was created by userspace */
93909 +#if IS_ENABLED(CONFIG_IPV6)
93910 + bool v4mapped;
93911 +#endif
93912
93913 struct work_struct del_work;
93914
93915 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
93916 index 43dd752..63a23bc 100644
93917 --- a/net/mac80211/cfg.c
93918 +++ b/net/mac80211/cfg.c
93919 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
93920 ret = ieee80211_vif_use_channel(sdata, chandef,
93921 IEEE80211_CHANCTX_EXCLUSIVE);
93922 }
93923 - } else if (local->open_count == local->monitors) {
93924 + } else if (local_read(&local->open_count) == local->monitors) {
93925 local->_oper_chandef = *chandef;
93926 ieee80211_hw_config(local, 0);
93927 }
93928 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
93929 else
93930 local->probe_req_reg--;
93931
93932 - if (!local->open_count)
93933 + if (!local_read(&local->open_count))
93934 break;
93935
93936 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
93937 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
93938 if (chanctx_conf) {
93939 *chandef = chanctx_conf->def;
93940 ret = 0;
93941 - } else if (local->open_count > 0 &&
93942 - local->open_count == local->monitors &&
93943 + } else if (local_read(&local->open_count) > 0 &&
93944 + local_read(&local->open_count) == local->monitors &&
93945 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
93946 if (local->use_chanctx)
93947 *chandef = local->monitor_chandef;
93948 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
93949 index 8412a30..6e00181 100644
93950 --- a/net/mac80211/ieee80211_i.h
93951 +++ b/net/mac80211/ieee80211_i.h
93952 @@ -28,6 +28,7 @@
93953 #include <net/ieee80211_radiotap.h>
93954 #include <net/cfg80211.h>
93955 #include <net/mac80211.h>
93956 +#include <asm/local.h>
93957 #include "key.h"
93958 #include "sta_info.h"
93959 #include "debug.h"
93960 @@ -907,7 +908,7 @@ struct ieee80211_local {
93961 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
93962 spinlock_t queue_stop_reason_lock;
93963
93964 - int open_count;
93965 + local_t open_count;
93966 int monitors, cooked_mntrs;
93967 /* number of interfaces with corresponding FIF_ flags */
93968 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
93969 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
93970 index cc11759..11d5541 100644
93971 --- a/net/mac80211/iface.c
93972 +++ b/net/mac80211/iface.c
93973 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
93974 break;
93975 }
93976
93977 - if (local->open_count == 0) {
93978 + if (local_read(&local->open_count) == 0) {
93979 res = drv_start(local);
93980 if (res)
93981 goto err_del_bss;
93982 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
93983 res = drv_add_interface(local, sdata);
93984 if (res)
93985 goto err_stop;
93986 - } else if (local->monitors == 0 && local->open_count == 0) {
93987 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
93988 res = ieee80211_add_virtual_monitor(local);
93989 if (res)
93990 goto err_stop;
93991 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
93992 atomic_inc(&local->iff_promiscs);
93993
93994 if (coming_up)
93995 - local->open_count++;
93996 + local_inc(&local->open_count);
93997
93998 if (hw_reconf_flags)
93999 ieee80211_hw_config(local, hw_reconf_flags);
94000 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94001 err_del_interface:
94002 drv_remove_interface(local, sdata);
94003 err_stop:
94004 - if (!local->open_count)
94005 + if (!local_read(&local->open_count))
94006 drv_stop(local);
94007 err_del_bss:
94008 sdata->bss = NULL;
94009 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94010 }
94011
94012 if (going_down)
94013 - local->open_count--;
94014 + local_dec(&local->open_count);
94015
94016 switch (sdata->vif.type) {
94017 case NL80211_IFTYPE_AP_VLAN:
94018 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94019 }
94020 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94021
94022 - if (local->open_count == 0)
94023 + if (local_read(&local->open_count) == 0)
94024 ieee80211_clear_tx_pending(local);
94025
94026 /*
94027 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94028
94029 ieee80211_recalc_ps(local, -1);
94030
94031 - if (local->open_count == 0) {
94032 + if (local_read(&local->open_count) == 0) {
94033 ieee80211_stop_device(local);
94034
94035 /* no reconfiguring after stop! */
94036 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94037 ieee80211_configure_filter(local);
94038 ieee80211_hw_config(local, hw_reconf_flags);
94039
94040 - if (local->monitors == local->open_count)
94041 + if (local->monitors == local_read(&local->open_count))
94042 ieee80211_add_virtual_monitor(local);
94043 }
94044
94045 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94046 index 091088a..daf43c7 100644
94047 --- a/net/mac80211/main.c
94048 +++ b/net/mac80211/main.c
94049 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94050 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94051 IEEE80211_CONF_CHANGE_POWER);
94052
94053 - if (changed && local->open_count) {
94054 + if (changed && local_read(&local->open_count)) {
94055 ret = drv_config(local, changed);
94056 /*
94057 * Goal:
94058 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94059 index 3401262..d5cd68d 100644
94060 --- a/net/mac80211/pm.c
94061 +++ b/net/mac80211/pm.c
94062 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94063 struct ieee80211_sub_if_data *sdata;
94064 struct sta_info *sta;
94065
94066 - if (!local->open_count)
94067 + if (!local_read(&local->open_count))
94068 goto suspend;
94069
94070 ieee80211_scan_cancel(local);
94071 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94072 cancel_work_sync(&local->dynamic_ps_enable_work);
94073 del_timer_sync(&local->dynamic_ps_timer);
94074
94075 - local->wowlan = wowlan && local->open_count;
94076 + local->wowlan = wowlan && local_read(&local->open_count);
94077 if (local->wowlan) {
94078 int err = drv_suspend(local, wowlan);
94079 if (err < 0) {
94080 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94081 WARN_ON(!list_empty(&local->chanctx_list));
94082
94083 /* stop hardware - this must stop RX */
94084 - if (local->open_count)
94085 + if (local_read(&local->open_count))
94086 ieee80211_stop_device(local);
94087
94088 suspend:
94089 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94090 index 30d58d2..449ac8e 100644
94091 --- a/net/mac80211/rate.c
94092 +++ b/net/mac80211/rate.c
94093 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94094
94095 ASSERT_RTNL();
94096
94097 - if (local->open_count)
94098 + if (local_read(&local->open_count))
94099 return -EBUSY;
94100
94101 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94102 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94103 index c97a065..ff61928 100644
94104 --- a/net/mac80211/rc80211_pid_debugfs.c
94105 +++ b/net/mac80211/rc80211_pid_debugfs.c
94106 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94107
94108 spin_unlock_irqrestore(&events->lock, status);
94109
94110 - if (copy_to_user(buf, pb, p))
94111 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94112 return -EFAULT;
94113
94114 return p;
94115 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94116 index 2265445..ba14971 100644
94117 --- a/net/mac80211/util.c
94118 +++ b/net/mac80211/util.c
94119 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94120 }
94121 #endif
94122 /* everything else happens only if HW was up & running */
94123 - if (!local->open_count)
94124 + if (!local_read(&local->open_count))
94125 goto wake_up;
94126
94127 /*
94128 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94129 local->in_reconfig = false;
94130 barrier();
94131
94132 - if (local->monitors == local->open_count && local->monitors > 0)
94133 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94134 ieee80211_add_virtual_monitor(local);
94135
94136 /*
94137 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94138 index 56d22ca..87c778f 100644
94139 --- a/net/netfilter/Kconfig
94140 +++ b/net/netfilter/Kconfig
94141 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94142
94143 To compile it as a module, choose M here. If unsure, say N.
94144
94145 +config NETFILTER_XT_MATCH_GRADM
94146 + tristate '"gradm" match support'
94147 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94148 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94149 + ---help---
94150 + The gradm match allows to match on grsecurity RBAC being enabled.
94151 + It is useful when iptables rules are applied early on bootup to
94152 + prevent connections to the machine (except from a trusted host)
94153 + while the RBAC system is disabled.
94154 +
94155 config NETFILTER_XT_MATCH_HASHLIMIT
94156 tristate '"hashlimit" match support'
94157 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94158 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94159 index a1abf87..dbcb7ee 100644
94160 --- a/net/netfilter/Makefile
94161 +++ b/net/netfilter/Makefile
94162 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94163 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94164 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94165 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94166 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94167 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94168 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94169 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94170 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94171 index f771390..145b765 100644
94172 --- a/net/netfilter/ipset/ip_set_core.c
94173 +++ b/net/netfilter/ipset/ip_set_core.c
94174 @@ -1820,7 +1820,7 @@ done:
94175 return ret;
94176 }
94177
94178 -static struct nf_sockopt_ops so_set __read_mostly = {
94179 +static struct nf_sockopt_ops so_set = {
94180 .pf = PF_INET,
94181 .get_optmin = SO_IP_SET,
94182 .get_optmax = SO_IP_SET + 1,
94183 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94184 index 4c8e5c0..5a79b4d 100644
94185 --- a/net/netfilter/ipvs/ip_vs_conn.c
94186 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94187 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94188 /* Increase the refcnt counter of the dest */
94189 ip_vs_dest_hold(dest);
94190
94191 - conn_flags = atomic_read(&dest->conn_flags);
94192 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94193 if (cp->protocol != IPPROTO_UDP)
94194 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94195 flags = cp->flags;
94196 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94197
94198 cp->control = NULL;
94199 atomic_set(&cp->n_control, 0);
94200 - atomic_set(&cp->in_pkts, 0);
94201 + atomic_set_unchecked(&cp->in_pkts, 0);
94202
94203 cp->packet_xmit = NULL;
94204 cp->app = NULL;
94205 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94206
94207 /* Don't drop the entry if its number of incoming packets is not
94208 located in [0, 8] */
94209 - i = atomic_read(&cp->in_pkts);
94210 + i = atomic_read_unchecked(&cp->in_pkts);
94211 if (i > 8 || i < 0) return 0;
94212
94213 if (!todrop_rate[i]) return 0;
94214 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94215 index 4f69e83..da2d8bf 100644
94216 --- a/net/netfilter/ipvs/ip_vs_core.c
94217 +++ b/net/netfilter/ipvs/ip_vs_core.c
94218 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94219 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94220 /* do not touch skb anymore */
94221
94222 - atomic_inc(&cp->in_pkts);
94223 + atomic_inc_unchecked(&cp->in_pkts);
94224 ip_vs_conn_put(cp);
94225 return ret;
94226 }
94227 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94228 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94229 pkts = sysctl_sync_threshold(ipvs);
94230 else
94231 - pkts = atomic_add_return(1, &cp->in_pkts);
94232 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94233
94234 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94235 ip_vs_sync_conn(net, cp, pkts);
94236 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94237 index c8148e4..eff604f 100644
94238 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94239 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94240 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94241 */
94242 ip_vs_rs_hash(ipvs, dest);
94243 }
94244 - atomic_set(&dest->conn_flags, conn_flags);
94245 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94246
94247 /* bind the service */
94248 if (!dest->svc) {
94249 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94250 * align with netns init in ip_vs_control_net_init()
94251 */
94252
94253 -static struct ctl_table vs_vars[] = {
94254 +static ctl_table_no_const vs_vars[] __read_only = {
94255 {
94256 .procname = "amemthresh",
94257 .maxlen = sizeof(int),
94258 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94259 " %-7s %-6d %-10d %-10d\n",
94260 &dest->addr.in6,
94261 ntohs(dest->port),
94262 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94263 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94264 atomic_read(&dest->weight),
94265 atomic_read(&dest->activeconns),
94266 atomic_read(&dest->inactconns));
94267 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94268 "%-7s %-6d %-10d %-10d\n",
94269 ntohl(dest->addr.ip),
94270 ntohs(dest->port),
94271 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94272 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94273 atomic_read(&dest->weight),
94274 atomic_read(&dest->activeconns),
94275 atomic_read(&dest->inactconns));
94276 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94277
94278 entry.addr = dest->addr.ip;
94279 entry.port = dest->port;
94280 - entry.conn_flags = atomic_read(&dest->conn_flags);
94281 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94282 entry.weight = atomic_read(&dest->weight);
94283 entry.u_threshold = dest->u_threshold;
94284 entry.l_threshold = dest->l_threshold;
94285 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94286 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94287 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94288 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94289 - (atomic_read(&dest->conn_flags) &
94290 + (atomic_read_unchecked(&dest->conn_flags) &
94291 IP_VS_CONN_F_FWD_MASK)) ||
94292 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94293 atomic_read(&dest->weight)) ||
94294 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94295 {
94296 int idx;
94297 struct netns_ipvs *ipvs = net_ipvs(net);
94298 - struct ctl_table *tbl;
94299 + ctl_table_no_const *tbl;
94300
94301 atomic_set(&ipvs->dropentry, 0);
94302 spin_lock_init(&ipvs->dropentry_lock);
94303 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94304 index 1383b0e..a486da1 100644
94305 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94306 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94307 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94308 * IPVS LBLC sysctl table
94309 */
94310 #ifdef CONFIG_SYSCTL
94311 -static struct ctl_table vs_vars_table[] = {
94312 +static ctl_table_no_const vs_vars_table[] __read_only = {
94313 {
94314 .procname = "lblc_expiration",
94315 .data = NULL,
94316 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94317 index 3cd85b2..dfab2b8 100644
94318 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94319 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94320 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94321 * IPVS LBLCR sysctl table
94322 */
94323
94324 -static struct ctl_table vs_vars_table[] = {
94325 +static ctl_table_no_const vs_vars_table[] __read_only = {
94326 {
94327 .procname = "lblcr_expiration",
94328 .data = NULL,
94329 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94330 index f448471..995f131 100644
94331 --- a/net/netfilter/ipvs/ip_vs_sync.c
94332 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94333 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94334 cp = cp->control;
94335 if (cp) {
94336 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94337 - pkts = atomic_add_return(1, &cp->in_pkts);
94338 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94339 else
94340 pkts = sysctl_sync_threshold(ipvs);
94341 ip_vs_sync_conn(net, cp->control, pkts);
94342 @@ -771,7 +771,7 @@ control:
94343 if (!cp)
94344 return;
94345 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94346 - pkts = atomic_add_return(1, &cp->in_pkts);
94347 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94348 else
94349 pkts = sysctl_sync_threshold(ipvs);
94350 goto sloop;
94351 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94352
94353 if (opt)
94354 memcpy(&cp->in_seq, opt, sizeof(*opt));
94355 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94356 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94357 cp->state = state;
94358 cp->old_state = cp->state;
94359 /*
94360 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94361 index c47444e..b0961c6 100644
94362 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94363 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94364 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94365 else
94366 rc = NF_ACCEPT;
94367 /* do not touch skb anymore */
94368 - atomic_inc(&cp->in_pkts);
94369 + atomic_inc_unchecked(&cp->in_pkts);
94370 goto out;
94371 }
94372
94373 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94374 else
94375 rc = NF_ACCEPT;
94376 /* do not touch skb anymore */
94377 - atomic_inc(&cp->in_pkts);
94378 + atomic_inc_unchecked(&cp->in_pkts);
94379 goto out;
94380 }
94381
94382 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94383 index 2d3030a..7ba1c0a 100644
94384 --- a/net/netfilter/nf_conntrack_acct.c
94385 +++ b/net/netfilter/nf_conntrack_acct.c
94386 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94387 #ifdef CONFIG_SYSCTL
94388 static int nf_conntrack_acct_init_sysctl(struct net *net)
94389 {
94390 - struct ctl_table *table;
94391 + ctl_table_no_const *table;
94392
94393 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94394 GFP_KERNEL);
94395 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94396 index 0283bae..5febcb0 100644
94397 --- a/net/netfilter/nf_conntrack_core.c
94398 +++ b/net/netfilter/nf_conntrack_core.c
94399 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94400 #define DYING_NULLS_VAL ((1<<30)+1)
94401 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94402
94403 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94404 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94405 +#endif
94406 +
94407 int nf_conntrack_init_net(struct net *net)
94408 {
94409 int ret;
94410 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94411 goto err_stat;
94412 }
94413
94414 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94415 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94416 +#else
94417 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94418 +#endif
94419 if (!net->ct.slabname) {
94420 ret = -ENOMEM;
94421 goto err_slabname;
94422 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94423 index 1df1761..ce8b88a 100644
94424 --- a/net/netfilter/nf_conntrack_ecache.c
94425 +++ b/net/netfilter/nf_conntrack_ecache.c
94426 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94427 #ifdef CONFIG_SYSCTL
94428 static int nf_conntrack_event_init_sysctl(struct net *net)
94429 {
94430 - struct ctl_table *table;
94431 + ctl_table_no_const *table;
94432
94433 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94434 GFP_KERNEL);
94435 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94436 index 974a2a4..52cc6ff 100644
94437 --- a/net/netfilter/nf_conntrack_helper.c
94438 +++ b/net/netfilter/nf_conntrack_helper.c
94439 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94440
94441 static int nf_conntrack_helper_init_sysctl(struct net *net)
94442 {
94443 - struct ctl_table *table;
94444 + ctl_table_no_const *table;
94445
94446 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94447 GFP_KERNEL);
94448 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94449 index 0ab9636..cea3c6a 100644
94450 --- a/net/netfilter/nf_conntrack_proto.c
94451 +++ b/net/netfilter/nf_conntrack_proto.c
94452 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94453
94454 static void
94455 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94456 - struct ctl_table **table,
94457 + ctl_table_no_const **table,
94458 unsigned int users)
94459 {
94460 if (users > 0)
94461 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94462 index a99b6c3..cb372f9 100644
94463 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94464 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94465 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94466 const char *msg;
94467 u_int8_t state;
94468
94469 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94470 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94471 BUG_ON(dh == NULL);
94472
94473 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94474 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94475 out_invalid:
94476 if (LOG_INVALID(net, IPPROTO_DCCP))
94477 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94478 - NULL, msg);
94479 + NULL, "%s", msg);
94480 return false;
94481 }
94482
94483 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94484 u_int8_t type, old_state, new_state;
94485 enum ct_dccp_roles role;
94486
94487 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94488 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94489 BUG_ON(dh == NULL);
94490 type = dh->dccph_type;
94491
94492 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94493 unsigned int cscov;
94494 const char *msg;
94495
94496 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94497 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94498 if (dh == NULL) {
94499 msg = "nf_ct_dccp: short packet ";
94500 goto out_invalid;
94501 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94502
94503 out_invalid:
94504 if (LOG_INVALID(net, IPPROTO_DCCP))
94505 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94506 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94507 return -NF_ACCEPT;
94508 }
94509
94510 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94511 index f641751..d3c5b51 100644
94512 --- a/net/netfilter/nf_conntrack_standalone.c
94513 +++ b/net/netfilter/nf_conntrack_standalone.c
94514 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94515
94516 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94517 {
94518 - struct ctl_table *table;
94519 + ctl_table_no_const *table;
94520
94521 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94522 GFP_KERNEL);
94523 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94524 index 902fb0a..87f7fdb 100644
94525 --- a/net/netfilter/nf_conntrack_timestamp.c
94526 +++ b/net/netfilter/nf_conntrack_timestamp.c
94527 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94528 #ifdef CONFIG_SYSCTL
94529 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94530 {
94531 - struct ctl_table *table;
94532 + ctl_table_no_const *table;
94533
94534 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94535 GFP_KERNEL);
94536 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94537 index 85296d4..8becdec 100644
94538 --- a/net/netfilter/nf_log.c
94539 +++ b/net/netfilter/nf_log.c
94540 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94541
94542 #ifdef CONFIG_SYSCTL
94543 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94544 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94545 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94546
94547 static int nf_log_proc_dostring(struct ctl_table *table, int write,
94548 void __user *buffer, size_t *lenp, loff_t *ppos)
94549 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
94550 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
94551 mutex_unlock(&nf_log_mutex);
94552 } else {
94553 + ctl_table_no_const nf_log_table = *table;
94554 +
94555 mutex_lock(&nf_log_mutex);
94556 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
94557 lockdep_is_held(&nf_log_mutex));
94558 if (!logger)
94559 - table->data = "NONE";
94560 + nf_log_table.data = "NONE";
94561 else
94562 - table->data = logger->name;
94563 - r = proc_dostring(table, write, buffer, lenp, ppos);
94564 + nf_log_table.data = logger->name;
94565 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
94566 mutex_unlock(&nf_log_mutex);
94567 }
94568
94569 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
94570 index f042ae5..30ea486 100644
94571 --- a/net/netfilter/nf_sockopt.c
94572 +++ b/net/netfilter/nf_sockopt.c
94573 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
94574 }
94575 }
94576
94577 - list_add(&reg->list, &nf_sockopts);
94578 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
94579 out:
94580 mutex_unlock(&nf_sockopt_mutex);
94581 return ret;
94582 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
94583 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
94584 {
94585 mutex_lock(&nf_sockopt_mutex);
94586 - list_del(&reg->list);
94587 + pax_list_del((struct list_head *)&reg->list);
94588 mutex_unlock(&nf_sockopt_mutex);
94589 }
94590 EXPORT_SYMBOL(nf_unregister_sockopt);
94591 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
94592 index d92cc31..e46f350 100644
94593 --- a/net/netfilter/nfnetlink_log.c
94594 +++ b/net/netfilter/nfnetlink_log.c
94595 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
94596 struct nfnl_log_net {
94597 spinlock_t instances_lock;
94598 struct hlist_head instance_table[INSTANCE_BUCKETS];
94599 - atomic_t global_seq;
94600 + atomic_unchecked_t global_seq;
94601 };
94602
94603 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
94604 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
94605 /* global sequence number */
94606 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
94607 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
94608 - htonl(atomic_inc_return(&log->global_seq))))
94609 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
94610 goto nla_put_failure;
94611
94612 if (data_len) {
94613 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
94614 new file mode 100644
94615 index 0000000..c566332
94616 --- /dev/null
94617 +++ b/net/netfilter/xt_gradm.c
94618 @@ -0,0 +1,51 @@
94619 +/*
94620 + * gradm match for netfilter
94621 + * Copyright © Zbigniew Krzystolik, 2010
94622 + *
94623 + * This program is free software; you can redistribute it and/or modify
94624 + * it under the terms of the GNU General Public License; either version
94625 + * 2 or 3 as published by the Free Software Foundation.
94626 + */
94627 +#include <linux/module.h>
94628 +#include <linux/moduleparam.h>
94629 +#include <linux/skbuff.h>
94630 +#include <linux/netfilter/x_tables.h>
94631 +#include <linux/grsecurity.h>
94632 +#include <linux/netfilter/xt_gradm.h>
94633 +
94634 +static bool
94635 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
94636 +{
94637 + const struct xt_gradm_mtinfo *info = par->matchinfo;
94638 + bool retval = false;
94639 + if (gr_acl_is_enabled())
94640 + retval = true;
94641 + return retval ^ info->invflags;
94642 +}
94643 +
94644 +static struct xt_match gradm_mt_reg __read_mostly = {
94645 + .name = "gradm",
94646 + .revision = 0,
94647 + .family = NFPROTO_UNSPEC,
94648 + .match = gradm_mt,
94649 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
94650 + .me = THIS_MODULE,
94651 +};
94652 +
94653 +static int __init gradm_mt_init(void)
94654 +{
94655 + return xt_register_match(&gradm_mt_reg);
94656 +}
94657 +
94658 +static void __exit gradm_mt_exit(void)
94659 +{
94660 + xt_unregister_match(&gradm_mt_reg);
94661 +}
94662 +
94663 +module_init(gradm_mt_init);
94664 +module_exit(gradm_mt_exit);
94665 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
94666 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
94667 +MODULE_LICENSE("GPL");
94668 +MODULE_ALIAS("ipt_gradm");
94669 +MODULE_ALIAS("ip6t_gradm");
94670 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
94671 index 4fe4fb4..87a89e5 100644
94672 --- a/net/netfilter/xt_statistic.c
94673 +++ b/net/netfilter/xt_statistic.c
94674 @@ -19,7 +19,7 @@
94675 #include <linux/module.h>
94676
94677 struct xt_statistic_priv {
94678 - atomic_t count;
94679 + atomic_unchecked_t count;
94680 } ____cacheline_aligned_in_smp;
94681
94682 MODULE_LICENSE("GPL");
94683 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
94684 break;
94685 case XT_STATISTIC_MODE_NTH:
94686 do {
94687 - oval = atomic_read(&info->master->count);
94688 + oval = atomic_read_unchecked(&info->master->count);
94689 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
94690 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
94691 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
94692 if (nval == 0)
94693 ret = !ret;
94694 break;
94695 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
94696 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
94697 if (info->master == NULL)
94698 return -ENOMEM;
94699 - atomic_set(&info->master->count, info->u.nth.count);
94700 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
94701
94702 return 0;
94703 }
94704 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
94705 index 0c61b59..941bddd 100644
94706 --- a/net/netlink/af_netlink.c
94707 +++ b/net/netlink/af_netlink.c
94708 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
94709 sk->sk_error_report(sk);
94710 }
94711 }
94712 - atomic_inc(&sk->sk_drops);
94713 + atomic_inc_unchecked(&sk->sk_drops);
94714 }
94715
94716 static void netlink_rcv_wake(struct sock *sk)
94717 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
94718 sk_wmem_alloc_get(s),
94719 nlk->cb,
94720 atomic_read(&s->sk_refcnt),
94721 - atomic_read(&s->sk_drops),
94722 + atomic_read_unchecked(&s->sk_drops),
94723 sock_i_ino(s)
94724 );
94725
94726 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
94727 index 0c741ce..f8c8ca7 100644
94728 --- a/net/netlink/genetlink.c
94729 +++ b/net/netlink/genetlink.c
94730 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
94731 goto errout;
94732 }
94733
94734 + pax_open_kernel();
94735 if (ops->dumpit)
94736 - ops->flags |= GENL_CMD_CAP_DUMP;
94737 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
94738 if (ops->doit)
94739 - ops->flags |= GENL_CMD_CAP_DO;
94740 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
94741 if (ops->policy)
94742 - ops->flags |= GENL_CMD_CAP_HASPOL;
94743 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
94744 + pax_close_kernel();
94745
94746 genl_lock_all();
94747 - list_add_tail(&ops->ops_list, &family->ops_list);
94748 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
94749 genl_unlock_all();
94750
94751 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
94752 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
94753 err = 0;
94754 errout:
94755 return err;
94756 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
94757 genl_lock_all();
94758 list_for_each_entry(rc, &family->ops_list, ops_list) {
94759 if (rc == ops) {
94760 - list_del(&ops->ops_list);
94761 + pax_list_del((struct list_head *)&ops->ops_list);
94762 genl_unlock_all();
94763 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
94764 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
94765 return 0;
94766 }
94767 }
94768 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
94769 index 698814b..7cfde4e 100644
94770 --- a/net/netrom/af_netrom.c
94771 +++ b/net/netrom/af_netrom.c
94772 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
94773 *uaddr_len = sizeof(struct full_sockaddr_ax25);
94774 } else {
94775 sax->fsa_ax25.sax25_family = AF_NETROM;
94776 - sax->fsa_ax25.sax25_ndigis = 0;
94777 sax->fsa_ax25.sax25_call = nr->source_addr;
94778 *uaddr_len = sizeof(struct sockaddr_ax25);
94779 }
94780 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
94781 index 75c8bbf..ee9be59 100644
94782 --- a/net/packet/af_packet.c
94783 +++ b/net/packet/af_packet.c
94784 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94785
94786 spin_lock(&sk->sk_receive_queue.lock);
94787 po->stats.stats1.tp_packets++;
94788 - skb->dropcount = atomic_read(&sk->sk_drops);
94789 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
94790 __skb_queue_tail(&sk->sk_receive_queue, skb);
94791 spin_unlock(&sk->sk_receive_queue.lock);
94792 sk->sk_data_ready(sk, skb->len);
94793 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94794 drop_n_acct:
94795 spin_lock(&sk->sk_receive_queue.lock);
94796 po->stats.stats1.tp_drops++;
94797 - atomic_inc(&sk->sk_drops);
94798 + atomic_inc_unchecked(&sk->sk_drops);
94799 spin_unlock(&sk->sk_receive_queue.lock);
94800
94801 drop_n_restore:
94802 @@ -2640,6 +2640,7 @@ out:
94803
94804 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
94805 {
94806 + struct sock_extended_err ee;
94807 struct sock_exterr_skb *serr;
94808 struct sk_buff *skb, *skb2;
94809 int copied, err;
94810 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
94811 sock_recv_timestamp(msg, sk, skb);
94812
94813 serr = SKB_EXT_ERR(skb);
94814 + ee = serr->ee;
94815 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
94816 - sizeof(serr->ee), &serr->ee);
94817 + sizeof ee, &ee);
94818
94819 msg->msg_flags |= MSG_ERRQUEUE;
94820 err = copied;
94821 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
94822 case PACKET_HDRLEN:
94823 if (len > sizeof(int))
94824 len = sizeof(int);
94825 - if (copy_from_user(&val, optval, len))
94826 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
94827 return -EFAULT;
94828 switch (val) {
94829 case TPACKET_V1:
94830 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
94831 len = lv;
94832 if (put_user(len, optlen))
94833 return -EFAULT;
94834 - if (copy_to_user(optval, data, len))
94835 + if (len > sizeof(st) || copy_to_user(optval, data, len))
94836 return -EFAULT;
94837 return 0;
94838 }
94839 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
94840 index e774117..900b8b7 100644
94841 --- a/net/phonet/pep.c
94842 +++ b/net/phonet/pep.c
94843 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
94844
94845 case PNS_PEP_CTRL_REQ:
94846 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
94847 - atomic_inc(&sk->sk_drops);
94848 + atomic_inc_unchecked(&sk->sk_drops);
94849 break;
94850 }
94851 __skb_pull(skb, 4);
94852 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
94853 }
94854
94855 if (pn->rx_credits == 0) {
94856 - atomic_inc(&sk->sk_drops);
94857 + atomic_inc_unchecked(&sk->sk_drops);
94858 err = -ENOBUFS;
94859 break;
94860 }
94861 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
94862 }
94863
94864 if (pn->rx_credits == 0) {
94865 - atomic_inc(&sk->sk_drops);
94866 + atomic_inc_unchecked(&sk->sk_drops);
94867 err = NET_RX_DROP;
94868 break;
94869 }
94870 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
94871 index 1afd138..0b42453 100644
94872 --- a/net/phonet/socket.c
94873 +++ b/net/phonet/socket.c
94874 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
94875 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
94876 sock_i_ino(sk),
94877 atomic_read(&sk->sk_refcnt), sk,
94878 - atomic_read(&sk->sk_drops), &len);
94879 + atomic_read_unchecked(&sk->sk_drops), &len);
94880 }
94881 seq_printf(seq, "%*s\n", 127 - len, "");
94882 return 0;
94883 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
94884 index c02a8c4..3c5b600 100644
94885 --- a/net/phonet/sysctl.c
94886 +++ b/net/phonet/sysctl.c
94887 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
94888 {
94889 int ret;
94890 int range[2] = {local_port_range[0], local_port_range[1]};
94891 - struct ctl_table tmp = {
94892 + ctl_table_no_const tmp = {
94893 .data = &range,
94894 .maxlen = sizeof(range),
94895 .mode = table->mode,
94896 diff --git a/net/rds/cong.c b/net/rds/cong.c
94897 index e5b65ac..f3b6fb7 100644
94898 --- a/net/rds/cong.c
94899 +++ b/net/rds/cong.c
94900 @@ -78,7 +78,7 @@
94901 * finds that the saved generation number is smaller than the global generation
94902 * number, it wakes up the process.
94903 */
94904 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
94905 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
94906
94907 /*
94908 * Congestion monitoring
94909 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
94910 rdsdebug("waking map %p for %pI4\n",
94911 map, &map->m_addr);
94912 rds_stats_inc(s_cong_update_received);
94913 - atomic_inc(&rds_cong_generation);
94914 + atomic_inc_unchecked(&rds_cong_generation);
94915 if (waitqueue_active(&map->m_waitq))
94916 wake_up(&map->m_waitq);
94917 if (waitqueue_active(&rds_poll_waitq))
94918 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
94919
94920 int rds_cong_updated_since(unsigned long *recent)
94921 {
94922 - unsigned long gen = atomic_read(&rds_cong_generation);
94923 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
94924
94925 if (likely(*recent == gen))
94926 return 0;
94927 diff --git a/net/rds/ib.h b/net/rds/ib.h
94928 index 7280ab8..e04f4ea 100644
94929 --- a/net/rds/ib.h
94930 +++ b/net/rds/ib.h
94931 @@ -128,7 +128,7 @@ struct rds_ib_connection {
94932 /* sending acks */
94933 unsigned long i_ack_flags;
94934 #ifdef KERNEL_HAS_ATOMIC64
94935 - atomic64_t i_ack_next; /* next ACK to send */
94936 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
94937 #else
94938 spinlock_t i_ack_lock; /* protect i_ack_next */
94939 u64 i_ack_next; /* next ACK to send */
94940 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
94941 index 31b74f5..dc1fbfa 100644
94942 --- a/net/rds/ib_cm.c
94943 +++ b/net/rds/ib_cm.c
94944 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
94945 /* Clear the ACK state */
94946 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
94947 #ifdef KERNEL_HAS_ATOMIC64
94948 - atomic64_set(&ic->i_ack_next, 0);
94949 + atomic64_set_unchecked(&ic->i_ack_next, 0);
94950 #else
94951 ic->i_ack_next = 0;
94952 #endif
94953 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
94954 index 8eb9501..0c386ff 100644
94955 --- a/net/rds/ib_recv.c
94956 +++ b/net/rds/ib_recv.c
94957 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
94958 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
94959 int ack_required)
94960 {
94961 - atomic64_set(&ic->i_ack_next, seq);
94962 + atomic64_set_unchecked(&ic->i_ack_next, seq);
94963 if (ack_required) {
94964 smp_mb__before_clear_bit();
94965 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
94966 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
94967 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
94968 smp_mb__after_clear_bit();
94969
94970 - return atomic64_read(&ic->i_ack_next);
94971 + return atomic64_read_unchecked(&ic->i_ack_next);
94972 }
94973 #endif
94974
94975 diff --git a/net/rds/iw.h b/net/rds/iw.h
94976 index 04ce3b1..48119a6 100644
94977 --- a/net/rds/iw.h
94978 +++ b/net/rds/iw.h
94979 @@ -134,7 +134,7 @@ struct rds_iw_connection {
94980 /* sending acks */
94981 unsigned long i_ack_flags;
94982 #ifdef KERNEL_HAS_ATOMIC64
94983 - atomic64_t i_ack_next; /* next ACK to send */
94984 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
94985 #else
94986 spinlock_t i_ack_lock; /* protect i_ack_next */
94987 u64 i_ack_next; /* next ACK to send */
94988 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
94989 index a91e1db..cf3053f 100644
94990 --- a/net/rds/iw_cm.c
94991 +++ b/net/rds/iw_cm.c
94992 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
94993 /* Clear the ACK state */
94994 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
94995 #ifdef KERNEL_HAS_ATOMIC64
94996 - atomic64_set(&ic->i_ack_next, 0);
94997 + atomic64_set_unchecked(&ic->i_ack_next, 0);
94998 #else
94999 ic->i_ack_next = 0;
95000 #endif
95001 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95002 index 4503335..db566b4 100644
95003 --- a/net/rds/iw_recv.c
95004 +++ b/net/rds/iw_recv.c
95005 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95006 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95007 int ack_required)
95008 {
95009 - atomic64_set(&ic->i_ack_next, seq);
95010 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95011 if (ack_required) {
95012 smp_mb__before_clear_bit();
95013 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95014 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95015 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95016 smp_mb__after_clear_bit();
95017
95018 - return atomic64_read(&ic->i_ack_next);
95019 + return atomic64_read_unchecked(&ic->i_ack_next);
95020 }
95021 #endif
95022
95023 diff --git a/net/rds/rds.h b/net/rds/rds.h
95024 index ec1d731..90a3a8d 100644
95025 --- a/net/rds/rds.h
95026 +++ b/net/rds/rds.h
95027 @@ -449,7 +449,7 @@ struct rds_transport {
95028 void (*sync_mr)(void *trans_private, int direction);
95029 void (*free_mr)(void *trans_private, int invalidate);
95030 void (*flush_mrs)(void);
95031 -};
95032 +} __do_const;
95033
95034 struct rds_sock {
95035 struct sock rs_sk;
95036 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95037 index edac9ef..16bcb98 100644
95038 --- a/net/rds/tcp.c
95039 +++ b/net/rds/tcp.c
95040 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95041 int val = 1;
95042
95043 set_fs(KERNEL_DS);
95044 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95045 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95046 sizeof(val));
95047 set_fs(oldfs);
95048 }
95049 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95050 index 81cf5a4..b5826ff 100644
95051 --- a/net/rds/tcp_send.c
95052 +++ b/net/rds/tcp_send.c
95053 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95054
95055 oldfs = get_fs();
95056 set_fs(KERNEL_DS);
95057 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95058 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95059 sizeof(val));
95060 set_fs(oldfs);
95061 }
95062 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95063 index e61aa60..f07cc89 100644
95064 --- a/net/rxrpc/af_rxrpc.c
95065 +++ b/net/rxrpc/af_rxrpc.c
95066 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95067 __be32 rxrpc_epoch;
95068
95069 /* current debugging ID */
95070 -atomic_t rxrpc_debug_id;
95071 +atomic_unchecked_t rxrpc_debug_id;
95072
95073 /* count of skbs currently in use */
95074 atomic_t rxrpc_n_skbs;
95075 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95076 index e4d9cbc..b229649 100644
95077 --- a/net/rxrpc/ar-ack.c
95078 +++ b/net/rxrpc/ar-ack.c
95079 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95080
95081 _enter("{%d,%d,%d,%d},",
95082 call->acks_hard, call->acks_unacked,
95083 - atomic_read(&call->sequence),
95084 + atomic_read_unchecked(&call->sequence),
95085 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95086
95087 stop = 0;
95088 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95089
95090 /* each Tx packet has a new serial number */
95091 sp->hdr.serial =
95092 - htonl(atomic_inc_return(&call->conn->serial));
95093 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95094
95095 hdr = (struct rxrpc_header *) txb->head;
95096 hdr->serial = sp->hdr.serial;
95097 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95098 */
95099 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95100 {
95101 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95102 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95103 }
95104
95105 /*
95106 @@ -629,7 +629,7 @@ process_further:
95107
95108 latest = ntohl(sp->hdr.serial);
95109 hard = ntohl(ack.firstPacket);
95110 - tx = atomic_read(&call->sequence);
95111 + tx = atomic_read_unchecked(&call->sequence);
95112
95113 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95114 latest,
95115 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95116 goto maybe_reschedule;
95117
95118 send_ACK_with_skew:
95119 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95120 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95121 ntohl(ack.serial));
95122 send_ACK:
95123 mtu = call->conn->trans->peer->if_mtu;
95124 @@ -1173,7 +1173,7 @@ send_ACK:
95125 ackinfo.rxMTU = htonl(5692);
95126 ackinfo.jumbo_max = htonl(4);
95127
95128 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95129 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95130 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95131 ntohl(hdr.serial),
95132 ntohs(ack.maxSkew),
95133 @@ -1191,7 +1191,7 @@ send_ACK:
95134 send_message:
95135 _debug("send message");
95136
95137 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95138 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95139 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95140 send_message_2:
95141
95142 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95143 index a3bbb36..3341fb9 100644
95144 --- a/net/rxrpc/ar-call.c
95145 +++ b/net/rxrpc/ar-call.c
95146 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95147 spin_lock_init(&call->lock);
95148 rwlock_init(&call->state_lock);
95149 atomic_set(&call->usage, 1);
95150 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95151 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95152 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95153
95154 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95155 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95156 index 4106ca9..a338d7a 100644
95157 --- a/net/rxrpc/ar-connection.c
95158 +++ b/net/rxrpc/ar-connection.c
95159 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95160 rwlock_init(&conn->lock);
95161 spin_lock_init(&conn->state_lock);
95162 atomic_set(&conn->usage, 1);
95163 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95164 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95165 conn->avail_calls = RXRPC_MAXCALLS;
95166 conn->size_align = 4;
95167 conn->header_size = sizeof(struct rxrpc_header);
95168 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95169 index e7ed43a..6afa140 100644
95170 --- a/net/rxrpc/ar-connevent.c
95171 +++ b/net/rxrpc/ar-connevent.c
95172 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95173
95174 len = iov[0].iov_len + iov[1].iov_len;
95175
95176 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95177 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95178 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95179
95180 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95181 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95182 index 529572f..c758ca7 100644
95183 --- a/net/rxrpc/ar-input.c
95184 +++ b/net/rxrpc/ar-input.c
95185 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95186 /* track the latest serial number on this connection for ACK packet
95187 * information */
95188 serial = ntohl(sp->hdr.serial);
95189 - hi_serial = atomic_read(&call->conn->hi_serial);
95190 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95191 while (serial > hi_serial)
95192 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95193 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95194 serial);
95195
95196 /* request ACK generation for any ACK or DATA packet that requests
95197 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95198 index a693aca..81e7293 100644
95199 --- a/net/rxrpc/ar-internal.h
95200 +++ b/net/rxrpc/ar-internal.h
95201 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95202 int error; /* error code for local abort */
95203 int debug_id; /* debug ID for printks */
95204 unsigned int call_counter; /* call ID counter */
95205 - atomic_t serial; /* packet serial number counter */
95206 - atomic_t hi_serial; /* highest serial number received */
95207 + atomic_unchecked_t serial; /* packet serial number counter */
95208 + atomic_unchecked_t hi_serial; /* highest serial number received */
95209 u8 avail_calls; /* number of calls available */
95210 u8 size_align; /* data size alignment (for security) */
95211 u8 header_size; /* rxrpc + security header size */
95212 @@ -346,7 +346,7 @@ struct rxrpc_call {
95213 spinlock_t lock;
95214 rwlock_t state_lock; /* lock for state transition */
95215 atomic_t usage;
95216 - atomic_t sequence; /* Tx data packet sequence counter */
95217 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95218 u32 abort_code; /* local/remote abort code */
95219 enum { /* current state of call */
95220 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95221 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95222 */
95223 extern atomic_t rxrpc_n_skbs;
95224 extern __be32 rxrpc_epoch;
95225 -extern atomic_t rxrpc_debug_id;
95226 +extern atomic_unchecked_t rxrpc_debug_id;
95227 extern struct workqueue_struct *rxrpc_workqueue;
95228
95229 /*
95230 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95231 index 87f7135..74d3703 100644
95232 --- a/net/rxrpc/ar-local.c
95233 +++ b/net/rxrpc/ar-local.c
95234 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95235 spin_lock_init(&local->lock);
95236 rwlock_init(&local->services_lock);
95237 atomic_set(&local->usage, 1);
95238 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95239 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95240 memcpy(&local->srx, srx, sizeof(*srx));
95241 }
95242
95243 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95244 index e1ac183..b43e10e 100644
95245 --- a/net/rxrpc/ar-output.c
95246 +++ b/net/rxrpc/ar-output.c
95247 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95248 sp->hdr.cid = call->cid;
95249 sp->hdr.callNumber = call->call_id;
95250 sp->hdr.seq =
95251 - htonl(atomic_inc_return(&call->sequence));
95252 + htonl(atomic_inc_return_unchecked(&call->sequence));
95253 sp->hdr.serial =
95254 - htonl(atomic_inc_return(&conn->serial));
95255 + htonl(atomic_inc_return_unchecked(&conn->serial));
95256 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95257 sp->hdr.userStatus = 0;
95258 sp->hdr.securityIndex = conn->security_ix;
95259 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95260 index bebaa43..2644591 100644
95261 --- a/net/rxrpc/ar-peer.c
95262 +++ b/net/rxrpc/ar-peer.c
95263 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95264 INIT_LIST_HEAD(&peer->error_targets);
95265 spin_lock_init(&peer->lock);
95266 atomic_set(&peer->usage, 1);
95267 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95268 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95269 memcpy(&peer->srx, srx, sizeof(*srx));
95270
95271 rxrpc_assess_MTU_size(peer);
95272 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95273 index 38047f7..9f48511 100644
95274 --- a/net/rxrpc/ar-proc.c
95275 +++ b/net/rxrpc/ar-proc.c
95276 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95277 atomic_read(&conn->usage),
95278 rxrpc_conn_states[conn->state],
95279 key_serial(conn->key),
95280 - atomic_read(&conn->serial),
95281 - atomic_read(&conn->hi_serial));
95282 + atomic_read_unchecked(&conn->serial),
95283 + atomic_read_unchecked(&conn->hi_serial));
95284
95285 return 0;
95286 }
95287 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95288 index 92df566..87ec1bf 100644
95289 --- a/net/rxrpc/ar-transport.c
95290 +++ b/net/rxrpc/ar-transport.c
95291 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95292 spin_lock_init(&trans->client_lock);
95293 rwlock_init(&trans->conn_lock);
95294 atomic_set(&trans->usage, 1);
95295 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95296 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95297
95298 if (peer->srx.transport.family == AF_INET) {
95299 switch (peer->srx.transport_type) {
95300 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95301 index f226709..0e735a8 100644
95302 --- a/net/rxrpc/rxkad.c
95303 +++ b/net/rxrpc/rxkad.c
95304 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95305
95306 len = iov[0].iov_len + iov[1].iov_len;
95307
95308 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95309 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95310 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95311
95312 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95313 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95314
95315 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95316
95317 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95318 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95319 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95320
95321 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95322 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95323 index 547a461e..ea606e3 100644
95324 --- a/net/sctp/ipv6.c
95325 +++ b/net/sctp/ipv6.c
95326 @@ -968,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95327 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95328 };
95329
95330 -static struct sctp_af sctp_af_inet6 = {
95331 +static struct sctp_af sctp_af_inet6 __read_only = {
95332 .sa_family = AF_INET6,
95333 .sctp_xmit = sctp_v6_xmit,
95334 .setsockopt = ipv6_setsockopt,
95335 @@ -1000,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95336 #endif
95337 };
95338
95339 -static struct sctp_pf sctp_pf_inet6 = {
95340 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95341 .event_msgname = sctp_inet6_event_msgname,
95342 .skb_msgname = sctp_inet6_skb_msgname,
95343 .af_supported = sctp_inet6_af_supported,
95344 @@ -1025,7 +1025,7 @@ void sctp_v6_pf_init(void)
95345
95346 void sctp_v6_pf_exit(void)
95347 {
95348 - list_del(&sctp_af_inet6.list);
95349 + pax_list_del(&sctp_af_inet6.list);
95350 }
95351
95352 /* Initialize IPv6 support and register with socket layer. */
95353 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95354 index 62526c4..36a13c5 100644
95355 --- a/net/sctp/proc.c
95356 +++ b/net/sctp/proc.c
95357 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95358 seq_printf(seq,
95359 "%8pK %8pK %-3d %-3d %-2d %-4d "
95360 "%4d %8d %8d %7d %5lu %-5d %5d ",
95361 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95362 + assoc, sk,
95363 + sctp_sk(sk)->type, sk->sk_state,
95364 assoc->state, hash,
95365 assoc->assoc_id,
95366 assoc->sndbuf_used,
95367 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95368 index 4a17494d..f7e3fa0 100644
95369 --- a/net/sctp/protocol.c
95370 +++ b/net/sctp/protocol.c
95371 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95372 return 0;
95373 }
95374
95375 + pax_open_kernel();
95376 INIT_LIST_HEAD(&af->list);
95377 - list_add_tail(&af->list, &sctp_address_families);
95378 + pax_close_kernel();
95379 + pax_list_add_tail(&af->list, &sctp_address_families);
95380 return 1;
95381 }
95382
95383 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95384
95385 static struct sctp_af sctp_af_inet;
95386
95387 -static struct sctp_pf sctp_pf_inet = {
95388 +static struct sctp_pf sctp_pf_inet __read_only = {
95389 .event_msgname = sctp_inet_event_msgname,
95390 .skb_msgname = sctp_inet_skb_msgname,
95391 .af_supported = sctp_inet_af_supported,
95392 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95393 };
95394
95395 /* IPv4 address related functions. */
95396 -static struct sctp_af sctp_af_inet = {
95397 +static struct sctp_af sctp_af_inet __read_only = {
95398 .sa_family = AF_INET,
95399 .sctp_xmit = sctp_v4_xmit,
95400 .setsockopt = ip_setsockopt,
95401 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95402
95403 static void sctp_v4_pf_exit(void)
95404 {
95405 - list_del(&sctp_af_inet.list);
95406 + pax_list_del(&sctp_af_inet.list);
95407 }
95408
95409 static int sctp_v4_protosw_init(void)
95410 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95411 index 9da6885..7571898 100644
95412 --- a/net/sctp/sm_sideeffect.c
95413 +++ b/net/sctp/sm_sideeffect.c
95414 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95415 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95416 }
95417
95418 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95419 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95420 NULL,
95421 sctp_generate_t1_cookie_event,
95422 sctp_generate_t1_init_event,
95423 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95424 index cf6c6b0..b978b65 100644
95425 --- a/net/sctp/socket.c
95426 +++ b/net/sctp/socket.c
95427 @@ -2159,11 +2159,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95428 {
95429 struct sctp_association *asoc;
95430 struct sctp_ulpevent *event;
95431 + struct sctp_event_subscribe subscribe;
95432
95433 if (optlen > sizeof(struct sctp_event_subscribe))
95434 return -EINVAL;
95435 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95436 + if (copy_from_user(&subscribe, optval, optlen))
95437 return -EFAULT;
95438 + sctp_sk(sk)->subscribe = subscribe;
95439
95440 /*
95441 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95442 @@ -4219,13 +4221,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95443 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95444 int __user *optlen)
95445 {
95446 + struct sctp_event_subscribe subscribe;
95447 +
95448 if (len <= 0)
95449 return -EINVAL;
95450 if (len > sizeof(struct sctp_event_subscribe))
95451 len = sizeof(struct sctp_event_subscribe);
95452 if (put_user(len, optlen))
95453 return -EFAULT;
95454 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95455 + subscribe = sctp_sk(sk)->subscribe;
95456 + if (copy_to_user(optval, &subscribe, len))
95457 return -EFAULT;
95458 return 0;
95459 }
95460 @@ -4243,6 +4248,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95461 */
95462 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95463 {
95464 + __u32 autoclose;
95465 +
95466 /* Applicable to UDP-style socket only */
95467 if (sctp_style(sk, TCP))
95468 return -EOPNOTSUPP;
95469 @@ -4251,7 +4258,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95470 len = sizeof(int);
95471 if (put_user(len, optlen))
95472 return -EFAULT;
95473 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95474 + autoclose = sctp_sk(sk)->autoclose;
95475 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95476 return -EFAULT;
95477 return 0;
95478 }
95479 @@ -4623,12 +4631,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95480 */
95481 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95482 {
95483 + struct sctp_initmsg initmsg;
95484 +
95485 if (len < sizeof(struct sctp_initmsg))
95486 return -EINVAL;
95487 len = sizeof(struct sctp_initmsg);
95488 if (put_user(len, optlen))
95489 return -EFAULT;
95490 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95491 + initmsg = sctp_sk(sk)->initmsg;
95492 + if (copy_to_user(optval, &initmsg, len))
95493 return -EFAULT;
95494 return 0;
95495 }
95496 @@ -4669,6 +4680,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95497 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95498 if (space_left < addrlen)
95499 return -ENOMEM;
95500 + if (addrlen > sizeof(temp) || addrlen < 0)
95501 + return -EFAULT;
95502 if (copy_to_user(to, &temp, addrlen))
95503 return -EFAULT;
95504 to += addrlen;
95505 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95506 index 9a5c4c9..46e4b29 100644
95507 --- a/net/sctp/sysctl.c
95508 +++ b/net/sctp/sysctl.c
95509 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95510 {
95511 struct net *net = current->nsproxy->net_ns;
95512 char tmp[8];
95513 - struct ctl_table tbl;
95514 + ctl_table_no_const tbl;
95515 int ret;
95516 int changed = 0;
95517 char *none = "none";
95518 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95519
95520 int sctp_sysctl_net_register(struct net *net)
95521 {
95522 - struct ctl_table *table;
95523 + ctl_table_no_const *table;
95524 int i;
95525
95526 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95527 diff --git a/net/socket.c b/net/socket.c
95528 index b2d7c62..441a7ef 100644
95529 --- a/net/socket.c
95530 +++ b/net/socket.c
95531 @@ -88,6 +88,7 @@
95532 #include <linux/magic.h>
95533 #include <linux/slab.h>
95534 #include <linux/xattr.h>
95535 +#include <linux/in.h>
95536
95537 #include <asm/uaccess.h>
95538 #include <asm/unistd.h>
95539 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
95540 unsigned int sysctl_net_busy_poll __read_mostly;
95541 #endif
95542
95543 +#include <linux/grsock.h>
95544 +
95545 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
95546 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
95547 unsigned long nr_segs, loff_t pos);
95548 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
95549 */
95550
95551 static DEFINE_SPINLOCK(net_family_lock);
95552 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95553 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95554
95555 /*
95556 * Statistics counters of the socket lists
95557 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
95558 &sockfs_dentry_operations, SOCKFS_MAGIC);
95559 }
95560
95561 -static struct vfsmount *sock_mnt __read_mostly;
95562 +struct vfsmount *sock_mnt __read_mostly;
95563
95564 static struct file_system_type sock_fs_type = {
95565 .name = "sockfs",
95566 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95567 return -EAFNOSUPPORT;
95568 if (type < 0 || type >= SOCK_MAX)
95569 return -EINVAL;
95570 + if (protocol < 0)
95571 + return -EINVAL;
95572
95573 /* Compatibility.
95574
95575 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95576 if (err)
95577 return err;
95578
95579 + if(!kern && !gr_search_socket(family, type, protocol)) {
95580 + if (rcu_access_pointer(net_families[family]) == NULL)
95581 + return -EAFNOSUPPORT;
95582 + else
95583 + return -EACCES;
95584 + }
95585 +
95586 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
95587 + if (rcu_access_pointer(net_families[family]) == NULL)
95588 + return -EAFNOSUPPORT;
95589 + else
95590 + return -EACCES;
95591 + }
95592 +
95593 /*
95594 * Allocate the socket and allow the family to set things up. if
95595 * the protocol is 0, the family is instructed to select an appropriate
95596 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95597 if (sock) {
95598 err = move_addr_to_kernel(umyaddr, addrlen, &address);
95599 if (err >= 0) {
95600 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
95601 + err = -EACCES;
95602 + goto error;
95603 + }
95604 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
95605 + if (err)
95606 + goto error;
95607 +
95608 err = security_socket_bind(sock,
95609 (struct sockaddr *)&address,
95610 addrlen);
95611 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95612 (struct sockaddr *)
95613 &address, addrlen);
95614 }
95615 +error:
95616 fput_light(sock->file, fput_needed);
95617 }
95618 return err;
95619 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
95620 if ((unsigned int)backlog > somaxconn)
95621 backlog = somaxconn;
95622
95623 + if (gr_handle_sock_server_other(sock->sk)) {
95624 + err = -EPERM;
95625 + goto error;
95626 + }
95627 +
95628 + err = gr_search_listen(sock);
95629 + if (err)
95630 + goto error;
95631 +
95632 err = security_socket_listen(sock, backlog);
95633 if (!err)
95634 err = sock->ops->listen(sock, backlog);
95635
95636 +error:
95637 fput_light(sock->file, fput_needed);
95638 }
95639 return err;
95640 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95641 newsock->type = sock->type;
95642 newsock->ops = sock->ops;
95643
95644 + if (gr_handle_sock_server_other(sock->sk)) {
95645 + err = -EPERM;
95646 + sock_release(newsock);
95647 + goto out_put;
95648 + }
95649 +
95650 + err = gr_search_accept(sock);
95651 + if (err) {
95652 + sock_release(newsock);
95653 + goto out_put;
95654 + }
95655 +
95656 /*
95657 * We don't need try_module_get here, as the listening socket (sock)
95658 * has the protocol module (sock->ops->owner) held.
95659 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95660 fd_install(newfd, newfile);
95661 err = newfd;
95662
95663 + gr_attach_curr_ip(newsock->sk);
95664 +
95665 out_put:
95666 fput_light(sock->file, fput_needed);
95667 out:
95668 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95669 int, addrlen)
95670 {
95671 struct socket *sock;
95672 + struct sockaddr *sck;
95673 struct sockaddr_storage address;
95674 int err, fput_needed;
95675
95676 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95677 if (err < 0)
95678 goto out_put;
95679
95680 + sck = (struct sockaddr *)&address;
95681 +
95682 + if (gr_handle_sock_client(sck)) {
95683 + err = -EACCES;
95684 + goto out_put;
95685 + }
95686 +
95687 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
95688 + if (err)
95689 + goto out_put;
95690 +
95691 err =
95692 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
95693 if (err)
95694 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
95695 * the protocol.
95696 */
95697
95698 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
95699 +
95700 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
95701 unsigned int, flags, struct sockaddr __user *, addr,
95702 int, addr_len)
95703 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
95704 struct socket *sock;
95705 struct iovec iov;
95706 struct msghdr msg;
95707 - struct sockaddr_storage address;
95708 + struct sockaddr_storage address = { };
95709 int err, err2;
95710 int fput_needed;
95711
95712 @@ -2040,7 +2106,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
95713 * checking falls down on this.
95714 */
95715 if (copy_from_user(ctl_buf,
95716 - (void __user __force *)msg_sys->msg_control,
95717 + (void __force_user *)msg_sys->msg_control,
95718 ctl_len))
95719 goto out_freectl;
95720 msg_sys->msg_control = ctl_buf;
95721 @@ -2191,7 +2257,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95722 int err, total_len, len;
95723
95724 /* kernel mode address */
95725 - struct sockaddr_storage addr;
95726 + struct sockaddr_storage addr = { };
95727
95728 /* user mode address pointers */
95729 struct sockaddr __user *uaddr;
95730 @@ -2219,7 +2285,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95731 * kernel msghdr to use the kernel address space)
95732 */
95733
95734 - uaddr = (__force void __user *)msg_sys->msg_name;
95735 + uaddr = (void __force_user *)msg_sys->msg_name;
95736 uaddr_len = COMPAT_NAMELEN(msg);
95737 if (MSG_CMSG_COMPAT & flags) {
95738 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
95739 @@ -2974,7 +3040,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
95740 old_fs = get_fs();
95741 set_fs(KERNEL_DS);
95742 err = dev_ioctl(net, cmd,
95743 - (struct ifreq __user __force *) &kifr);
95744 + (struct ifreq __force_user *) &kifr);
95745 set_fs(old_fs);
95746
95747 return err;
95748 @@ -3083,7 +3149,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
95749
95750 old_fs = get_fs();
95751 set_fs(KERNEL_DS);
95752 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
95753 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
95754 set_fs(old_fs);
95755
95756 if (cmd == SIOCGIFMAP && !err) {
95757 @@ -3188,7 +3254,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
95758 ret |= __get_user(rtdev, &(ur4->rt_dev));
95759 if (rtdev) {
95760 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
95761 - r4.rt_dev = (char __user __force *)devname;
95762 + r4.rt_dev = (char __force_user *)devname;
95763 devname[15] = 0;
95764 } else
95765 r4.rt_dev = NULL;
95766 @@ -3414,8 +3480,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
95767 int __user *uoptlen;
95768 int err;
95769
95770 - uoptval = (char __user __force *) optval;
95771 - uoptlen = (int __user __force *) optlen;
95772 + uoptval = (char __force_user *) optval;
95773 + uoptlen = (int __force_user *) optlen;
95774
95775 set_fs(KERNEL_DS);
95776 if (level == SOL_SOCKET)
95777 @@ -3435,7 +3501,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
95778 char __user *uoptval;
95779 int err;
95780
95781 - uoptval = (char __user __force *) optval;
95782 + uoptval = (char __force_user *) optval;
95783
95784 set_fs(KERNEL_DS);
95785 if (level == SOL_SOCKET)
95786 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
95787 index 09fb638..2e6a5c5 100644
95788 --- a/net/sunrpc/auth_gss/svcauth_gss.c
95789 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
95790 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95791 uint64_t *handle)
95792 {
95793 struct rsc rsci, *rscp = NULL;
95794 - static atomic64_t ctxhctr;
95795 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
95796 long long ctxh;
95797 struct gss_api_mech *gm = NULL;
95798 time_t expiry;
95799 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95800 status = -ENOMEM;
95801 /* the handle needs to be just a unique id,
95802 * use a static counter */
95803 - ctxh = atomic64_inc_return(&ctxhctr);
95804 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
95805
95806 /* make a copy for the caller */
95807 *handle = ctxh;
95808 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
95809 index ecbc4e3..ad25df8 100644
95810 --- a/net/sunrpc/clnt.c
95811 +++ b/net/sunrpc/clnt.c
95812 @@ -1304,7 +1304,9 @@ call_start(struct rpc_task *task)
95813 (RPC_IS_ASYNC(task) ? "async" : "sync"));
95814
95815 /* Increment call count */
95816 - task->tk_msg.rpc_proc->p_count++;
95817 + pax_open_kernel();
95818 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
95819 + pax_close_kernel();
95820 clnt->cl_stats->rpccnt++;
95821 task->tk_action = call_reserve;
95822 }
95823 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
95824 index 93a7a4e..3b98b9f 100644
95825 --- a/net/sunrpc/sched.c
95826 +++ b/net/sunrpc/sched.c
95827 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
95828 #ifdef RPC_DEBUG
95829 static void rpc_task_set_debuginfo(struct rpc_task *task)
95830 {
95831 - static atomic_t rpc_pid;
95832 + static atomic_unchecked_t rpc_pid;
95833
95834 - task->tk_pid = atomic_inc_return(&rpc_pid);
95835 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
95836 }
95837 #else
95838 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
95839 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
95840 index b974571..678ed90 100644
95841 --- a/net/sunrpc/svc.c
95842 +++ b/net/sunrpc/svc.c
95843 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
95844 svc_putnl(resv, RPC_SUCCESS);
95845
95846 /* Bump per-procedure stats counter */
95847 - procp->pc_count++;
95848 + pax_open_kernel();
95849 + (*(unsigned int *)&procp->pc_count)++;
95850 + pax_close_kernel();
95851
95852 /* Initialize storage for argp and resp */
95853 memset(rqstp->rq_argp, 0, procp->pc_argsize);
95854 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
95855 index c1b6270..05089c1 100644
95856 --- a/net/sunrpc/xprtrdma/svc_rdma.c
95857 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
95858 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
95859 static unsigned int min_max_inline = 4096;
95860 static unsigned int max_max_inline = 65536;
95861
95862 -atomic_t rdma_stat_recv;
95863 -atomic_t rdma_stat_read;
95864 -atomic_t rdma_stat_write;
95865 -atomic_t rdma_stat_sq_starve;
95866 -atomic_t rdma_stat_rq_starve;
95867 -atomic_t rdma_stat_rq_poll;
95868 -atomic_t rdma_stat_rq_prod;
95869 -atomic_t rdma_stat_sq_poll;
95870 -atomic_t rdma_stat_sq_prod;
95871 +atomic_unchecked_t rdma_stat_recv;
95872 +atomic_unchecked_t rdma_stat_read;
95873 +atomic_unchecked_t rdma_stat_write;
95874 +atomic_unchecked_t rdma_stat_sq_starve;
95875 +atomic_unchecked_t rdma_stat_rq_starve;
95876 +atomic_unchecked_t rdma_stat_rq_poll;
95877 +atomic_unchecked_t rdma_stat_rq_prod;
95878 +atomic_unchecked_t rdma_stat_sq_poll;
95879 +atomic_unchecked_t rdma_stat_sq_prod;
95880
95881 /* Temporary NFS request map and context caches */
95882 struct kmem_cache *svc_rdma_map_cachep;
95883 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
95884 len -= *ppos;
95885 if (len > *lenp)
95886 len = *lenp;
95887 - if (len && copy_to_user(buffer, str_buf, len))
95888 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
95889 return -EFAULT;
95890 *lenp = len;
95891 *ppos += len;
95892 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
95893 {
95894 .procname = "rdma_stat_read",
95895 .data = &rdma_stat_read,
95896 - .maxlen = sizeof(atomic_t),
95897 + .maxlen = sizeof(atomic_unchecked_t),
95898 .mode = 0644,
95899 .proc_handler = read_reset_stat,
95900 },
95901 {
95902 .procname = "rdma_stat_recv",
95903 .data = &rdma_stat_recv,
95904 - .maxlen = sizeof(atomic_t),
95905 + .maxlen = sizeof(atomic_unchecked_t),
95906 .mode = 0644,
95907 .proc_handler = read_reset_stat,
95908 },
95909 {
95910 .procname = "rdma_stat_write",
95911 .data = &rdma_stat_write,
95912 - .maxlen = sizeof(atomic_t),
95913 + .maxlen = sizeof(atomic_unchecked_t),
95914 .mode = 0644,
95915 .proc_handler = read_reset_stat,
95916 },
95917 {
95918 .procname = "rdma_stat_sq_starve",
95919 .data = &rdma_stat_sq_starve,
95920 - .maxlen = sizeof(atomic_t),
95921 + .maxlen = sizeof(atomic_unchecked_t),
95922 .mode = 0644,
95923 .proc_handler = read_reset_stat,
95924 },
95925 {
95926 .procname = "rdma_stat_rq_starve",
95927 .data = &rdma_stat_rq_starve,
95928 - .maxlen = sizeof(atomic_t),
95929 + .maxlen = sizeof(atomic_unchecked_t),
95930 .mode = 0644,
95931 .proc_handler = read_reset_stat,
95932 },
95933 {
95934 .procname = "rdma_stat_rq_poll",
95935 .data = &rdma_stat_rq_poll,
95936 - .maxlen = sizeof(atomic_t),
95937 + .maxlen = sizeof(atomic_unchecked_t),
95938 .mode = 0644,
95939 .proc_handler = read_reset_stat,
95940 },
95941 {
95942 .procname = "rdma_stat_rq_prod",
95943 .data = &rdma_stat_rq_prod,
95944 - .maxlen = sizeof(atomic_t),
95945 + .maxlen = sizeof(atomic_unchecked_t),
95946 .mode = 0644,
95947 .proc_handler = read_reset_stat,
95948 },
95949 {
95950 .procname = "rdma_stat_sq_poll",
95951 .data = &rdma_stat_sq_poll,
95952 - .maxlen = sizeof(atomic_t),
95953 + .maxlen = sizeof(atomic_unchecked_t),
95954 .mode = 0644,
95955 .proc_handler = read_reset_stat,
95956 },
95957 {
95958 .procname = "rdma_stat_sq_prod",
95959 .data = &rdma_stat_sq_prod,
95960 - .maxlen = sizeof(atomic_t),
95961 + .maxlen = sizeof(atomic_unchecked_t),
95962 .mode = 0644,
95963 .proc_handler = read_reset_stat,
95964 },
95965 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
95966 index 0ce7552..d074459 100644
95967 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
95968 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
95969 @@ -501,7 +501,7 @@ next_sge:
95970 svc_rdma_put_context(ctxt, 0);
95971 goto out;
95972 }
95973 - atomic_inc(&rdma_stat_read);
95974 + atomic_inc_unchecked(&rdma_stat_read);
95975
95976 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
95977 chl_map->ch[ch_no].count -= read_wr.num_sge;
95978 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
95979 dto_q);
95980 list_del_init(&ctxt->dto_q);
95981 } else {
95982 - atomic_inc(&rdma_stat_rq_starve);
95983 + atomic_inc_unchecked(&rdma_stat_rq_starve);
95984 clear_bit(XPT_DATA, &xprt->xpt_flags);
95985 ctxt = NULL;
95986 }
95987 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
95988 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
95989 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
95990 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
95991 - atomic_inc(&rdma_stat_recv);
95992 + atomic_inc_unchecked(&rdma_stat_recv);
95993
95994 /* Build up the XDR from the receive buffers. */
95995 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
95996 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
95997 index c1d124d..acfc59e 100644
95998 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
95999 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96000 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96001 write_wr.wr.rdma.remote_addr = to;
96002
96003 /* Post It */
96004 - atomic_inc(&rdma_stat_write);
96005 + atomic_inc_unchecked(&rdma_stat_write);
96006 if (svc_rdma_send(xprt, &write_wr))
96007 goto err;
96008 return 0;
96009 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96010 index 62e4f9b..dd3f2d7 100644
96011 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96012 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96013 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96014 return;
96015
96016 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96017 - atomic_inc(&rdma_stat_rq_poll);
96018 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96019
96020 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96021 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96022 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96023 }
96024
96025 if (ctxt)
96026 - atomic_inc(&rdma_stat_rq_prod);
96027 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96028
96029 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96030 /*
96031 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96032 return;
96033
96034 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96035 - atomic_inc(&rdma_stat_sq_poll);
96036 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96037 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96038 if (wc.status != IB_WC_SUCCESS)
96039 /* Close the transport */
96040 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96041 }
96042
96043 if (ctxt)
96044 - atomic_inc(&rdma_stat_sq_prod);
96045 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96046 }
96047
96048 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96049 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96050 spin_lock_bh(&xprt->sc_lock);
96051 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96052 spin_unlock_bh(&xprt->sc_lock);
96053 - atomic_inc(&rdma_stat_sq_starve);
96054 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96055
96056 /* See if we can opportunistically reap SQ WR to make room */
96057 sq_cq_reap(xprt);
96058 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96059 index e7000be..e3b0ba7 100644
96060 --- a/net/sysctl_net.c
96061 +++ b/net/sysctl_net.c
96062 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96063 kgid_t root_gid = make_kgid(net->user_ns, 0);
96064
96065 /* Allow network administrator to have same access as root. */
96066 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96067 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96068 uid_eq(root_uid, current_euid())) {
96069 int mode = (table->mode >> 6) & 7;
96070 return (mode << 6) | (mode << 3) | mode;
96071 diff --git a/net/tipc/link.c b/net/tipc/link.c
96072 index 0cc3d90..cc42021 100644
96073 --- a/net/tipc/link.c
96074 +++ b/net/tipc/link.c
96075 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96076 struct tipc_msg fragm_hdr;
96077 struct sk_buff *buf, *buf_chain, *prev;
96078 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96079 - const unchar *sect_crs;
96080 + const unchar __user *sect_crs;
96081 int curr_sect;
96082 u32 fragm_no;
96083 int res = 0;
96084 @@ -1207,7 +1207,7 @@ again:
96085
96086 if (!sect_rest) {
96087 sect_rest = msg_sect[++curr_sect].iov_len;
96088 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96089 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96090 }
96091
96092 if (sect_rest < fragm_rest)
96093 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96094 index ced60e2..54eab6c 100644
96095 --- a/net/tipc/msg.c
96096 +++ b/net/tipc/msg.c
96097 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96098 skb_copy_to_linear_data(*buf, hdr, hsz);
96099 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96100 skb_copy_to_linear_data_offset(*buf, pos,
96101 - msg_sect[cnt].iov_base,
96102 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96103 msg_sect[cnt].iov_len);
96104 pos += msg_sect[cnt].iov_len;
96105 }
96106 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96107 index d38bb45..4fd6ac6 100644
96108 --- a/net/tipc/subscr.c
96109 +++ b/net/tipc/subscr.c
96110 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96111 struct kvec msg_sect;
96112 int ret;
96113
96114 - msg_sect.iov_base = (void *)&sub->evt;
96115 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96116 msg_sect.iov_len = sizeof(struct tipc_event);
96117
96118 sub->evt.event = htohl(event, sub->swap);
96119 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96120 index c4ce243..2be7c59 100644
96121 --- a/net/unix/af_unix.c
96122 +++ b/net/unix/af_unix.c
96123 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96124 err = -ECONNREFUSED;
96125 if (!S_ISSOCK(inode->i_mode))
96126 goto put_fail;
96127 +
96128 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96129 + err = -EACCES;
96130 + goto put_fail;
96131 + }
96132 +
96133 u = unix_find_socket_byinode(inode);
96134 if (!u)
96135 goto put_fail;
96136 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96137 if (u) {
96138 struct dentry *dentry;
96139 dentry = unix_sk(u)->path.dentry;
96140 +
96141 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96142 + err = -EPERM;
96143 + sock_put(u);
96144 + goto fail;
96145 + }
96146 +
96147 if (dentry)
96148 touch_atime(&unix_sk(u)->path);
96149 } else
96150 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96151 */
96152 err = security_path_mknod(&path, dentry, mode, 0);
96153 if (!err) {
96154 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96155 + err = -EACCES;
96156 + goto out;
96157 + }
96158 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96159 if (!err) {
96160 res->mnt = mntget(path.mnt);
96161 res->dentry = dget(dentry);
96162 + gr_handle_create(dentry, path.mnt);
96163 }
96164 }
96165 +out:
96166 done_path_create(&path, dentry);
96167 return err;
96168 }
96169 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96170 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96171 "Inode Path\n");
96172 else {
96173 - struct sock *s = v;
96174 + struct sock *s = v, *peer;
96175 struct unix_sock *u = unix_sk(s);
96176 unix_state_lock(s);
96177 + peer = unix_peer(s);
96178 + unix_state_unlock(s);
96179 +
96180 + unix_state_double_lock(s, peer);
96181
96182 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
96183 s,
96184 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96185 }
96186 for ( ; i < len; i++)
96187 seq_putc(seq, u->addr->name->sun_path[i]);
96188 - }
96189 - unix_state_unlock(s);
96190 + } else if (peer)
96191 + seq_printf(seq, " P%lu", sock_i_ino(peer));
96192 +
96193 + unix_state_double_unlock(s, peer);
96194 seq_putc(seq, '\n');
96195 }
96196
96197 diff --git a/net/unix/diag.c b/net/unix/diag.c
96198 index d591091..86fa0f3 100644
96199 --- a/net/unix/diag.c
96200 +++ b/net/unix/diag.c
96201 @@ -124,6 +124,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
96202 rep->udiag_family = AF_UNIX;
96203 rep->udiag_type = sk->sk_type;
96204 rep->udiag_state = sk->sk_state;
96205 + rep->pad = 0;
96206 rep->udiag_ino = sk_ino;
96207 sock_diag_save_cookie(sk, rep->udiag_cookie);
96208
96209 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
96210 index b3d5150..ff3a837 100644
96211 --- a/net/unix/sysctl_net_unix.c
96212 +++ b/net/unix/sysctl_net_unix.c
96213 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
96214
96215 int __net_init unix_sysctl_register(struct net *net)
96216 {
96217 - struct ctl_table *table;
96218 + ctl_table_no_const *table;
96219
96220 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96221 if (table == NULL)
96222 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96223 index c8717c1..08539f5 100644
96224 --- a/net/wireless/wext-core.c
96225 +++ b/net/wireless/wext-core.c
96226 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96227 */
96228
96229 /* Support for very large requests */
96230 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96231 - (user_length > descr->max_tokens)) {
96232 + if (user_length > descr->max_tokens) {
96233 /* Allow userspace to GET more than max so
96234 * we can support any size GET requests.
96235 * There is still a limit : -ENOMEM.
96236 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96237 }
96238 }
96239
96240 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96241 - /*
96242 - * If this is a GET, but not NOMAX, it means that the extra
96243 - * data is not bounded by userspace, but by max_tokens. Thus
96244 - * set the length to max_tokens. This matches the extra data
96245 - * allocation.
96246 - * The driver should fill it with the number of tokens it
96247 - * provided, and it may check iwp->length rather than having
96248 - * knowledge of max_tokens. If the driver doesn't change the
96249 - * iwp->length, this ioctl just copies back max_token tokens
96250 - * filled with zeroes. Hopefully the driver isn't claiming
96251 - * them to be valid data.
96252 - */
96253 - iwp->length = descr->max_tokens;
96254 - }
96255 -
96256 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96257
96258 iwp->length += essid_compat;
96259 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96260 index f77c371..b0cb010 100644
96261 --- a/net/xfrm/xfrm_policy.c
96262 +++ b/net/xfrm/xfrm_policy.c
96263 @@ -332,9 +332,10 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96264 {
96265 policy->walk.dead = 1;
96266
96267 - atomic_inc(&policy->genid);
96268 + atomic_inc_unchecked(&policy->genid);
96269
96270 - del_timer(&policy->polq.hold_timer);
96271 + if (del_timer(&policy->polq.hold_timer))
96272 + xfrm_pol_put(policy);
96273 xfrm_queue_purge(&policy->polq.hold_queue);
96274
96275 if (del_timer(&policy->timer))
96276 @@ -589,7 +590,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96277
96278 spin_lock_bh(&pq->hold_queue.lock);
96279 skb_queue_splice_init(&pq->hold_queue, &list);
96280 - del_timer(&pq->hold_timer);
96281 + if (del_timer(&pq->hold_timer))
96282 + xfrm_pol_put(old);
96283 spin_unlock_bh(&pq->hold_queue.lock);
96284
96285 if (skb_queue_empty(&list))
96286 @@ -600,7 +602,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96287 spin_lock_bh(&pq->hold_queue.lock);
96288 skb_queue_splice(&list, &pq->hold_queue);
96289 pq->timeout = XFRM_QUEUE_TMO_MIN;
96290 - mod_timer(&pq->hold_timer, jiffies);
96291 + if (!mod_timer(&pq->hold_timer, jiffies))
96292 + xfrm_pol_hold(new);
96293 spin_unlock_bh(&pq->hold_queue.lock);
96294 }
96295
96296 @@ -657,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96297 hlist_add_head(&policy->bydst, chain);
96298 xfrm_pol_hold(policy);
96299 net->xfrm.policy_count[dir]++;
96300 - atomic_inc(&flow_cache_genid);
96301 + atomic_inc_unchecked(&flow_cache_genid);
96302 rt_genid_bump(net);
96303 if (delpol) {
96304 xfrm_policy_requeue(delpol, policy);
96305 @@ -1627,7 +1630,7 @@ free_dst:
96306 goto out;
96307 }
96308
96309 -static int inline
96310 +static inline int
96311 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96312 {
96313 if (!*target) {
96314 @@ -1639,7 +1642,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96315 return 0;
96316 }
96317
96318 -static int inline
96319 +static inline int
96320 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96321 {
96322 #ifdef CONFIG_XFRM_SUB_POLICY
96323 @@ -1651,7 +1654,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96324 #endif
96325 }
96326
96327 -static int inline
96328 +static inline int
96329 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96330 {
96331 #ifdef CONFIG_XFRM_SUB_POLICY
96332 @@ -1745,7 +1748,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96333
96334 xdst->num_pols = num_pols;
96335 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96336 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96337 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96338
96339 return xdst;
96340 }
96341 @@ -1763,6 +1766,10 @@ static void xfrm_policy_queue_process(unsigned long arg)
96342
96343 spin_lock(&pq->hold_queue.lock);
96344 skb = skb_peek(&pq->hold_queue);
96345 + if (!skb) {
96346 + spin_unlock(&pq->hold_queue.lock);
96347 + goto out;
96348 + }
96349 dst = skb_dst(skb);
96350 sk = skb->sk;
96351 xfrm_decode_session(skb, &fl, dst->ops->family);
96352 @@ -1781,8 +1788,9 @@ static void xfrm_policy_queue_process(unsigned long arg)
96353 goto purge_queue;
96354
96355 pq->timeout = pq->timeout << 1;
96356 - mod_timer(&pq->hold_timer, jiffies + pq->timeout);
96357 - return;
96358 + if (!mod_timer(&pq->hold_timer, jiffies + pq->timeout))
96359 + xfrm_pol_hold(pol);
96360 + goto out;
96361 }
96362
96363 dst_release(dst);
96364 @@ -1813,11 +1821,14 @@ static void xfrm_policy_queue_process(unsigned long arg)
96365 err = dst_output(skb);
96366 }
96367
96368 +out:
96369 + xfrm_pol_put(pol);
96370 return;
96371
96372 purge_queue:
96373 pq->timeout = 0;
96374 xfrm_queue_purge(&pq->hold_queue);
96375 + xfrm_pol_put(pol);
96376 }
96377
96378 static int xdst_queue_output(struct sk_buff *skb)
96379 @@ -1825,7 +1836,8 @@ static int xdst_queue_output(struct sk_buff *skb)
96380 unsigned long sched_next;
96381 struct dst_entry *dst = skb_dst(skb);
96382 struct xfrm_dst *xdst = (struct xfrm_dst *) dst;
96383 - struct xfrm_policy_queue *pq = &xdst->pols[0]->polq;
96384 + struct xfrm_policy *pol = xdst->pols[0];
96385 + struct xfrm_policy_queue *pq = &pol->polq;
96386
96387 if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) {
96388 kfree_skb(skb);
96389 @@ -1844,10 +1856,12 @@ static int xdst_queue_output(struct sk_buff *skb)
96390 if (del_timer(&pq->hold_timer)) {
96391 if (time_before(pq->hold_timer.expires, sched_next))
96392 sched_next = pq->hold_timer.expires;
96393 + xfrm_pol_put(pol);
96394 }
96395
96396 __skb_queue_tail(&pq->hold_queue, skb);
96397 - mod_timer(&pq->hold_timer, sched_next);
96398 + if (!mod_timer(&pq->hold_timer, sched_next))
96399 + xfrm_pol_hold(pol);
96400
96401 spin_unlock_bh(&pq->hold_queue.lock);
96402
96403 @@ -2557,11 +2571,12 @@ void xfrm_garbage_collect(struct net *net)
96404 }
96405 EXPORT_SYMBOL(xfrm_garbage_collect);
96406
96407 -static void xfrm_garbage_collect_deferred(struct net *net)
96408 +void xfrm_garbage_collect_deferred(struct net *net)
96409 {
96410 flow_cache_flush_deferred();
96411 __xfrm_garbage_collect(net);
96412 }
96413 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
96414
96415 static void xfrm_init_pmtu(struct dst_entry *dst)
96416 {
96417 @@ -2611,7 +2626,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
96418 if (xdst->xfrm_genid != dst->xfrm->genid)
96419 return 0;
96420 if (xdst->num_pols > 0 &&
96421 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
96422 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
96423 return 0;
96424
96425 mtu = dst_mtu(dst->child);
96426 @@ -2699,8 +2714,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
96427 dst_ops->link_failure = xfrm_link_failure;
96428 if (likely(dst_ops->neigh_lookup == NULL))
96429 dst_ops->neigh_lookup = xfrm_neigh_lookup;
96430 - if (likely(afinfo->garbage_collect == NULL))
96431 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
96432 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
96433 }
96434 spin_unlock(&xfrm_policy_afinfo_lock);
96435 @@ -2754,7 +2767,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
96436 dst_ops->check = NULL;
96437 dst_ops->negative_advice = NULL;
96438 dst_ops->link_failure = NULL;
96439 - afinfo->garbage_collect = NULL;
96440 }
96441 return err;
96442 }
96443 @@ -3137,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
96444 sizeof(pol->xfrm_vec[i].saddr));
96445 pol->xfrm_vec[i].encap_family = mp->new_family;
96446 /* flush bundles */
96447 - atomic_inc(&pol->genid);
96448 + atomic_inc_unchecked(&pol->genid);
96449 }
96450 }
96451
96452 diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
96453 index 8dafe6d3..dab57da 100644
96454 --- a/net/xfrm/xfrm_replay.c
96455 +++ b/net/xfrm/xfrm_replay.c
96456 @@ -61,9 +61,9 @@ static void xfrm_replay_notify(struct xfrm_state *x, int event)
96457
96458 switch (event) {
96459 case XFRM_REPLAY_UPDATE:
96460 - if (x->replay_maxdiff &&
96461 - (x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96462 - (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff)) {
96463 + if (!x->replay_maxdiff ||
96464 + ((x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96465 + (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))) {
96466 if (x->xflags & XFRM_TIME_DEFER)
96467 event = XFRM_REPLAY_TIMEOUT;
96468 else
96469 @@ -129,8 +129,7 @@ static int xfrm_replay_check(struct xfrm_state *x,
96470 return 0;
96471
96472 diff = x->replay.seq - seq;
96473 - if (diff >= min_t(unsigned int, x->props.replay_window,
96474 - sizeof(x->replay.bitmap) * 8)) {
96475 + if (diff >= x->props.replay_window) {
96476 x->stats.replay_window++;
96477 goto err;
96478 }
96479 @@ -302,9 +301,10 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)
96480
96481 switch (event) {
96482 case XFRM_REPLAY_UPDATE:
96483 - if (x->replay_maxdiff &&
96484 - (replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96485 - (replay_esn->oseq - preplay_esn->oseq < x->replay_maxdiff)) {
96486 + if (!x->replay_maxdiff ||
96487 + ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96488 + (replay_esn->oseq - preplay_esn->oseq
96489 + < x->replay_maxdiff))) {
96490 if (x->xflags & XFRM_TIME_DEFER)
96491 event = XFRM_REPLAY_TIMEOUT;
96492 else
96493 @@ -353,28 +353,30 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event)
96494
96495 switch (event) {
96496 case XFRM_REPLAY_UPDATE:
96497 - if (!x->replay_maxdiff)
96498 - break;
96499 -
96500 - if (replay_esn->seq_hi == preplay_esn->seq_hi)
96501 - seq_diff = replay_esn->seq - preplay_esn->seq;
96502 - else
96503 - seq_diff = ~preplay_esn->seq + replay_esn->seq + 1;
96504 -
96505 - if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
96506 - oseq_diff = replay_esn->oseq - preplay_esn->oseq;
96507 - else
96508 - oseq_diff = ~preplay_esn->oseq + replay_esn->oseq + 1;
96509 -
96510 - if (seq_diff < x->replay_maxdiff &&
96511 - oseq_diff < x->replay_maxdiff) {
96512 + if (x->replay_maxdiff) {
96513 + if (replay_esn->seq_hi == preplay_esn->seq_hi)
96514 + seq_diff = replay_esn->seq - preplay_esn->seq;
96515 + else
96516 + seq_diff = ~preplay_esn->seq + replay_esn->seq
96517 + + 1;
96518
96519 - if (x->xflags & XFRM_TIME_DEFER)
96520 - event = XFRM_REPLAY_TIMEOUT;
96521 + if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
96522 + oseq_diff = replay_esn->oseq
96523 + - preplay_esn->oseq;
96524 else
96525 - return;
96526 + oseq_diff = ~preplay_esn->oseq
96527 + + replay_esn->oseq + 1;
96528 +
96529 + if (seq_diff >= x->replay_maxdiff ||
96530 + oseq_diff >= x->replay_maxdiff)
96531 + break;
96532 }
96533
96534 + if (x->xflags & XFRM_TIME_DEFER)
96535 + event = XFRM_REPLAY_TIMEOUT;
96536 + else
96537 + return;
96538 +
96539 break;
96540
96541 case XFRM_REPLAY_TIMEOUT:
96542 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
96543 index 54c0acd..56814bd 100644
96544 --- a/net/xfrm/xfrm_state.c
96545 +++ b/net/xfrm/xfrm_state.c
96546 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
96547
96548 if (unlikely(afinfo == NULL))
96549 return -EAFNOSUPPORT;
96550 - typemap = afinfo->type_map;
96551 + typemap = (const struct xfrm_type **)afinfo->type_map;
96552 spin_lock_bh(&xfrm_type_lock);
96553
96554 - if (likely(typemap[type->proto] == NULL))
96555 + if (likely(typemap[type->proto] == NULL)) {
96556 + pax_open_kernel();
96557 typemap[type->proto] = type;
96558 - else
96559 + pax_close_kernel();
96560 + } else
96561 err = -EEXIST;
96562 spin_unlock_bh(&xfrm_type_lock);
96563 xfrm_state_put_afinfo(afinfo);
96564 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
96565
96566 if (unlikely(afinfo == NULL))
96567 return -EAFNOSUPPORT;
96568 - typemap = afinfo->type_map;
96569 + typemap = (const struct xfrm_type **)afinfo->type_map;
96570 spin_lock_bh(&xfrm_type_lock);
96571
96572 if (unlikely(typemap[type->proto] != type))
96573 err = -ENOENT;
96574 - else
96575 + else {
96576 + pax_open_kernel();
96577 typemap[type->proto] = NULL;
96578 + pax_close_kernel();
96579 + }
96580 spin_unlock_bh(&xfrm_type_lock);
96581 xfrm_state_put_afinfo(afinfo);
96582 return err;
96583 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
96584 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
96585 {
96586 struct xfrm_state_afinfo *afinfo;
96587 - const struct xfrm_type **typemap;
96588 const struct xfrm_type *type;
96589 int modload_attempted = 0;
96590
96591 @@ -219,9 +223,8 @@ retry:
96592 afinfo = xfrm_state_get_afinfo(family);
96593 if (unlikely(afinfo == NULL))
96594 return NULL;
96595 - typemap = afinfo->type_map;
96596
96597 - type = typemap[proto];
96598 + type = afinfo->type_map[proto];
96599 if (unlikely(type && !try_module_get(type->owner)))
96600 type = NULL;
96601 if (!type && !modload_attempted) {
96602 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96603 return -EAFNOSUPPORT;
96604
96605 err = -EEXIST;
96606 - modemap = afinfo->mode_map;
96607 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96608 spin_lock_bh(&xfrm_mode_lock);
96609 if (modemap[mode->encap])
96610 goto out;
96611 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96612 if (!try_module_get(afinfo->owner))
96613 goto out;
96614
96615 - mode->afinfo = afinfo;
96616 + pax_open_kernel();
96617 + *(const void **)&mode->afinfo = afinfo;
96618 modemap[mode->encap] = mode;
96619 + pax_close_kernel();
96620 err = 0;
96621
96622 out:
96623 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
96624 return -EAFNOSUPPORT;
96625
96626 err = -ENOENT;
96627 - modemap = afinfo->mode_map;
96628 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96629 spin_lock_bh(&xfrm_mode_lock);
96630 if (likely(modemap[mode->encap] == mode)) {
96631 + pax_open_kernel();
96632 modemap[mode->encap] = NULL;
96633 + pax_close_kernel();
96634 module_put(mode->afinfo->owner);
96635 err = 0;
96636 }
96637 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
96638 u32 xfrm_get_acqseq(void)
96639 {
96640 u32 res;
96641 - static atomic_t acqseq;
96642 + static atomic_unchecked_t acqseq;
96643
96644 do {
96645 - res = atomic_inc_return(&acqseq);
96646 + res = atomic_inc_return_unchecked(&acqseq);
96647 } while (!res);
96648
96649 return res;
96650 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
96651 index 05a6e3d..6716ec9 100644
96652 --- a/net/xfrm/xfrm_sysctl.c
96653 +++ b/net/xfrm/xfrm_sysctl.c
96654 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
96655
96656 int __net_init xfrm_sysctl_init(struct net *net)
96657 {
96658 - struct ctl_table *table;
96659 + ctl_table_no_const *table;
96660
96661 __xfrm_sysctl_init(net);
96662
96663 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
96664 index 3f565e4..f964d4c 100644
96665 --- a/net/xfrm/xfrm_user.c
96666 +++ b/net/xfrm/xfrm_user.c
96667 @@ -446,7 +446,8 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
96668 memcpy(&x->sel, &p->sel, sizeof(x->sel));
96669 memcpy(&x->lft, &p->lft, sizeof(x->lft));
96670 x->props.mode = p->mode;
96671 - x->props.replay_window = p->replay_window;
96672 + x->props.replay_window = min_t(unsigned int, p->replay_window,
96673 + sizeof(x->replay.bitmap) * 8);
96674 x->props.reqid = p->reqid;
96675 x->props.family = p->family;
96676 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
96677 @@ -1856,7 +1857,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
96678 if (x->km.state != XFRM_STATE_VALID)
96679 goto out;
96680
96681 - err = xfrm_replay_verify_len(x->replay_esn, rp);
96682 + err = xfrm_replay_verify_len(x->replay_esn, re);
96683 if (err)
96684 goto out;
96685
96686 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
96687 index d5d859c..781cbcb 100644
96688 --- a/scripts/Makefile.build
96689 +++ b/scripts/Makefile.build
96690 @@ -111,7 +111,7 @@ endif
96691 endif
96692
96693 # Do not include host rules unless needed
96694 -ifneq ($(hostprogs-y)$(hostprogs-m),)
96695 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
96696 include scripts/Makefile.host
96697 endif
96698
96699 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
96700 index 686cb0d..9d653bf 100644
96701 --- a/scripts/Makefile.clean
96702 +++ b/scripts/Makefile.clean
96703 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
96704 __clean-files := $(extra-y) $(always) \
96705 $(targets) $(clean-files) \
96706 $(host-progs) \
96707 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
96708 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
96709 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
96710
96711 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
96712
96713 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
96714 index 1ac414f..38575f7 100644
96715 --- a/scripts/Makefile.host
96716 +++ b/scripts/Makefile.host
96717 @@ -31,6 +31,8 @@
96718 # Note: Shared libraries consisting of C++ files are not supported
96719
96720 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
96721 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
96722 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
96723
96724 # C code
96725 # Executables compiled from a single .c file
96726 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
96727 # Shared libaries (only .c supported)
96728 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
96729 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
96730 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
96731 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
96732 # Remove .so files from "xxx-objs"
96733 host-cobjs := $(filter-out %.so,$(host-cobjs))
96734 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
96735
96736 -#Object (.o) files used by the shared libaries
96737 +# Object (.o) files used by the shared libaries
96738 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
96739 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
96740
96741 # output directory for programs/.o files
96742 # hostprogs-y := tools/build may have been specified. Retrieve directory
96743 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
96744 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
96745 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
96746 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
96747 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
96748 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
96749 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
96750 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
96751
96752 obj-dirs += $(host-objdirs)
96753 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
96754 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
96755 $(call if_changed_dep,host-cshobjs)
96756
96757 +# Compile .c file, create position independent .o file
96758 +# host-cxxshobjs -> .o
96759 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
96760 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
96761 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
96762 + $(call if_changed_dep,host-cxxshobjs)
96763 +
96764 # Link a shared library, based on position independent .o files
96765 # *.o -> .so shared library (host-cshlib)
96766 quiet_cmd_host-cshlib = HOSTLLD -shared $@
96767 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
96768 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
96769 $(call if_changed,host-cshlib)
96770
96771 +# Link a shared library, based on position independent .o files
96772 +# *.o -> .so shared library (host-cxxshlib)
96773 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
96774 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
96775 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
96776 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
96777 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
96778 + $(call if_changed,host-cxxshlib)
96779 +
96780 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
96781 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
96782 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
96783
96784 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
96785 index 078fe1d..fbdb363 100644
96786 --- a/scripts/basic/fixdep.c
96787 +++ b/scripts/basic/fixdep.c
96788 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
96789 /*
96790 * Lookup a value in the configuration string.
96791 */
96792 -static int is_defined_config(const char *name, int len, unsigned int hash)
96793 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
96794 {
96795 struct item *aux;
96796
96797 @@ -211,10 +211,10 @@ static void clear_config(void)
96798 /*
96799 * Record the use of a CONFIG_* word.
96800 */
96801 -static void use_config(const char *m, int slen)
96802 +static void use_config(const char *m, unsigned int slen)
96803 {
96804 unsigned int hash = strhash(m, slen);
96805 - int c, i;
96806 + unsigned int c, i;
96807
96808 if (is_defined_config(m, slen, hash))
96809 return;
96810 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
96811
96812 static void parse_config_file(const char *map, size_t len)
96813 {
96814 - const int *end = (const int *) (map + len);
96815 + const unsigned int *end = (const unsigned int *) (map + len);
96816 /* start at +1, so that p can never be < map */
96817 - const int *m = (const int *) map + 1;
96818 + const unsigned int *m = (const unsigned int *) map + 1;
96819 const char *p, *q;
96820
96821 for (; m < end; m++) {
96822 @@ -435,7 +435,7 @@ static void print_deps(void)
96823 static void traps(void)
96824 {
96825 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
96826 - int *p = (int *)test;
96827 + unsigned int *p = (unsigned int *)test;
96828
96829 if (*p != INT_CONF) {
96830 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
96831 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
96832 new file mode 100644
96833 index 0000000..5e0222d
96834 --- /dev/null
96835 +++ b/scripts/gcc-plugin.sh
96836 @@ -0,0 +1,17 @@
96837 +#!/bin/bash
96838 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
96839 +#include "gcc-plugin.h"
96840 +#include "tree.h"
96841 +#include "tm.h"
96842 +#include "rtl.h"
96843 +#ifdef ENABLE_BUILD_WITH_CXX
96844 +#warning $2
96845 +#else
96846 +#warning $1
96847 +#endif
96848 +EOF`
96849 +if [ $? -eq 0 ]
96850 +then
96851 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
96852 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
96853 +fi
96854 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
96855 index 5de5660..d3deb89 100644
96856 --- a/scripts/headers_install.sh
96857 +++ b/scripts/headers_install.sh
96858 @@ -32,6 +32,7 @@ do
96859 FILE="$(basename "$i")"
96860 sed -r \
96861 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
96862 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
96863 -e 's/__attribute_const__([ \t]|$)/\1/g' \
96864 -e 's@^#include <linux/compiler.h>@@' \
96865 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
96866 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
96867 index 0149949..d482a0d 100644
96868 --- a/scripts/link-vmlinux.sh
96869 +++ b/scripts/link-vmlinux.sh
96870 @@ -158,7 +158,7 @@ else
96871 fi;
96872
96873 # final build of init/
96874 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
96875 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
96876
96877 kallsymso=""
96878 kallsyms_vmlinux=""
96879 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
96880 index 2370863..212fbca 100644
96881 --- a/scripts/mod/file2alias.c
96882 +++ b/scripts/mod/file2alias.c
96883 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
96884 unsigned long size, unsigned long id_size,
96885 void *symval)
96886 {
96887 - int i;
96888 + unsigned int i;
96889
96890 if (size % id_size || size < id_size) {
96891 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
96892 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
96893 /* USB is special because the bcdDevice can be matched against a numeric range */
96894 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
96895 static void do_usb_entry(void *symval,
96896 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
96897 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
96898 unsigned char range_lo, unsigned char range_hi,
96899 unsigned char max, struct module *mod)
96900 {
96901 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
96902 {
96903 unsigned int devlo, devhi;
96904 unsigned char chi, clo, max;
96905 - int ndigits;
96906 + unsigned int ndigits;
96907
96908 DEF_FIELD(symval, usb_device_id, match_flags);
96909 DEF_FIELD(symval, usb_device_id, idVendor);
96910 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
96911 for (i = 0; i < count; i++) {
96912 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
96913 char acpi_id[sizeof(*id)];
96914 - int j;
96915 + unsigned int j;
96916
96917 buf_printf(&mod->dev_table_buf,
96918 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
96919 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
96920
96921 for (j = 0; j < PNP_MAX_DEVICES; j++) {
96922 const char *id = (char *)(*devs)[j].id;
96923 - int i2, j2;
96924 + unsigned int i2, j2;
96925 int dup = 0;
96926
96927 if (!id[0])
96928 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
96929 /* add an individual alias for every device entry */
96930 if (!dup) {
96931 char acpi_id[PNP_ID_LEN];
96932 - int k;
96933 + unsigned int k;
96934
96935 buf_printf(&mod->dev_table_buf,
96936 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
96937 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
96938 static int do_dmi_entry(const char *filename, void *symval,
96939 char *alias)
96940 {
96941 - int i, j;
96942 + unsigned int i, j;
96943 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
96944 sprintf(alias, "dmi*");
96945
96946 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
96947 index 6216434..050cf89 100644
96948 --- a/scripts/mod/modpost.c
96949 +++ b/scripts/mod/modpost.c
96950 @@ -930,6 +930,7 @@ enum mismatch {
96951 ANY_INIT_TO_ANY_EXIT,
96952 ANY_EXIT_TO_ANY_INIT,
96953 EXPORT_TO_INIT_EXIT,
96954 + DATA_TO_TEXT
96955 };
96956
96957 struct sectioncheck {
96958 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
96959 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
96960 .mismatch = EXPORT_TO_INIT_EXIT,
96961 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
96962 +},
96963 +/* Do not reference code from writable data */
96964 +{
96965 + .fromsec = { DATA_SECTIONS, NULL },
96966 + .tosec = { TEXT_SECTIONS, NULL },
96967 + .mismatch = DATA_TO_TEXT
96968 }
96969 };
96970
96971 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
96972 continue;
96973 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
96974 continue;
96975 - if (sym->st_value == addr)
96976 - return sym;
96977 /* Find a symbol nearby - addr are maybe negative */
96978 d = sym->st_value - addr;
96979 + if (d == 0)
96980 + return sym;
96981 if (d < 0)
96982 d = addr - sym->st_value;
96983 if (d < distance) {
96984 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
96985 tosym, prl_to, prl_to, tosym);
96986 free(prl_to);
96987 break;
96988 + case DATA_TO_TEXT:
96989 +#if 0
96990 + fprintf(stderr,
96991 + "The %s %s:%s references\n"
96992 + "the %s %s:%s%s\n",
96993 + from, fromsec, fromsym, to, tosec, tosym, to_p);
96994 +#endif
96995 + break;
96996 }
96997 fprintf(stderr, "\n");
96998 }
96999 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
97000 static void check_sec_ref(struct module *mod, const char *modname,
97001 struct elf_info *elf)
97002 {
97003 - int i;
97004 + unsigned int i;
97005 Elf_Shdr *sechdrs = elf->sechdrs;
97006
97007 /* Walk through all sections */
97008 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
97009 va_end(ap);
97010 }
97011
97012 -void buf_write(struct buffer *buf, const char *s, int len)
97013 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
97014 {
97015 if (buf->size - buf->pos < len) {
97016 buf->size += len + SZ;
97017 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
97018 if (fstat(fileno(file), &st) < 0)
97019 goto close_write;
97020
97021 - if (st.st_size != b->pos)
97022 + if (st.st_size != (off_t)b->pos)
97023 goto close_write;
97024
97025 tmp = NOFAIL(malloc(b->pos));
97026 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
97027 index 51207e4..f7d603d 100644
97028 --- a/scripts/mod/modpost.h
97029 +++ b/scripts/mod/modpost.h
97030 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
97031
97032 struct buffer {
97033 char *p;
97034 - int pos;
97035 - int size;
97036 + unsigned int pos;
97037 + unsigned int size;
97038 };
97039
97040 void __attribute__((format(printf, 2, 3)))
97041 buf_printf(struct buffer *buf, const char *fmt, ...);
97042
97043 void
97044 -buf_write(struct buffer *buf, const char *s, int len);
97045 +buf_write(struct buffer *buf, const char *s, unsigned int len);
97046
97047 struct module {
97048 struct module *next;
97049 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
97050 index 9dfcd6d..099068e 100644
97051 --- a/scripts/mod/sumversion.c
97052 +++ b/scripts/mod/sumversion.c
97053 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
97054 goto out;
97055 }
97056
97057 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
97058 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
97059 warn("writing sum in %s failed: %s\n",
97060 filename, strerror(errno));
97061 goto out;
97062 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
97063 index 0865b3e..7235dd4 100644
97064 --- a/scripts/module-common.lds
97065 +++ b/scripts/module-common.lds
97066 @@ -6,6 +6,10 @@
97067 SECTIONS {
97068 /DISCARD/ : { *(.discard) }
97069
97070 + .rodata : {
97071 + *(.rodata) *(.rodata.*)
97072 + *(.data..read_only)
97073 + }
97074 __ksymtab : { *(SORT(___ksymtab+*)) }
97075 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
97076 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
97077 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97078 index acb8650..b8c5f02 100644
97079 --- a/scripts/package/builddeb
97080 +++ b/scripts/package/builddeb
97081 @@ -246,6 +246,7 @@ fi
97082 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97083 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97084 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97085 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97086 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97087 mkdir -p "$destdir"
97088 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97089 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97090 index 68bb4ef..2f419e1 100644
97091 --- a/scripts/pnmtologo.c
97092 +++ b/scripts/pnmtologo.c
97093 @@ -244,14 +244,14 @@ static void write_header(void)
97094 fprintf(out, " * Linux logo %s\n", logoname);
97095 fputs(" */\n\n", out);
97096 fputs("#include <linux/linux_logo.h>\n\n", out);
97097 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97098 + fprintf(out, "static unsigned char %s_data[] = {\n",
97099 logoname);
97100 }
97101
97102 static void write_footer(void)
97103 {
97104 fputs("\n};\n\n", out);
97105 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97106 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97107 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97108 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97109 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97110 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97111 fputs("\n};\n\n", out);
97112
97113 /* write logo clut */
97114 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97115 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97116 logoname);
97117 write_hex_cnt = 0;
97118 for (i = 0; i < logo_clutsize; i++) {
97119 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97120 index f5eb43d..1814de8 100644
97121 --- a/scripts/sortextable.h
97122 +++ b/scripts/sortextable.h
97123 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97124 const char *secstrtab;
97125 const char *strtab;
97126 char *extab_image;
97127 - int extab_index = 0;
97128 - int i;
97129 - int idx;
97130 + unsigned int extab_index = 0;
97131 + unsigned int i;
97132 + unsigned int idx;
97133
97134 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97135 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97136 diff --git a/security/Kconfig b/security/Kconfig
97137 index e9c6ac7..c5d45c8 100644
97138 --- a/security/Kconfig
97139 +++ b/security/Kconfig
97140 @@ -4,6 +4,959 @@
97141
97142 menu "Security options"
97143
97144 +menu "Grsecurity"
97145 +
97146 + config ARCH_TRACK_EXEC_LIMIT
97147 + bool
97148 +
97149 + config PAX_KERNEXEC_PLUGIN
97150 + bool
97151 +
97152 + config PAX_PER_CPU_PGD
97153 + bool
97154 +
97155 + config TASK_SIZE_MAX_SHIFT
97156 + int
97157 + depends on X86_64
97158 + default 47 if !PAX_PER_CPU_PGD
97159 + default 42 if PAX_PER_CPU_PGD
97160 +
97161 + config PAX_ENABLE_PAE
97162 + bool
97163 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97164 +
97165 + config PAX_USERCOPY_SLABS
97166 + bool
97167 +
97168 +config GRKERNSEC
97169 + bool "Grsecurity"
97170 + select CRYPTO
97171 + select CRYPTO_SHA256
97172 + select PROC_FS
97173 + select STOP_MACHINE
97174 + select TTY
97175 + help
97176 + If you say Y here, you will be able to configure many features
97177 + that will enhance the security of your system. It is highly
97178 + recommended that you say Y here and read through the help
97179 + for each option so that you fully understand the features and
97180 + can evaluate their usefulness for your machine.
97181 +
97182 +choice
97183 + prompt "Configuration Method"
97184 + depends on GRKERNSEC
97185 + default GRKERNSEC_CONFIG_CUSTOM
97186 + help
97187 +
97188 +config GRKERNSEC_CONFIG_AUTO
97189 + bool "Automatic"
97190 + help
97191 + If you choose this configuration method, you'll be able to answer a small
97192 + number of simple questions about how you plan to use this kernel.
97193 + The settings of grsecurity and PaX will be automatically configured for
97194 + the highest commonly-used settings within the provided constraints.
97195 +
97196 + If you require additional configuration, custom changes can still be made
97197 + from the "custom configuration" menu.
97198 +
97199 +config GRKERNSEC_CONFIG_CUSTOM
97200 + bool "Custom"
97201 + help
97202 + If you choose this configuration method, you'll be able to configure all
97203 + grsecurity and PaX settings manually. Via this method, no options are
97204 + automatically enabled.
97205 +
97206 +endchoice
97207 +
97208 +choice
97209 + prompt "Usage Type"
97210 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97211 + default GRKERNSEC_CONFIG_SERVER
97212 + help
97213 +
97214 +config GRKERNSEC_CONFIG_SERVER
97215 + bool "Server"
97216 + help
97217 + Choose this option if you plan to use this kernel on a server.
97218 +
97219 +config GRKERNSEC_CONFIG_DESKTOP
97220 + bool "Desktop"
97221 + help
97222 + Choose this option if you plan to use this kernel on a desktop.
97223 +
97224 +endchoice
97225 +
97226 +choice
97227 + prompt "Virtualization Type"
97228 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
97229 + default GRKERNSEC_CONFIG_VIRT_NONE
97230 + help
97231 +
97232 +config GRKERNSEC_CONFIG_VIRT_NONE
97233 + bool "None"
97234 + help
97235 + Choose this option if this kernel will be run on bare metal.
97236 +
97237 +config GRKERNSEC_CONFIG_VIRT_GUEST
97238 + bool "Guest"
97239 + help
97240 + Choose this option if this kernel will be run as a VM guest.
97241 +
97242 +config GRKERNSEC_CONFIG_VIRT_HOST
97243 + bool "Host"
97244 + help
97245 + Choose this option if this kernel will be run as a VM host.
97246 +
97247 +endchoice
97248 +
97249 +choice
97250 + prompt "Virtualization Hardware"
97251 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97252 + help
97253 +
97254 +config GRKERNSEC_CONFIG_VIRT_EPT
97255 + bool "EPT/RVI Processor Support"
97256 + depends on X86
97257 + help
97258 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
97259 + hardware virtualization. This allows for additional kernel hardening protections
97260 + to operate without additional performance impact.
97261 +
97262 + To see if your Intel processor supports EPT, see:
97263 + http://ark.intel.com/Products/VirtualizationTechnology
97264 + (Most Core i3/5/7 support EPT)
97265 +
97266 + To see if your AMD processor supports RVI, see:
97267 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
97268 +
97269 +config GRKERNSEC_CONFIG_VIRT_SOFT
97270 + bool "First-gen/No Hardware Virtualization"
97271 + help
97272 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
97273 + support hardware virtualization or doesn't support the EPT/RVI extensions.
97274 +
97275 +endchoice
97276 +
97277 +choice
97278 + prompt "Virtualization Software"
97279 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97280 + help
97281 +
97282 +config GRKERNSEC_CONFIG_VIRT_XEN
97283 + bool "Xen"
97284 + help
97285 + Choose this option if this kernel is running as a Xen guest or host.
97286 +
97287 +config GRKERNSEC_CONFIG_VIRT_VMWARE
97288 + bool "VMWare"
97289 + help
97290 + Choose this option if this kernel is running as a VMWare guest or host.
97291 +
97292 +config GRKERNSEC_CONFIG_VIRT_KVM
97293 + bool "KVM"
97294 + help
97295 + Choose this option if this kernel is running as a KVM guest or host.
97296 +
97297 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
97298 + bool "VirtualBox"
97299 + help
97300 + Choose this option if this kernel is running as a VirtualBox guest or host.
97301 +
97302 +endchoice
97303 +
97304 +choice
97305 + prompt "Required Priorities"
97306 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97307 + default GRKERNSEC_CONFIG_PRIORITY_PERF
97308 + help
97309 +
97310 +config GRKERNSEC_CONFIG_PRIORITY_PERF
97311 + bool "Performance"
97312 + help
97313 + Choose this option if performance is of highest priority for this deployment
97314 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
97315 + clearing of structures intended for userland, and freed memory sanitizing will
97316 + be disabled.
97317 +
97318 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
97319 + bool "Security"
97320 + help
97321 + Choose this option if security is of highest priority for this deployment of
97322 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
97323 + for userland, and freed memory sanitizing will be enabled for this kernel.
97324 + In a worst-case scenario, these features can introduce a 20% performance hit
97325 + (UDEREF on x64 contributing half of this hit).
97326 +
97327 +endchoice
97328 +
97329 +menu "Default Special Groups"
97330 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97331 +
97332 +config GRKERNSEC_PROC_GID
97333 + int "GID exempted from /proc restrictions"
97334 + default 1001
97335 + help
97336 + Setting this GID determines which group will be exempted from
97337 + grsecurity's /proc restrictions, allowing users of the specified
97338 + group to view network statistics and the existence of other users'
97339 + processes on the system. This GID may also be chosen at boot time
97340 + via "grsec_proc_gid=" on the kernel commandline.
97341 +
97342 +config GRKERNSEC_TPE_UNTRUSTED_GID
97343 + int "GID for TPE-untrusted users"
97344 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
97345 + default 1005
97346 + help
97347 + Setting this GID determines which group untrusted users should
97348 + be added to. These users will be placed under grsecurity's Trusted Path
97349 + Execution mechanism, preventing them from executing their own binaries.
97350 + The users will only be able to execute binaries in directories owned and
97351 + writable only by the root user. If the sysctl option is enabled, a sysctl
97352 + option with name "tpe_gid" is created.
97353 +
97354 +config GRKERNSEC_TPE_TRUSTED_GID
97355 + int "GID for TPE-trusted users"
97356 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
97357 + default 1005
97358 + help
97359 + Setting this GID determines what group TPE restrictions will be
97360 + *disabled* for. If the sysctl option is enabled, a sysctl option
97361 + with name "tpe_gid" is created.
97362 +
97363 +config GRKERNSEC_SYMLINKOWN_GID
97364 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
97365 + depends on GRKERNSEC_CONFIG_SERVER
97366 + default 1006
97367 + help
97368 + Setting this GID determines what group kernel-enforced
97369 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
97370 + is enabled, a sysctl option with name "symlinkown_gid" is created.
97371 +
97372 +
97373 +endmenu
97374 +
97375 +menu "Customize Configuration"
97376 +depends on GRKERNSEC
97377 +
97378 +menu "PaX"
97379 +
97380 +config PAX
97381 + bool "Enable various PaX features"
97382 + default y if GRKERNSEC_CONFIG_AUTO
97383 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
97384 + help
97385 + This allows you to enable various PaX features. PaX adds
97386 + intrusion prevention mechanisms to the kernel that reduce
97387 + the risks posed by exploitable memory corruption bugs.
97388 +
97389 +menu "PaX Control"
97390 + depends on PAX
97391 +
97392 +config PAX_SOFTMODE
97393 + bool 'Support soft mode'
97394 + help
97395 + Enabling this option will allow you to run PaX in soft mode, that
97396 + is, PaX features will not be enforced by default, only on executables
97397 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
97398 + support as they are the only way to mark executables for soft mode use.
97399 +
97400 + Soft mode can be activated by using the "pax_softmode=1" kernel command
97401 + line option on boot. Furthermore you can control various PaX features
97402 + at runtime via the entries in /proc/sys/kernel/pax.
97403 +
97404 +config PAX_EI_PAX
97405 + bool 'Use legacy ELF header marking'
97406 + default y if GRKERNSEC_CONFIG_AUTO
97407 + help
97408 + Enabling this option will allow you to control PaX features on
97409 + a per executable basis via the 'chpax' utility available at
97410 + http://pax.grsecurity.net/. The control flags will be read from
97411 + an otherwise reserved part of the ELF header. This marking has
97412 + numerous drawbacks (no support for soft-mode, toolchain does not
97413 + know about the non-standard use of the ELF header) therefore it
97414 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
97415 + support.
97416 +
97417 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
97418 + support as well, they will override the legacy EI_PAX marks.
97419 +
97420 + If you enable none of the marking options then all applications
97421 + will run with PaX enabled on them by default.
97422 +
97423 +config PAX_PT_PAX_FLAGS
97424 + bool 'Use ELF program header marking'
97425 + default y if GRKERNSEC_CONFIG_AUTO
97426 + help
97427 + Enabling this option will allow you to control PaX features on
97428 + a per executable basis via the 'paxctl' utility available at
97429 + http://pax.grsecurity.net/. The control flags will be read from
97430 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
97431 + has the benefits of supporting both soft mode and being fully
97432 + integrated into the toolchain (the binutils patch is available
97433 + from http://pax.grsecurity.net).
97434 +
97435 + Note that if you enable the legacy EI_PAX marking support as well,
97436 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
97437 +
97438 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97439 + must make sure that the marks are the same if a binary has both marks.
97440 +
97441 + If you enable none of the marking options then all applications
97442 + will run with PaX enabled on them by default.
97443 +
97444 +config PAX_XATTR_PAX_FLAGS
97445 + bool 'Use filesystem extended attributes marking'
97446 + default y if GRKERNSEC_CONFIG_AUTO
97447 + select CIFS_XATTR if CIFS
97448 + select EXT2_FS_XATTR if EXT2_FS
97449 + select EXT3_FS_XATTR if EXT3_FS
97450 + select EXT4_FS_XATTR if EXT4_FS
97451 + select JFFS2_FS_XATTR if JFFS2_FS
97452 + select REISERFS_FS_XATTR if REISERFS_FS
97453 + select SQUASHFS_XATTR if SQUASHFS
97454 + select TMPFS_XATTR if TMPFS
97455 + select UBIFS_FS_XATTR if UBIFS_FS
97456 + help
97457 + Enabling this option will allow you to control PaX features on
97458 + a per executable basis via the 'setfattr' utility. The control
97459 + flags will be read from the user.pax.flags extended attribute of
97460 + the file. This marking has the benefit of supporting binary-only
97461 + applications that self-check themselves (e.g., skype) and would
97462 + not tolerate chpax/paxctl changes. The main drawback is that
97463 + extended attributes are not supported by some filesystems (e.g.,
97464 + isofs, udf, vfat) so copying files through such filesystems will
97465 + lose the extended attributes and these PaX markings.
97466 +
97467 + Note that if you enable the legacy EI_PAX marking support as well,
97468 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
97469 +
97470 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97471 + must make sure that the marks are the same if a binary has both marks.
97472 +
97473 + If you enable none of the marking options then all applications
97474 + will run with PaX enabled on them by default.
97475 +
97476 +choice
97477 + prompt 'MAC system integration'
97478 + default PAX_HAVE_ACL_FLAGS
97479 + help
97480 + Mandatory Access Control systems have the option of controlling
97481 + PaX flags on a per executable basis, choose the method supported
97482 + by your particular system.
97483 +
97484 + - "none": if your MAC system does not interact with PaX,
97485 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
97486 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
97487 +
97488 + NOTE: this option is for developers/integrators only.
97489 +
97490 + config PAX_NO_ACL_FLAGS
97491 + bool 'none'
97492 +
97493 + config PAX_HAVE_ACL_FLAGS
97494 + bool 'direct'
97495 +
97496 + config PAX_HOOK_ACL_FLAGS
97497 + bool 'hook'
97498 +endchoice
97499 +
97500 +endmenu
97501 +
97502 +menu "Non-executable pages"
97503 + depends on PAX
97504 +
97505 +config PAX_NOEXEC
97506 + bool "Enforce non-executable pages"
97507 + default y if GRKERNSEC_CONFIG_AUTO
97508 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
97509 + help
97510 + By design some architectures do not allow for protecting memory
97511 + pages against execution or even if they do, Linux does not make
97512 + use of this feature. In practice this means that if a page is
97513 + readable (such as the stack or heap) it is also executable.
97514 +
97515 + There is a well known exploit technique that makes use of this
97516 + fact and a common programming mistake where an attacker can
97517 + introduce code of his choice somewhere in the attacked program's
97518 + memory (typically the stack or the heap) and then execute it.
97519 +
97520 + If the attacked program was running with different (typically
97521 + higher) privileges than that of the attacker, then he can elevate
97522 + his own privilege level (e.g. get a root shell, write to files for
97523 + which he does not have write access to, etc).
97524 +
97525 + Enabling this option will let you choose from various features
97526 + that prevent the injection and execution of 'foreign' code in
97527 + a program.
97528 +
97529 + This will also break programs that rely on the old behaviour and
97530 + expect that dynamically allocated memory via the malloc() family
97531 + of functions is executable (which it is not). Notable examples
97532 + are the XFree86 4.x server, the java runtime and wine.
97533 +
97534 +config PAX_PAGEEXEC
97535 + bool "Paging based non-executable pages"
97536 + default y if GRKERNSEC_CONFIG_AUTO
97537 + 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)
97538 + select ARCH_TRACK_EXEC_LIMIT if X86_32
97539 + help
97540 + This implementation is based on the paging feature of the CPU.
97541 + On i386 without hardware non-executable bit support there is a
97542 + variable but usually low performance impact, however on Intel's
97543 + P4 core based CPUs it is very high so you should not enable this
97544 + for kernels meant to be used on such CPUs.
97545 +
97546 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
97547 + with hardware non-executable bit support there is no performance
97548 + impact, on ppc the impact is negligible.
97549 +
97550 + Note that several architectures require various emulations due to
97551 + badly designed userland ABIs, this will cause a performance impact
97552 + but will disappear as soon as userland is fixed. For example, ppc
97553 + userland MUST have been built with secure-plt by a recent toolchain.
97554 +
97555 +config PAX_SEGMEXEC
97556 + bool "Segmentation based non-executable pages"
97557 + default y if GRKERNSEC_CONFIG_AUTO
97558 + depends on PAX_NOEXEC && X86_32
97559 + help
97560 + This implementation is based on the segmentation feature of the
97561 + CPU and has a very small performance impact, however applications
97562 + will be limited to a 1.5 GB address space instead of the normal
97563 + 3 GB.
97564 +
97565 +config PAX_EMUTRAMP
97566 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
97567 + default y if PARISC
97568 + help
97569 + There are some programs and libraries that for one reason or
97570 + another attempt to execute special small code snippets from
97571 + non-executable memory pages. Most notable examples are the
97572 + signal handler return code generated by the kernel itself and
97573 + the GCC trampolines.
97574 +
97575 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
97576 + such programs will no longer work under your kernel.
97577 +
97578 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
97579 + utilities to enable trampoline emulation for the affected programs
97580 + yet still have the protection provided by the non-executable pages.
97581 +
97582 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
97583 + your system will not even boot.
97584 +
97585 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
97586 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
97587 + for the affected files.
97588 +
97589 + NOTE: enabling this feature *may* open up a loophole in the
97590 + protection provided by non-executable pages that an attacker
97591 + could abuse. Therefore the best solution is to not have any
97592 + files on your system that would require this option. This can
97593 + be achieved by not using libc5 (which relies on the kernel
97594 + signal handler return code) and not using or rewriting programs
97595 + that make use of the nested function implementation of GCC.
97596 + Skilled users can just fix GCC itself so that it implements
97597 + nested function calls in a way that does not interfere with PaX.
97598 +
97599 +config PAX_EMUSIGRT
97600 + bool "Automatically emulate sigreturn trampolines"
97601 + depends on PAX_EMUTRAMP && PARISC
97602 + default y
97603 + help
97604 + Enabling this option will have the kernel automatically detect
97605 + and emulate signal return trampolines executing on the stack
97606 + that would otherwise lead to task termination.
97607 +
97608 + This solution is intended as a temporary one for users with
97609 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
97610 + Modula-3 runtime, etc) or executables linked to such, basically
97611 + everything that does not specify its own SA_RESTORER function in
97612 + normal executable memory like glibc 2.1+ does.
97613 +
97614 + On parisc you MUST enable this option, otherwise your system will
97615 + not even boot.
97616 +
97617 + NOTE: this feature cannot be disabled on a per executable basis
97618 + and since it *does* open up a loophole in the protection provided
97619 + by non-executable pages, the best solution is to not have any
97620 + files on your system that would require this option.
97621 +
97622 +config PAX_MPROTECT
97623 + bool "Restrict mprotect()"
97624 + default y if GRKERNSEC_CONFIG_AUTO
97625 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
97626 + help
97627 + Enabling this option will prevent programs from
97628 + - changing the executable status of memory pages that were
97629 + not originally created as executable,
97630 + - making read-only executable pages writable again,
97631 + - creating executable pages from anonymous memory,
97632 + - making read-only-after-relocations (RELRO) data pages writable again.
97633 +
97634 + You should say Y here to complete the protection provided by
97635 + the enforcement of non-executable pages.
97636 +
97637 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97638 + this feature on a per file basis.
97639 +
97640 +config PAX_MPROTECT_COMPAT
97641 + bool "Use legacy/compat protection demoting (read help)"
97642 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97643 + depends on PAX_MPROTECT
97644 + help
97645 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
97646 + by sending the proper error code to the application. For some broken
97647 + userland, this can cause problems with Python or other applications. The
97648 + current implementation however allows for applications like clamav to
97649 + detect if JIT compilation/execution is allowed and to fall back gracefully
97650 + to an interpreter-based mode if it does not. While we encourage everyone
97651 + to use the current implementation as-is and push upstream to fix broken
97652 + userland (note that the RWX logging option can assist with this), in some
97653 + environments this may not be possible. Having to disable MPROTECT
97654 + completely on certain binaries reduces the security benefit of PaX,
97655 + so this option is provided for those environments to revert to the old
97656 + behavior.
97657 +
97658 +config PAX_ELFRELOCS
97659 + bool "Allow ELF text relocations (read help)"
97660 + depends on PAX_MPROTECT
97661 + default n
97662 + help
97663 + Non-executable pages and mprotect() restrictions are effective
97664 + in preventing the introduction of new executable code into an
97665 + attacked task's address space. There remain only two venues
97666 + for this kind of attack: if the attacker can execute already
97667 + existing code in the attacked task then he can either have it
97668 + create and mmap() a file containing his code or have it mmap()
97669 + an already existing ELF library that does not have position
97670 + independent code in it and use mprotect() on it to make it
97671 + writable and copy his code there. While protecting against
97672 + the former approach is beyond PaX, the latter can be prevented
97673 + by having only PIC ELF libraries on one's system (which do not
97674 + need to relocate their code). If you are sure this is your case,
97675 + as is the case with all modern Linux distributions, then leave
97676 + this option disabled. You should say 'n' here.
97677 +
97678 +config PAX_ETEXECRELOCS
97679 + bool "Allow ELF ET_EXEC text relocations"
97680 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
97681 + select PAX_ELFRELOCS
97682 + default y
97683 + help
97684 + On some architectures there are incorrectly created applications
97685 + that require text relocations and would not work without enabling
97686 + this option. If you are an alpha, ia64 or parisc user, you should
97687 + enable this option and disable it once you have made sure that
97688 + none of your applications need it.
97689 +
97690 +config PAX_EMUPLT
97691 + bool "Automatically emulate ELF PLT"
97692 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
97693 + default y
97694 + help
97695 + Enabling this option will have the kernel automatically detect
97696 + and emulate the Procedure Linkage Table entries in ELF files.
97697 + On some architectures such entries are in writable memory, and
97698 + become non-executable leading to task termination. Therefore
97699 + it is mandatory that you enable this option on alpha, parisc,
97700 + sparc and sparc64, otherwise your system would not even boot.
97701 +
97702 + NOTE: this feature *does* open up a loophole in the protection
97703 + provided by the non-executable pages, therefore the proper
97704 + solution is to modify the toolchain to produce a PLT that does
97705 + not need to be writable.
97706 +
97707 +config PAX_DLRESOLVE
97708 + bool 'Emulate old glibc resolver stub'
97709 + depends on PAX_EMUPLT && SPARC
97710 + default n
97711 + help
97712 + This option is needed if userland has an old glibc (before 2.4)
97713 + that puts a 'save' instruction into the runtime generated resolver
97714 + stub that needs special emulation.
97715 +
97716 +config PAX_KERNEXEC
97717 + bool "Enforce non-executable kernel pages"
97718 + 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))
97719 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
97720 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
97721 + select PAX_KERNEXEC_PLUGIN if X86_64
97722 + help
97723 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
97724 + that is, enabling this option will make it harder to inject
97725 + and execute 'foreign' code in kernel memory itself.
97726 +
97727 +choice
97728 + prompt "Return Address Instrumentation Method"
97729 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
97730 + depends on PAX_KERNEXEC_PLUGIN
97731 + help
97732 + Select the method used to instrument function pointer dereferences.
97733 + Note that binary modules cannot be instrumented by this approach.
97734 +
97735 + Note that the implementation requires a gcc with plugin support,
97736 + i.e., gcc 4.5 or newer. You may need to install the supporting
97737 + headers explicitly in addition to the normal gcc package.
97738 +
97739 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
97740 + bool "bts"
97741 + help
97742 + This method is compatible with binary only modules but has
97743 + a higher runtime overhead.
97744 +
97745 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
97746 + bool "or"
97747 + depends on !PARAVIRT
97748 + help
97749 + This method is incompatible with binary only modules but has
97750 + a lower runtime overhead.
97751 +endchoice
97752 +
97753 +config PAX_KERNEXEC_PLUGIN_METHOD
97754 + string
97755 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
97756 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
97757 + default ""
97758 +
97759 +config PAX_KERNEXEC_MODULE_TEXT
97760 + int "Minimum amount of memory reserved for module code"
97761 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
97762 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97763 + depends on PAX_KERNEXEC && X86_32
97764 + help
97765 + Due to implementation details the kernel must reserve a fixed
97766 + amount of memory for runtime allocated code (such as modules)
97767 + at compile time that cannot be changed at runtime. Here you
97768 + can specify the minimum amount in MB that will be reserved.
97769 + Due to the same implementation details this size will always
97770 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
97771 + the actually available memory for runtime allocated code will
97772 + usually be more than this minimum.
97773 +
97774 + The default 4 MB should be enough for most users but if you have
97775 + an excessive number of modules (e.g., most distribution configs
97776 + compile many drivers as modules) or use huge modules such as
97777 + nvidia's kernel driver, you will need to adjust this amount.
97778 + A good rule of thumb is to look at your currently loaded kernel
97779 + modules and add up their sizes.
97780 +
97781 +endmenu
97782 +
97783 +menu "Address Space Layout Randomization"
97784 + depends on PAX
97785 +
97786 +config PAX_ASLR
97787 + bool "Address Space Layout Randomization"
97788 + default y if GRKERNSEC_CONFIG_AUTO
97789 + help
97790 + Many if not most exploit techniques rely on the knowledge of
97791 + certain addresses in the attacked program. The following options
97792 + will allow the kernel to apply a certain amount of randomization
97793 + to specific parts of the program thereby forcing an attacker to
97794 + guess them in most cases. Any failed guess will most likely crash
97795 + the attacked program which allows the kernel to detect such attempts
97796 + and react on them. PaX itself provides no reaction mechanisms,
97797 + instead it is strongly encouraged that you make use of Nergal's
97798 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
97799 + (http://www.grsecurity.net/) built-in crash detection features or
97800 + develop one yourself.
97801 +
97802 + By saying Y here you can choose to randomize the following areas:
97803 + - top of the task's kernel stack
97804 + - top of the task's userland stack
97805 + - base address for mmap() requests that do not specify one
97806 + (this includes all libraries)
97807 + - base address of the main executable
97808 +
97809 + It is strongly recommended to say Y here as address space layout
97810 + randomization has negligible impact on performance yet it provides
97811 + a very effective protection.
97812 +
97813 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97814 + this feature on a per file basis.
97815 +
97816 +config PAX_RANDKSTACK
97817 + bool "Randomize kernel stack base"
97818 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
97819 + depends on X86_TSC && X86
97820 + help
97821 + By saying Y here the kernel will randomize every task's kernel
97822 + stack on every system call. This will not only force an attacker
97823 + to guess it but also prevent him from making use of possible
97824 + leaked information about it.
97825 +
97826 + Since the kernel stack is a rather scarce resource, randomization
97827 + may cause unexpected stack overflows, therefore you should very
97828 + carefully test your system. Note that once enabled in the kernel
97829 + configuration, this feature cannot be disabled on a per file basis.
97830 +
97831 +config PAX_RANDUSTACK
97832 + bool "Randomize user stack base"
97833 + default y if GRKERNSEC_CONFIG_AUTO
97834 + depends on PAX_ASLR
97835 + help
97836 + By saying Y here the kernel will randomize every task's userland
97837 + stack. The randomization is done in two steps where the second
97838 + one may apply a big amount of shift to the top of the stack and
97839 + cause problems for programs that want to use lots of memory (more
97840 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
97841 + For this reason the second step can be controlled by 'chpax' or
97842 + 'paxctl' on a per file basis.
97843 +
97844 +config PAX_RANDMMAP
97845 + bool "Randomize mmap() base"
97846 + default y if GRKERNSEC_CONFIG_AUTO
97847 + depends on PAX_ASLR
97848 + help
97849 + By saying Y here the kernel will use a randomized base address for
97850 + mmap() requests that do not specify one themselves. As a result
97851 + all dynamically loaded libraries will appear at random addresses
97852 + and therefore be harder to exploit by a technique where an attacker
97853 + attempts to execute library code for his purposes (e.g. spawn a
97854 + shell from an exploited program that is running at an elevated
97855 + privilege level).
97856 +
97857 + Furthermore, if a program is relinked as a dynamic ELF file, its
97858 + base address will be randomized as well, completing the full
97859 + randomization of the address space layout. Attacking such programs
97860 + becomes a guess game. You can find an example of doing this at
97861 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
97862 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
97863 +
97864 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
97865 + feature on a per file basis.
97866 +
97867 +endmenu
97868 +
97869 +menu "Miscellaneous hardening features"
97870 +
97871 +config PAX_MEMORY_SANITIZE
97872 + bool "Sanitize all freed memory"
97873 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97874 + depends on !HIBERNATION
97875 + help
97876 + By saying Y here the kernel will erase memory pages and slab objects
97877 + as soon as they are freed. This in turn reduces the lifetime of data
97878 + stored in them, making it less likely that sensitive information such
97879 + as passwords, cryptographic secrets, etc stay in memory for too long.
97880 +
97881 + This is especially useful for programs whose runtime is short, long
97882 + lived processes and the kernel itself benefit from this as long as
97883 + they ensure timely freeing of memory that may hold sensitive
97884 + information.
97885 +
97886 + A nice side effect of the sanitization of slab objects is the
97887 + reduction of possible info leaks caused by padding bytes within the
97888 + leaky structures. Use-after-free bugs for structures containing
97889 + pointers can also be detected as dereferencing the sanitized pointer
97890 + will generate an access violation.
97891 +
97892 + The tradeoff is performance impact, on a single CPU system kernel
97893 + compilation sees a 3% slowdown, other systems and workloads may vary
97894 + and you are advised to test this feature on your expected workload
97895 + before deploying it.
97896 +
97897 + To reduce the performance penalty by sanitizing pages only, albeit
97898 + limiting the effectiveness of this feature at the same time, slab
97899 + sanitization can be disabled with the kernel commandline parameter
97900 + "pax_sanitize_slab=0".
97901 +
97902 + Note that this feature does not protect data stored in live pages,
97903 + e.g., process memory swapped to disk may stay there for a long time.
97904 +
97905 +config PAX_MEMORY_STACKLEAK
97906 + bool "Sanitize kernel stack"
97907 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97908 + depends on X86
97909 + help
97910 + By saying Y here the kernel will erase the kernel stack before it
97911 + returns from a system call. This in turn reduces the information
97912 + that a kernel stack leak bug can reveal.
97913 +
97914 + Note that such a bug can still leak information that was put on
97915 + the stack by the current system call (the one eventually triggering
97916 + the bug) but traces of earlier system calls on the kernel stack
97917 + cannot leak anymore.
97918 +
97919 + The tradeoff is performance impact: on a single CPU system kernel
97920 + compilation sees a 1% slowdown, other systems and workloads may vary
97921 + and you are advised to test this feature on your expected workload
97922 + before deploying it.
97923 +
97924 + Note that the full feature requires a gcc with plugin support,
97925 + i.e., gcc 4.5 or newer. You may need to install the supporting
97926 + headers explicitly in addition to the normal gcc package. Using
97927 + older gcc versions means that functions with large enough stack
97928 + frames may leave uninitialized memory behind that may be exposed
97929 + to a later syscall leaking the stack.
97930 +
97931 +config PAX_MEMORY_STRUCTLEAK
97932 + bool "Forcibly initialize local variables copied to userland"
97933 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97934 + help
97935 + By saying Y here the kernel will zero initialize some local
97936 + variables that are going to be copied to userland. This in
97937 + turn prevents unintended information leakage from the kernel
97938 + stack should later code forget to explicitly set all parts of
97939 + the copied variable.
97940 +
97941 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
97942 + at a much smaller coverage.
97943 +
97944 + Note that the implementation requires a gcc with plugin support,
97945 + i.e., gcc 4.5 or newer. You may need to install the supporting
97946 + headers explicitly in addition to the normal gcc package.
97947 +
97948 +config PAX_MEMORY_UDEREF
97949 + bool "Prevent invalid userland pointer dereference"
97950 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
97951 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
97952 + select PAX_PER_CPU_PGD if X86_64
97953 + help
97954 + By saying Y here the kernel will be prevented from dereferencing
97955 + userland pointers in contexts where the kernel expects only kernel
97956 + pointers. This is both a useful runtime debugging feature and a
97957 + security measure that prevents exploiting a class of kernel bugs.
97958 +
97959 + The tradeoff is that some virtualization solutions may experience
97960 + a huge slowdown and therefore you should not enable this feature
97961 + for kernels meant to run in such environments. Whether a given VM
97962 + solution is affected or not is best determined by simply trying it
97963 + out, the performance impact will be obvious right on boot as this
97964 + mechanism engages from very early on. A good rule of thumb is that
97965 + VMs running on CPUs without hardware virtualization support (i.e.,
97966 + the majority of IA-32 CPUs) will likely experience the slowdown.
97967 +
97968 + On X86_64 the kernel will make use of PCID support when available
97969 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
97970 + or performance impact. Pass pax_weakuderef on the kernel command
97971 + line to choose the latter.
97972 +
97973 +config PAX_REFCOUNT
97974 + bool "Prevent various kernel object reference counter overflows"
97975 + default y if GRKERNSEC_CONFIG_AUTO
97976 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
97977 + help
97978 + By saying Y here the kernel will detect and prevent overflowing
97979 + various (but not all) kinds of object reference counters. Such
97980 + overflows can normally occur due to bugs only and are often, if
97981 + not always, exploitable.
97982 +
97983 + The tradeoff is that data structures protected by an overflowed
97984 + refcount will never be freed and therefore will leak memory. Note
97985 + that this leak also happens even without this protection but in
97986 + that case the overflow can eventually trigger the freeing of the
97987 + data structure while it is still being used elsewhere, resulting
97988 + in the exploitable situation that this feature prevents.
97989 +
97990 + Since this has a negligible performance impact, you should enable
97991 + this feature.
97992 +
97993 +config PAX_CONSTIFY_PLUGIN
97994 + bool "Automatically constify eligible structures"
97995 + default y
97996 + depends on !UML && PAX_KERNEXEC
97997 + help
97998 + By saying Y here the compiler will automatically constify a class
97999 + of types that contain only function pointers. This reduces the
98000 + kernel's attack surface and also produces a better memory layout.
98001 +
98002 + Note that the implementation requires a gcc with plugin support,
98003 + i.e., gcc 4.5 or newer. You may need to install the supporting
98004 + headers explicitly in addition to the normal gcc package.
98005 +
98006 + Note that if some code really has to modify constified variables
98007 + then the source code will have to be patched to allow it. Examples
98008 + can be found in PaX itself (the no_const attribute) and for some
98009 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
98010 +
98011 +config PAX_USERCOPY
98012 + bool "Harden heap object copies between kernel and userland"
98013 + default y if GRKERNSEC_CONFIG_AUTO
98014 + depends on ARM || IA64 || PPC || SPARC || X86
98015 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
98016 + select PAX_USERCOPY_SLABS
98017 + help
98018 + By saying Y here the kernel will enforce the size of heap objects
98019 + when they are copied in either direction between the kernel and
98020 + userland, even if only a part of the heap object is copied.
98021 +
98022 + Specifically, this checking prevents information leaking from the
98023 + kernel heap during kernel to userland copies (if the kernel heap
98024 + object is otherwise fully initialized) and prevents kernel heap
98025 + overflows during userland to kernel copies.
98026 +
98027 + Note that the current implementation provides the strictest bounds
98028 + checks for the SLUB allocator.
98029 +
98030 + Enabling this option also enables per-slab cache protection against
98031 + data in a given cache being copied into/out of via userland
98032 + accessors. Though the whitelist of regions will be reduced over
98033 + time, it notably protects important data structures like task structs.
98034 +
98035 + If frame pointers are enabled on x86, this option will also restrict
98036 + copies into and out of the kernel stack to local variables within a
98037 + single frame.
98038 +
98039 + Since this has a negligible performance impact, you should enable
98040 + this feature.
98041 +
98042 +config PAX_USERCOPY_DEBUG
98043 + bool
98044 + depends on X86 && PAX_USERCOPY
98045 + default n
98046 +
98047 +config PAX_SIZE_OVERFLOW
98048 + bool "Prevent various integer overflows in function size parameters"
98049 + default y if GRKERNSEC_CONFIG_AUTO
98050 + depends on X86
98051 + help
98052 + By saying Y here the kernel recomputes expressions of function
98053 + arguments marked by a size_overflow attribute with double integer
98054 + precision (DImode/TImode for 32/64 bit integer types).
98055 +
98056 + The recomputed argument is checked against TYPE_MAX and an event
98057 + is logged on overflow and the triggering process is killed.
98058 +
98059 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
98060 +
98061 + Note that the implementation requires a gcc with plugin support,
98062 + i.e., gcc 4.5 or newer. You may need to install the supporting
98063 + headers explicitly in addition to the normal gcc package.
98064 +
98065 +config PAX_LATENT_ENTROPY
98066 + bool "Generate some entropy during boot"
98067 + default y if GRKERNSEC_CONFIG_AUTO
98068 + help
98069 + By saying Y here the kernel will instrument early boot code to
98070 + extract some entropy from both original and artificially created
98071 + program state. This will help especially embedded systems where
98072 + there is little 'natural' source of entropy normally. The cost
98073 + is some slowdown of the boot process.
98074 +
98075 + When pax_extra_latent_entropy is passed on the kernel command line,
98076 + entropy will be extracted from up to the first 4GB of RAM while the
98077 + runtime memory allocator is being initialized. This costs even more
98078 + slowdown of the boot process.
98079 +
98080 + Note that the implementation requires a gcc with plugin support,
98081 + i.e., gcc 4.5 or newer. You may need to install the supporting
98082 + headers explicitly in addition to the normal gcc package.
98083 +
98084 + Note that entropy extracted this way is not cryptographically
98085 + secure!
98086 +
98087 +endmenu
98088 +
98089 +endmenu
98090 +
98091 +source grsecurity/Kconfig
98092 +
98093 +endmenu
98094 +
98095 +endmenu
98096 +
98097 source security/keys/Kconfig
98098
98099 config SECURITY_DMESG_RESTRICT
98100 @@ -103,7 +1056,7 @@ config INTEL_TXT
98101 config LSM_MMAP_MIN_ADDR
98102 int "Low address space for LSM to protect from user allocation"
98103 depends on SECURITY && SECURITY_SELINUX
98104 - default 32768 if ARM
98105 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98106 default 65536
98107 help
98108 This is the portion of low virtual memory which should be protected
98109 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98110 index 9b9013b..51ebf96 100644
98111 --- a/security/apparmor/Kconfig
98112 +++ b/security/apparmor/Kconfig
98113 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98114 boot.
98115
98116 If you are unsure how to answer this question, answer 1.
98117 +
98118 +config SECURITY_APPARMOR_COMPAT_24
98119 + bool "Enable AppArmor 2.4 compatability"
98120 + depends on SECURITY_APPARMOR
98121 + default y
98122 + help
98123 + This option enables compatability with AppArmor 2.4. It is
98124 + recommended if compatability with older versions of AppArmor
98125 + is desired.
98126 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98127 index 16c15ec..42b7c9f 100644
98128 --- a/security/apparmor/apparmorfs.c
98129 +++ b/security/apparmor/apparmorfs.c
98130 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98131 .release = single_release,
98132 };
98133
98134 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98135 +/**
98136 + * __next_namespace - find the next namespace to list
98137 + * @root: root namespace to stop search at (NOT NULL)
98138 + * @ns: current ns position (NOT NULL)
98139 + *
98140 + * Find the next namespace from @ns under @root and handle all locking needed
98141 + * while switching current namespace.
98142 + *
98143 + * Returns: next namespace or NULL if at last namespace under @root
98144 + * NOTE: will not unlock root->lock
98145 + */
98146 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98147 + struct aa_namespace *ns)
98148 +{
98149 + struct aa_namespace *parent;
98150 +
98151 + /* is next namespace a child */
98152 + if (!list_empty(&ns->sub_ns)) {
98153 + struct aa_namespace *next;
98154 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98155 + read_lock(&next->lock);
98156 + return next;
98157 + }
98158 +
98159 + /* check if the next ns is a sibling, parent, gp, .. */
98160 + parent = ns->parent;
98161 + while (parent) {
98162 + read_unlock(&ns->lock);
98163 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98164 + read_lock(&ns->lock);
98165 + return ns;
98166 + }
98167 + if (parent == root)
98168 + return NULL;
98169 + ns = parent;
98170 + parent = parent->parent;
98171 + }
98172 +
98173 + return NULL;
98174 +}
98175 +
98176 +/**
98177 + * __first_profile - find the first profile in a namespace
98178 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98179 + * @ns: namespace to start in (NOT NULL)
98180 + *
98181 + * Returns: unrefcounted profile or NULL if no profile
98182 + */
98183 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98184 + struct aa_namespace *ns)
98185 +{
98186 + for ( ; ns; ns = __next_namespace(root, ns)) {
98187 + if (!list_empty(&ns->base.profiles))
98188 + return list_first_entry(&ns->base.profiles,
98189 + struct aa_profile, base.list);
98190 + }
98191 + return NULL;
98192 +}
98193 +
98194 +/**
98195 + * __next_profile - step to the next profile in a profile tree
98196 + * @profile: current profile in tree (NOT NULL)
98197 + *
98198 + * Perform a depth first taversal on the profile tree in a namespace
98199 + *
98200 + * Returns: next profile or NULL if done
98201 + * Requires: profile->ns.lock to be held
98202 + */
98203 +static struct aa_profile *__next_profile(struct aa_profile *p)
98204 +{
98205 + struct aa_profile *parent;
98206 + struct aa_namespace *ns = p->ns;
98207 +
98208 + /* is next profile a child */
98209 + if (!list_empty(&p->base.profiles))
98210 + return list_first_entry(&p->base.profiles, typeof(*p),
98211 + base.list);
98212 +
98213 + /* is next profile a sibling, parent sibling, gp, subling, .. */
98214 + parent = p->parent;
98215 + while (parent) {
98216 + list_for_each_entry_continue(p, &parent->base.profiles,
98217 + base.list)
98218 + return p;
98219 + p = parent;
98220 + parent = parent->parent;
98221 + }
98222 +
98223 + /* is next another profile in the namespace */
98224 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
98225 + return p;
98226 +
98227 + return NULL;
98228 +}
98229 +
98230 +/**
98231 + * next_profile - step to the next profile in where ever it may be
98232 + * @root: root namespace (NOT NULL)
98233 + * @profile: current profile (NOT NULL)
98234 + *
98235 + * Returns: next profile or NULL if there isn't one
98236 + */
98237 +static struct aa_profile *next_profile(struct aa_namespace *root,
98238 + struct aa_profile *profile)
98239 +{
98240 + struct aa_profile *next = __next_profile(profile);
98241 + if (next)
98242 + return next;
98243 +
98244 + /* finished all profiles in namespace move to next namespace */
98245 + return __first_profile(root, __next_namespace(root, profile->ns));
98246 +}
98247 +
98248 +/**
98249 + * p_start - start a depth first traversal of profile tree
98250 + * @f: seq_file to fill
98251 + * @pos: current position
98252 + *
98253 + * Returns: first profile under current namespace or NULL if none found
98254 + *
98255 + * acquires first ns->lock
98256 + */
98257 +static void *p_start(struct seq_file *f, loff_t *pos)
98258 + __acquires(root->lock)
98259 +{
98260 + struct aa_profile *profile = NULL;
98261 + struct aa_namespace *root = aa_current_profile()->ns;
98262 + loff_t l = *pos;
98263 + f->private = aa_get_namespace(root);
98264 +
98265 +
98266 + /* find the first profile */
98267 + read_lock(&root->lock);
98268 + profile = __first_profile(root, root);
98269 +
98270 + /* skip to position */
98271 + for (; profile && l > 0; l--)
98272 + profile = next_profile(root, profile);
98273 +
98274 + return profile;
98275 +}
98276 +
98277 +/**
98278 + * p_next - read the next profile entry
98279 + * @f: seq_file to fill
98280 + * @p: profile previously returned
98281 + * @pos: current position
98282 + *
98283 + * Returns: next profile after @p or NULL if none
98284 + *
98285 + * may acquire/release locks in namespace tree as necessary
98286 + */
98287 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
98288 +{
98289 + struct aa_profile *profile = p;
98290 + struct aa_namespace *root = f->private;
98291 + (*pos)++;
98292 +
98293 + return next_profile(root, profile);
98294 +}
98295 +
98296 +/**
98297 + * p_stop - stop depth first traversal
98298 + * @f: seq_file we are filling
98299 + * @p: the last profile writen
98300 + *
98301 + * Release all locking done by p_start/p_next on namespace tree
98302 + */
98303 +static void p_stop(struct seq_file *f, void *p)
98304 + __releases(root->lock)
98305 +{
98306 + struct aa_profile *profile = p;
98307 + struct aa_namespace *root = f->private, *ns;
98308 +
98309 + if (profile) {
98310 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
98311 + read_unlock(&ns->lock);
98312 + }
98313 + read_unlock(&root->lock);
98314 + aa_put_namespace(root);
98315 +}
98316 +
98317 +/**
98318 + * seq_show_profile - show a profile entry
98319 + * @f: seq_file to file
98320 + * @p: current position (profile) (NOT NULL)
98321 + *
98322 + * Returns: error on failure
98323 + */
98324 +static int seq_show_profile(struct seq_file *f, void *p)
98325 +{
98326 + struct aa_profile *profile = (struct aa_profile *)p;
98327 + struct aa_namespace *root = f->private;
98328 +
98329 + if (profile->ns != root)
98330 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
98331 + seq_printf(f, "%s (%s)\n", profile->base.hname,
98332 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
98333 +
98334 + return 0;
98335 +}
98336 +
98337 +static const struct seq_operations aa_fs_profiles_op = {
98338 + .start = p_start,
98339 + .next = p_next,
98340 + .stop = p_stop,
98341 + .show = seq_show_profile,
98342 +};
98343 +
98344 +static int profiles_open(struct inode *inode, struct file *file)
98345 +{
98346 + return seq_open(file, &aa_fs_profiles_op);
98347 +}
98348 +
98349 +static int profiles_release(struct inode *inode, struct file *file)
98350 +{
98351 + return seq_release(inode, file);
98352 +}
98353 +
98354 +const struct file_operations aa_fs_profiles_fops = {
98355 + .open = profiles_open,
98356 + .read = seq_read,
98357 + .llseek = seq_lseek,
98358 + .release = profiles_release,
98359 +};
98360 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
98361 +
98362 /** Base file system setup **/
98363
98364 static struct aa_fs_entry aa_fs_entry_file[] = {
98365 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
98366 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
98367 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
98368 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
98369 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98370 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
98371 +#endif
98372 AA_FS_DIR("features", aa_fs_entry_features),
98373 { }
98374 };
98375 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
98376 index 2e2a0dd..a0cbc44 100644
98377 --- a/security/apparmor/lsm.c
98378 +++ b/security/apparmor/lsm.c
98379 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
98380 return error;
98381 }
98382
98383 -static struct security_operations apparmor_ops = {
98384 +static struct security_operations apparmor_ops __read_only = {
98385 .name = "apparmor",
98386
98387 .ptrace_access_check = apparmor_ptrace_access_check,
98388 diff --git a/security/commoncap.c b/security/commoncap.c
98389 index c44b6fe..932df30 100644
98390 --- a/security/commoncap.c
98391 +++ b/security/commoncap.c
98392 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
98393 return 0;
98394 }
98395
98396 +/* returns:
98397 + 1 for suid privilege
98398 + 2 for sgid privilege
98399 + 3 for fscap privilege
98400 +*/
98401 +int is_privileged_binary(const struct dentry *dentry)
98402 +{
98403 + struct cpu_vfs_cap_data capdata;
98404 + struct inode *inode = dentry->d_inode;
98405 +
98406 + if (!inode || S_ISDIR(inode->i_mode))
98407 + return 0;
98408 +
98409 + if (inode->i_mode & S_ISUID)
98410 + return 1;
98411 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
98412 + return 2;
98413 +
98414 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
98415 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
98416 + return 3;
98417 + }
98418 +
98419 + return 0;
98420 +}
98421 +
98422 /*
98423 * Attempt to get the on-exec apply capability sets for an executable file from
98424 * its xattrs and, if present, apply them to the proposed credentials being
98425 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
98426 const struct cred *cred = current_cred();
98427 kuid_t root_uid = make_kuid(cred->user_ns, 0);
98428
98429 + if (gr_acl_enable_at_secure())
98430 + return 1;
98431 +
98432 if (!uid_eq(cred->uid, root_uid)) {
98433 if (bprm->cap_effective)
98434 return 1;
98435 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
98436 index b3dd616..4bb17f3 100644
98437 --- a/security/integrity/ima/ima.h
98438 +++ b/security/integrity/ima/ima.h
98439 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
98440 extern spinlock_t ima_queue_lock;
98441
98442 struct ima_h_table {
98443 - atomic_long_t len; /* number of stored measurements in the list */
98444 - atomic_long_t violations;
98445 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
98446 + atomic_long_unchecked_t violations;
98447 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
98448 };
98449 extern struct ima_h_table ima_htable;
98450 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
98451 index 1c03e8f1..398a941 100644
98452 --- a/security/integrity/ima/ima_api.c
98453 +++ b/security/integrity/ima/ima_api.c
98454 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
98455 int result;
98456
98457 /* can overflow, only indicator */
98458 - atomic_long_inc(&ima_htable.violations);
98459 + atomic_long_inc_unchecked(&ima_htable.violations);
98460
98461 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
98462 if (!entry) {
98463 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
98464 index 38477c9..87a60c7 100644
98465 --- a/security/integrity/ima/ima_fs.c
98466 +++ b/security/integrity/ima/ima_fs.c
98467 @@ -28,12 +28,12 @@
98468 static int valid_policy = 1;
98469 #define TMPBUFLEN 12
98470 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
98471 - loff_t *ppos, atomic_long_t *val)
98472 + loff_t *ppos, atomic_long_unchecked_t *val)
98473 {
98474 char tmpbuf[TMPBUFLEN];
98475 ssize_t len;
98476
98477 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
98478 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
98479 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
98480 }
98481
98482 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
98483 index ff63fe0..809cd96 100644
98484 --- a/security/integrity/ima/ima_queue.c
98485 +++ b/security/integrity/ima/ima_queue.c
98486 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
98487 INIT_LIST_HEAD(&qe->later);
98488 list_add_tail_rcu(&qe->later, &ima_measurements);
98489
98490 - atomic_long_inc(&ima_htable.len);
98491 + atomic_long_inc_unchecked(&ima_htable.len);
98492 key = ima_hash_key(entry->digest);
98493 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
98494 return 0;
98495 diff --git a/security/keys/compat.c b/security/keys/compat.c
98496 index d65fa7f..cbfe366 100644
98497 --- a/security/keys/compat.c
98498 +++ b/security/keys/compat.c
98499 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
98500 if (ret == 0)
98501 goto no_payload_free;
98502
98503 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98504 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98505 err:
98506 if (iov != iovstack)
98507 kfree(iov);
98508 diff --git a/security/keys/internal.h b/security/keys/internal.h
98509 index d4f1468..cc52f92 100644
98510 --- a/security/keys/internal.h
98511 +++ b/security/keys/internal.h
98512 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
98513 extern long keyctl_invalidate_key(key_serial_t);
98514
98515 extern long keyctl_instantiate_key_common(key_serial_t,
98516 - const struct iovec *,
98517 + const struct iovec __user *,
98518 unsigned, size_t, key_serial_t);
98519
98520 /*
98521 diff --git a/security/keys/key.c b/security/keys/key.c
98522 index 8fb7c7b..ba3610d 100644
98523 --- a/security/keys/key.c
98524 +++ b/security/keys/key.c
98525 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
98526
98527 atomic_set(&key->usage, 1);
98528 init_rwsem(&key->sem);
98529 - lockdep_set_class(&key->sem, &type->lock_class);
98530 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
98531 key->type = type;
98532 key->user = user;
98533 key->quotalen = quotalen;
98534 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
98535 struct key_type *p;
98536 int ret;
98537
98538 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
98539 + pax_open_kernel();
98540 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
98541 + pax_close_kernel();
98542
98543 ret = -EEXIST;
98544 down_write(&key_types_sem);
98545 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
98546 }
98547
98548 /* store the type */
98549 - list_add(&ktype->link, &key_types_list);
98550 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
98551
98552 pr_notice("Key type %s registered\n", ktype->name);
98553 ret = 0;
98554 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
98555 void unregister_key_type(struct key_type *ktype)
98556 {
98557 down_write(&key_types_sem);
98558 - list_del_init(&ktype->link);
98559 + pax_list_del_init((struct list_head *)&ktype->link);
98560 downgrade_write(&key_types_sem);
98561 key_gc_keytype(ktype);
98562 pr_notice("Key type %s unregistered\n", ktype->name);
98563 @@ -1084,10 +1086,10 @@ void __init key_init(void)
98564 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
98565
98566 /* add the special key types */
98567 - list_add_tail(&key_type_keyring.link, &key_types_list);
98568 - list_add_tail(&key_type_dead.link, &key_types_list);
98569 - list_add_tail(&key_type_user.link, &key_types_list);
98570 - list_add_tail(&key_type_logon.link, &key_types_list);
98571 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
98572 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
98573 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
98574 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
98575
98576 /* record the root user tracking */
98577 rb_link_node(&root_key_user.node,
98578 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
98579 index 33cfd27..842fc5a 100644
98580 --- a/security/keys/keyctl.c
98581 +++ b/security/keys/keyctl.c
98582 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
98583 /*
98584 * Copy the iovec data from userspace
98585 */
98586 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98587 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
98588 unsigned ioc)
98589 {
98590 for (; ioc > 0; ioc--) {
98591 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98592 * If successful, 0 will be returned.
98593 */
98594 long keyctl_instantiate_key_common(key_serial_t id,
98595 - const struct iovec *payload_iov,
98596 + const struct iovec __user *payload_iov,
98597 unsigned ioc,
98598 size_t plen,
98599 key_serial_t ringid)
98600 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
98601 [0].iov_len = plen
98602 };
98603
98604 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
98605 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
98606 }
98607
98608 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
98609 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
98610 if (ret == 0)
98611 goto no_payload_free;
98612
98613 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98614 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98615 err:
98616 if (iov != iovstack)
98617 kfree(iov);
98618 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
98619 index 6ece7f2..ecdb55c 100644
98620 --- a/security/keys/keyring.c
98621 +++ b/security/keys/keyring.c
98622 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
98623 ret = -EFAULT;
98624
98625 for (loop = 0; loop < klist->nkeys; loop++) {
98626 + key_serial_t serial;
98627 key = rcu_deref_link_locked(klist, loop,
98628 keyring);
98629 + serial = key->serial;
98630
98631 tmp = sizeof(key_serial_t);
98632 if (tmp > buflen)
98633 tmp = buflen;
98634
98635 - if (copy_to_user(buffer,
98636 - &key->serial,
98637 - tmp) != 0)
98638 + if (copy_to_user(buffer, &serial, tmp))
98639 goto error;
98640
98641 buflen -= tmp;
98642 diff --git a/security/min_addr.c b/security/min_addr.c
98643 index f728728..6457a0c 100644
98644 --- a/security/min_addr.c
98645 +++ b/security/min_addr.c
98646 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
98647 */
98648 static void update_mmap_min_addr(void)
98649 {
98650 +#ifndef SPARC
98651 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
98652 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
98653 mmap_min_addr = dac_mmap_min_addr;
98654 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
98655 #else
98656 mmap_min_addr = dac_mmap_min_addr;
98657 #endif
98658 +#endif
98659 }
98660
98661 /*
98662 diff --git a/security/security.c b/security/security.c
98663 index 94b35ae..f4e7751 100644
98664 --- a/security/security.c
98665 +++ b/security/security.c
98666 @@ -33,8 +33,8 @@
98667 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
98668 CONFIG_DEFAULT_SECURITY;
98669
98670 -static struct security_operations *security_ops;
98671 -static struct security_operations default_security_ops = {
98672 +struct security_operations *security_ops __read_only;
98673 +struct security_operations default_security_ops __read_only = {
98674 .name = "default",
98675 };
98676
98677 @@ -73,11 +73,6 @@ int __init security_init(void)
98678 return 0;
98679 }
98680
98681 -void reset_security_ops(void)
98682 -{
98683 - security_ops = &default_security_ops;
98684 -}
98685 -
98686 /* Save user chosen LSM */
98687 static int __init choose_lsm(char *str)
98688 {
98689 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
98690 index dad36a6..7e5ffbf 100644
98691 --- a/security/selinux/avc.c
98692 +++ b/security/selinux/avc.c
98693 @@ -59,7 +59,7 @@ struct avc_node {
98694 struct avc_cache {
98695 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
98696 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
98697 - atomic_t lru_hint; /* LRU hint for reclaim scan */
98698 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
98699 atomic_t active_nodes;
98700 u32 latest_notif; /* latest revocation notification */
98701 };
98702 @@ -167,7 +167,7 @@ void __init avc_init(void)
98703 spin_lock_init(&avc_cache.slots_lock[i]);
98704 }
98705 atomic_set(&avc_cache.active_nodes, 0);
98706 - atomic_set(&avc_cache.lru_hint, 0);
98707 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
98708
98709 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
98710 0, SLAB_PANIC, NULL);
98711 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
98712 spinlock_t *lock;
98713
98714 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
98715 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98716 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98717 head = &avc_cache.slots[hvalue];
98718 lock = &avc_cache.slots_lock[hvalue];
98719
98720 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
98721 index c956390..1899f06 100644
98722 --- a/security/selinux/hooks.c
98723 +++ b/security/selinux/hooks.c
98724 @@ -97,8 +97,6 @@
98725
98726 #define NUM_SEL_MNT_OPTS 5
98727
98728 -extern struct security_operations *security_ops;
98729 -
98730 /* SECMARK reference count */
98731 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
98732
98733 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
98734
98735 #endif
98736
98737 -static struct security_operations selinux_ops = {
98738 +static struct security_operations selinux_ops __read_only = {
98739 .name = "selinux",
98740
98741 .ptrace_access_check = selinux_ptrace_access_check,
98742 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
98743 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
98744 static int selinux_disabled;
98745
98746 +extern struct security_operations *security_ops;
98747 +extern struct security_operations default_security_ops;
98748 +
98749 int selinux_disable(void)
98750 {
98751 if (ss_initialized) {
98752 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
98753 selinux_disabled = 1;
98754 selinux_enabled = 0;
98755
98756 - reset_security_ops();
98757 + pax_open_kernel();
98758 + security_ops = &default_security_ops;
98759 + pax_close_kernel();
98760
98761 /* Try to destroy the avc node cache */
98762 avc_disable();
98763 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
98764 index 65f67cb..3f141ef 100644
98765 --- a/security/selinux/include/xfrm.h
98766 +++ b/security/selinux/include/xfrm.h
98767 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
98768
98769 static inline void selinux_xfrm_notify_policyload(void)
98770 {
98771 - atomic_inc(&flow_cache_genid);
98772 + atomic_inc_unchecked(&flow_cache_genid);
98773 rt_genid_bump(&init_net);
98774 }
98775 #else
98776 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
98777 index eefbd10..9f10ddb 100644
98778 --- a/security/smack/smack_lsm.c
98779 +++ b/security/smack/smack_lsm.c
98780 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
98781 return 0;
98782 }
98783
98784 -struct security_operations smack_ops = {
98785 +struct security_operations smack_ops __read_only = {
98786 .name = "smack",
98787
98788 .ptrace_access_check = smack_ptrace_access_check,
98789 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
98790 index 390c646..f2f8db3 100644
98791 --- a/security/tomoyo/mount.c
98792 +++ b/security/tomoyo/mount.c
98793 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
98794 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
98795 need_dev = -1; /* dev_name is a directory */
98796 } else {
98797 + if (!capable(CAP_SYS_ADMIN)) {
98798 + error = -EPERM;
98799 + goto out;
98800 + }
98801 fstype = get_fs_type(type);
98802 if (!fstype) {
98803 error = -ENODEV;
98804 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
98805 index f0b756e..b129202 100644
98806 --- a/security/tomoyo/tomoyo.c
98807 +++ b/security/tomoyo/tomoyo.c
98808 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
98809 * tomoyo_security_ops is a "struct security_operations" which is used for
98810 * registering TOMOYO.
98811 */
98812 -static struct security_operations tomoyo_security_ops = {
98813 +static struct security_operations tomoyo_security_ops __read_only = {
98814 .name = "tomoyo",
98815 .cred_alloc_blank = tomoyo_cred_alloc_blank,
98816 .cred_prepare = tomoyo_cred_prepare,
98817 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
98818 index 20ef514..4182bed 100644
98819 --- a/security/yama/Kconfig
98820 +++ b/security/yama/Kconfig
98821 @@ -1,6 +1,6 @@
98822 config SECURITY_YAMA
98823 bool "Yama support"
98824 - depends on SECURITY
98825 + depends on SECURITY && !GRKERNSEC
98826 select SECURITYFS
98827 select SECURITY_PATH
98828 default n
98829 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
98830 index 13c88fbc..f8c115e 100644
98831 --- a/security/yama/yama_lsm.c
98832 +++ b/security/yama/yama_lsm.c
98833 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
98834 }
98835
98836 #ifndef CONFIG_SECURITY_YAMA_STACKED
98837 -static struct security_operations yama_ops = {
98838 +static struct security_operations yama_ops __read_only = {
98839 .name = "yama",
98840
98841 .ptrace_access_check = yama_ptrace_access_check,
98842 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
98843 #endif
98844
98845 #ifdef CONFIG_SYSCTL
98846 +static int zero __read_only;
98847 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
98848 +
98849 static int yama_dointvec_minmax(struct ctl_table *table, int write,
98850 void __user *buffer, size_t *lenp, loff_t *ppos)
98851 {
98852 - int rc;
98853 + ctl_table_no_const yama_table;
98854
98855 if (write && !capable(CAP_SYS_PTRACE))
98856 return -EPERM;
98857
98858 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
98859 - if (rc)
98860 - return rc;
98861 -
98862 + yama_table = *table;
98863 /* Lock the max value if it ever gets set. */
98864 - if (write && *(int *)table->data == *(int *)table->extra2)
98865 - table->extra1 = table->extra2;
98866 -
98867 - return rc;
98868 + if (ptrace_scope == max_scope)
98869 + yama_table.extra1 = &max_scope;
98870 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
98871 }
98872
98873 -static int zero;
98874 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
98875 -
98876 struct ctl_path yama_sysctl_path[] = {
98877 { .procname = "kernel", },
98878 { .procname = "yama", },
98879 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
98880 index 4cedc69..e59d8a3 100644
98881 --- a/sound/aoa/codecs/onyx.c
98882 +++ b/sound/aoa/codecs/onyx.c
98883 @@ -54,7 +54,7 @@ struct onyx {
98884 spdif_locked:1,
98885 analog_locked:1,
98886 original_mute:2;
98887 - int open_count;
98888 + local_t open_count;
98889 struct codec_info *codec_info;
98890
98891 /* mutex serializes concurrent access to the device
98892 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
98893 struct onyx *onyx = cii->codec_data;
98894
98895 mutex_lock(&onyx->mutex);
98896 - onyx->open_count++;
98897 + local_inc(&onyx->open_count);
98898 mutex_unlock(&onyx->mutex);
98899
98900 return 0;
98901 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
98902 struct onyx *onyx = cii->codec_data;
98903
98904 mutex_lock(&onyx->mutex);
98905 - onyx->open_count--;
98906 - if (!onyx->open_count)
98907 + if (local_dec_and_test(&onyx->open_count))
98908 onyx->spdif_locked = onyx->analog_locked = 0;
98909 mutex_unlock(&onyx->mutex);
98910
98911 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
98912 index ffd2025..df062c9 100644
98913 --- a/sound/aoa/codecs/onyx.h
98914 +++ b/sound/aoa/codecs/onyx.h
98915 @@ -11,6 +11,7 @@
98916 #include <linux/i2c.h>
98917 #include <asm/pmac_low_i2c.h>
98918 #include <asm/prom.h>
98919 +#include <asm/local.h>
98920
98921 /* PCM3052 register definitions */
98922
98923 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
98924 index 4c1cc51..16040040 100644
98925 --- a/sound/core/oss/pcm_oss.c
98926 +++ b/sound/core/oss/pcm_oss.c
98927 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
98928 if (in_kernel) {
98929 mm_segment_t fs;
98930 fs = snd_enter_user();
98931 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
98932 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
98933 snd_leave_user(fs);
98934 } else {
98935 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
98936 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
98937 }
98938 if (ret != -EPIPE && ret != -ESTRPIPE)
98939 break;
98940 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
98941 if (in_kernel) {
98942 mm_segment_t fs;
98943 fs = snd_enter_user();
98944 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
98945 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
98946 snd_leave_user(fs);
98947 } else {
98948 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
98949 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
98950 }
98951 if (ret == -EPIPE) {
98952 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
98953 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
98954 struct snd_pcm_plugin_channel *channels;
98955 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
98956 if (!in_kernel) {
98957 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
98958 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
98959 return -EFAULT;
98960 buf = runtime->oss.buffer;
98961 }
98962 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
98963 }
98964 } else {
98965 tmp = snd_pcm_oss_write2(substream,
98966 - (const char __force *)buf,
98967 + (const char __force_kernel *)buf,
98968 runtime->oss.period_bytes, 0);
98969 if (tmp <= 0)
98970 goto err;
98971 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
98972 struct snd_pcm_runtime *runtime = substream->runtime;
98973 snd_pcm_sframes_t frames, frames1;
98974 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
98975 - char __user *final_dst = (char __force __user *)buf;
98976 + char __user *final_dst = (char __force_user *)buf;
98977 if (runtime->oss.plugin_first) {
98978 struct snd_pcm_plugin_channel *channels;
98979 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
98980 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
98981 xfer += tmp;
98982 runtime->oss.buffer_used -= tmp;
98983 } else {
98984 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
98985 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
98986 runtime->oss.period_bytes, 0);
98987 if (tmp <= 0)
98988 goto err;
98989 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
98990 size1);
98991 size1 /= runtime->channels; /* frames */
98992 fs = snd_enter_user();
98993 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
98994 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
98995 snd_leave_user(fs);
98996 }
98997 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
98998 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
98999 index af49721..e85058e 100644
99000 --- a/sound/core/pcm_compat.c
99001 +++ b/sound/core/pcm_compat.c
99002 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99003 int err;
99004
99005 fs = snd_enter_user();
99006 - err = snd_pcm_delay(substream, &delay);
99007 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99008 snd_leave_user(fs);
99009 if (err < 0)
99010 return err;
99011 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99012 index a68d4c6..72af3cf 100644
99013 --- a/sound/core/pcm_native.c
99014 +++ b/sound/core/pcm_native.c
99015 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99016 switch (substream->stream) {
99017 case SNDRV_PCM_STREAM_PLAYBACK:
99018 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99019 - (void __user *)arg);
99020 + (void __force_user *)arg);
99021 break;
99022 case SNDRV_PCM_STREAM_CAPTURE:
99023 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99024 - (void __user *)arg);
99025 + (void __force_user *)arg);
99026 break;
99027 default:
99028 result = -EINVAL;
99029 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99030 index 040c60e..989a19a 100644
99031 --- a/sound/core/seq/seq_device.c
99032 +++ b/sound/core/seq/seq_device.c
99033 @@ -64,7 +64,7 @@ struct ops_list {
99034 int argsize; /* argument size */
99035
99036 /* operators */
99037 - struct snd_seq_dev_ops ops;
99038 + struct snd_seq_dev_ops *ops;
99039
99040 /* registered devices */
99041 struct list_head dev_list; /* list of devices */
99042 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99043
99044 mutex_lock(&ops->reg_mutex);
99045 /* copy driver operators */
99046 - ops->ops = *entry;
99047 + ops->ops = entry;
99048 ops->driver |= DRIVER_LOADED;
99049 ops->argsize = argsize;
99050
99051 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99052 dev->name, ops->id, ops->argsize, dev->argsize);
99053 return -EINVAL;
99054 }
99055 - if (ops->ops.init_device(dev) >= 0) {
99056 + if (ops->ops->init_device(dev) >= 0) {
99057 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99058 ops->num_init_devices++;
99059 } else {
99060 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99061 dev->name, ops->id, ops->argsize, dev->argsize);
99062 return -EINVAL;
99063 }
99064 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99065 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99066 dev->status = SNDRV_SEQ_DEVICE_FREE;
99067 dev->driver_data = NULL;
99068 ops->num_init_devices--;
99069 diff --git a/sound/core/sound.c b/sound/core/sound.c
99070 index f002bd9..c462985 100644
99071 --- a/sound/core/sound.c
99072 +++ b/sound/core/sound.c
99073 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99074 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99075 default: return;
99076 }
99077 - request_module(str);
99078 + request_module("%s", str);
99079 }
99080
99081 #endif /* modular kernel */
99082 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99083 index 4e0dd22..7a1f32c 100644
99084 --- a/sound/drivers/mts64.c
99085 +++ b/sound/drivers/mts64.c
99086 @@ -29,6 +29,7 @@
99087 #include <sound/initval.h>
99088 #include <sound/rawmidi.h>
99089 #include <sound/control.h>
99090 +#include <asm/local.h>
99091
99092 #define CARD_NAME "Miditerminal 4140"
99093 #define DRIVER_NAME "MTS64"
99094 @@ -67,7 +68,7 @@ struct mts64 {
99095 struct pardevice *pardev;
99096 int pardev_claimed;
99097
99098 - int open_count;
99099 + local_t open_count;
99100 int current_midi_output_port;
99101 int current_midi_input_port;
99102 u8 mode[MTS64_NUM_INPUT_PORTS];
99103 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99104 {
99105 struct mts64 *mts = substream->rmidi->private_data;
99106
99107 - if (mts->open_count == 0) {
99108 + if (local_read(&mts->open_count) == 0) {
99109 /* We don't need a spinlock here, because this is just called
99110 if the device has not been opened before.
99111 So there aren't any IRQs from the device */
99112 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99113
99114 msleep(50);
99115 }
99116 - ++(mts->open_count);
99117 + local_inc(&mts->open_count);
99118
99119 return 0;
99120 }
99121 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99122 struct mts64 *mts = substream->rmidi->private_data;
99123 unsigned long flags;
99124
99125 - --(mts->open_count);
99126 - if (mts->open_count == 0) {
99127 + if (local_dec_return(&mts->open_count) == 0) {
99128 /* We need the spinlock_irqsave here because we can still
99129 have IRQs at this point */
99130 spin_lock_irqsave(&mts->lock, flags);
99131 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99132
99133 msleep(500);
99134
99135 - } else if (mts->open_count < 0)
99136 - mts->open_count = 0;
99137 + } else if (local_read(&mts->open_count) < 0)
99138 + local_set(&mts->open_count, 0);
99139
99140 return 0;
99141 }
99142 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99143 index b953fb4..1999c01 100644
99144 --- a/sound/drivers/opl4/opl4_lib.c
99145 +++ b/sound/drivers/opl4/opl4_lib.c
99146 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99147 MODULE_DESCRIPTION("OPL4 driver");
99148 MODULE_LICENSE("GPL");
99149
99150 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99151 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99152 {
99153 int timeout = 10;
99154 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99155 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99156 index 991018d..8984740 100644
99157 --- a/sound/drivers/portman2x4.c
99158 +++ b/sound/drivers/portman2x4.c
99159 @@ -48,6 +48,7 @@
99160 #include <sound/initval.h>
99161 #include <sound/rawmidi.h>
99162 #include <sound/control.h>
99163 +#include <asm/local.h>
99164
99165 #define CARD_NAME "Portman 2x4"
99166 #define DRIVER_NAME "portman"
99167 @@ -85,7 +86,7 @@ struct portman {
99168 struct pardevice *pardev;
99169 int pardev_claimed;
99170
99171 - int open_count;
99172 + local_t open_count;
99173 int mode[PORTMAN_NUM_INPUT_PORTS];
99174 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99175 };
99176 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99177 index ea995af..f1bfa37 100644
99178 --- a/sound/firewire/amdtp.c
99179 +++ b/sound/firewire/amdtp.c
99180 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99181 ptr = s->pcm_buffer_pointer + data_blocks;
99182 if (ptr >= pcm->runtime->buffer_size)
99183 ptr -= pcm->runtime->buffer_size;
99184 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99185 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99186
99187 s->pcm_period_pointer += data_blocks;
99188 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99189 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99190 */
99191 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99192 {
99193 - ACCESS_ONCE(s->source_node_id_field) =
99194 + ACCESS_ONCE_RW(s->source_node_id_field) =
99195 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99196 }
99197 EXPORT_SYMBOL(amdtp_out_stream_update);
99198 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99199 index f6103d6..4843fbf 100644
99200 --- a/sound/firewire/amdtp.h
99201 +++ b/sound/firewire/amdtp.h
99202 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99203 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99204 struct snd_pcm_substream *pcm)
99205 {
99206 - ACCESS_ONCE(s->pcm) = pcm;
99207 + ACCESS_ONCE_RW(s->pcm) = pcm;
99208 }
99209
99210 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99211 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99212 index 58a5afe..af5bd64 100644
99213 --- a/sound/firewire/isight.c
99214 +++ b/sound/firewire/isight.c
99215 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99216 ptr += count;
99217 if (ptr >= runtime->buffer_size)
99218 ptr -= runtime->buffer_size;
99219 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99220 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99221
99222 isight->period_counter += count;
99223 if (isight->period_counter >= runtime->period_size) {
99224 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99225 if (err < 0)
99226 return err;
99227
99228 - ACCESS_ONCE(isight->pcm_active) = true;
99229 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99230
99231 return 0;
99232 }
99233 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99234 {
99235 struct isight *isight = substream->private_data;
99236
99237 - ACCESS_ONCE(isight->pcm_active) = false;
99238 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99239
99240 mutex_lock(&isight->mutex);
99241 isight_stop_streaming(isight);
99242 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99243
99244 switch (cmd) {
99245 case SNDRV_PCM_TRIGGER_START:
99246 - ACCESS_ONCE(isight->pcm_running) = true;
99247 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99248 break;
99249 case SNDRV_PCM_TRIGGER_STOP:
99250 - ACCESS_ONCE(isight->pcm_running) = false;
99251 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99252 break;
99253 default:
99254 return -EINVAL;
99255 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99256 index 505fc81..62e569e 100644
99257 --- a/sound/firewire/scs1x.c
99258 +++ b/sound/firewire/scs1x.c
99259 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99260 {
99261 struct scs *scs = stream->rmidi->private_data;
99262
99263 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99264 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99265 if (up) {
99266 scs->output_idle = false;
99267 tasklet_schedule(&scs->tasklet);
99268 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99269 {
99270 struct scs *scs = stream->rmidi->private_data;
99271
99272 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99273 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99274 }
99275
99276 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99277 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99278
99279 snd_card_disconnect(scs->card);
99280
99281 - ACCESS_ONCE(scs->output) = NULL;
99282 - ACCESS_ONCE(scs->input) = NULL;
99283 + ACCESS_ONCE_RW(scs->output) = NULL;
99284 + ACCESS_ONCE_RW(scs->input) = NULL;
99285
99286 wait_event(scs->idle_wait, scs->output_idle);
99287
99288 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99289 index 048439a..3be9f6f 100644
99290 --- a/sound/oss/sb_audio.c
99291 +++ b/sound/oss/sb_audio.c
99292 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
99293 buf16 = (signed short *)(localbuf + localoffs);
99294 while (c)
99295 {
99296 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99297 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99298 if (copy_from_user(lbuf8,
99299 userbuf+useroffs + p,
99300 locallen))
99301 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
99302 index 7d8803a..559f8d0 100644
99303 --- a/sound/oss/swarm_cs4297a.c
99304 +++ b/sound/oss/swarm_cs4297a.c
99305 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
99306 {
99307 struct cs4297a_state *s;
99308 u32 pwr, id;
99309 - mm_segment_t fs;
99310 int rval;
99311 #ifndef CONFIG_BCM_CS4297A_CSWARM
99312 u64 cfg;
99313 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
99314 if (!rval) {
99315 char *sb1250_duart_present;
99316
99317 +#if 0
99318 + mm_segment_t fs;
99319 fs = get_fs();
99320 set_fs(KERNEL_DS);
99321 -#if 0
99322 val = SOUND_MASK_LINE;
99323 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
99324 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
99325 val = initvol[i].vol;
99326 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
99327 }
99328 + set_fs(fs);
99329 // cs4297a_write_ac97(s, 0x18, 0x0808);
99330 #else
99331 // cs4297a_write_ac97(s, 0x5e, 0x180);
99332 cs4297a_write_ac97(s, 0x02, 0x0808);
99333 cs4297a_write_ac97(s, 0x18, 0x0808);
99334 #endif
99335 - set_fs(fs);
99336
99337 list_add(&s->list, &cs4297a_devs);
99338
99339 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
99340 index 8a005f0..4fe3059 100644
99341 --- a/sound/pci/hda/hda_codec.c
99342 +++ b/sound/pci/hda/hda_codec.c
99343 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
99344 mutex_unlock(&preset_mutex);
99345
99346 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
99347 - char name[32];
99348 if (!mod_requested)
99349 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
99350 - codec->vendor_id);
99351 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
99352 else
99353 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
99354 - (codec->vendor_id >> 16) & 0xffff);
99355 - request_module(name);
99356 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
99357 mod_requested++;
99358 goto again;
99359 }
99360 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
99361 index 4631a23..001ae57 100644
99362 --- a/sound/pci/ymfpci/ymfpci.h
99363 +++ b/sound/pci/ymfpci/ymfpci.h
99364 @@ -358,7 +358,7 @@ struct snd_ymfpci {
99365 spinlock_t reg_lock;
99366 spinlock_t voice_lock;
99367 wait_queue_head_t interrupt_sleep;
99368 - atomic_t interrupt_sleep_count;
99369 + atomic_unchecked_t interrupt_sleep_count;
99370 struct snd_info_entry *proc_entry;
99371 const struct firmware *dsp_microcode;
99372 const struct firmware *controller_microcode;
99373 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
99374 index d591c15..8cb8f94 100644
99375 --- a/sound/pci/ymfpci/ymfpci_main.c
99376 +++ b/sound/pci/ymfpci/ymfpci_main.c
99377 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
99378 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
99379 break;
99380 }
99381 - if (atomic_read(&chip->interrupt_sleep_count)) {
99382 - atomic_set(&chip->interrupt_sleep_count, 0);
99383 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99384 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99385 wake_up(&chip->interrupt_sleep);
99386 }
99387 __end:
99388 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
99389 continue;
99390 init_waitqueue_entry(&wait, current);
99391 add_wait_queue(&chip->interrupt_sleep, &wait);
99392 - atomic_inc(&chip->interrupt_sleep_count);
99393 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
99394 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
99395 remove_wait_queue(&chip->interrupt_sleep, &wait);
99396 }
99397 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
99398 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
99399 spin_unlock(&chip->reg_lock);
99400
99401 - if (atomic_read(&chip->interrupt_sleep_count)) {
99402 - atomic_set(&chip->interrupt_sleep_count, 0);
99403 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99404 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99405 wake_up(&chip->interrupt_sleep);
99406 }
99407 }
99408 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
99409 spin_lock_init(&chip->reg_lock);
99410 spin_lock_init(&chip->voice_lock);
99411 init_waitqueue_head(&chip->interrupt_sleep);
99412 - atomic_set(&chip->interrupt_sleep_count, 0);
99413 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99414 chip->card = card;
99415 chip->pci = pci;
99416 chip->irq = -1;
99417 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
99418 index 2f2d837..3e3f1f6 100644
99419 --- a/sound/soc/fsl/fsl_ssi.c
99420 +++ b/sound/soc/fsl/fsl_ssi.c
99421 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
99422 {
99423 struct fsl_ssi_private *ssi_private;
99424 int ret = 0;
99425 - struct device_attribute *dev_attr = NULL;
99426 + device_attribute_no_const *dev_attr = NULL;
99427 struct device_node *np = pdev->dev.of_node;
99428 const char *p, *sprop;
99429 const uint32_t *iprop;
99430 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
99431 new file mode 100644
99432 index 0000000..50f2f2f
99433 --- /dev/null
99434 +++ b/tools/gcc/.gitignore
99435 @@ -0,0 +1 @@
99436 +size_overflow_hash.h
99437 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
99438 new file mode 100644
99439 index 0000000..144dbee
99440 --- /dev/null
99441 +++ b/tools/gcc/Makefile
99442 @@ -0,0 +1,45 @@
99443 +#CC := gcc
99444 +#PLUGIN_SOURCE_FILES := pax_plugin.c
99445 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
99446 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
99447 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
99448 +
99449 +ifeq ($(PLUGINCC),$(HOSTCC))
99450 +HOSTLIBS := hostlibs
99451 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
99452 +else
99453 +HOSTLIBS := hostcxxlibs
99454 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
99455 +endif
99456 +
99457 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
99458 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
99459 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
99460 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
99461 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
99462 +$(HOSTLIBS)-y += colorize_plugin.so
99463 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
99464 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
99465 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
99466 +
99467 +always := $($(HOSTLIBS)-y)
99468 +
99469 +constify_plugin-objs := constify_plugin.o
99470 +stackleak_plugin-objs := stackleak_plugin.o
99471 +kallocstat_plugin-objs := kallocstat_plugin.o
99472 +kernexec_plugin-objs := kernexec_plugin.o
99473 +checker_plugin-objs := checker_plugin.o
99474 +colorize_plugin-objs := colorize_plugin.o
99475 +size_overflow_plugin-objs := size_overflow_plugin.o
99476 +latent_entropy_plugin-objs := latent_entropy_plugin.o
99477 +structleak_plugin-objs := structleak_plugin.o
99478 +
99479 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
99480 +
99481 +quiet_cmd_build_size_overflow_hash = GENHASH $@
99482 + cmd_build_size_overflow_hash = \
99483 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
99484 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
99485 + $(call if_changed,build_size_overflow_hash)
99486 +
99487 +targets += size_overflow_hash.h
99488 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
99489 new file mode 100644
99490 index 0000000..22f03c0
99491 --- /dev/null
99492 +++ b/tools/gcc/checker_plugin.c
99493 @@ -0,0 +1,172 @@
99494 +/*
99495 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
99496 + * Licensed under the GPL v2
99497 + *
99498 + * Note: the choice of the license means that the compilation process is
99499 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99500 + * but for the kernel it doesn't matter since it doesn't link against
99501 + * any of the gcc libraries
99502 + *
99503 + * gcc plugin to implement various sparse (source code checker) features
99504 + *
99505 + * TODO:
99506 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
99507 + *
99508 + * BUGS:
99509 + * - none known
99510 + */
99511 +#include "gcc-plugin.h"
99512 +#include "config.h"
99513 +#include "system.h"
99514 +#include "coretypes.h"
99515 +#include "tree.h"
99516 +#include "tree-pass.h"
99517 +#include "flags.h"
99518 +#include "intl.h"
99519 +#include "toplev.h"
99520 +#include "plugin.h"
99521 +//#include "expr.h" where are you...
99522 +#include "diagnostic.h"
99523 +#include "plugin-version.h"
99524 +#include "tm.h"
99525 +#include "function.h"
99526 +#include "basic-block.h"
99527 +#include "gimple.h"
99528 +#include "rtl.h"
99529 +#include "emit-rtl.h"
99530 +#include "tree-flow.h"
99531 +#include "target.h"
99532 +
99533 +extern void c_register_addr_space (const char *str, addr_space_t as);
99534 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
99535 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
99536 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
99537 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
99538 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
99539 +
99540 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99541 +extern rtx emit_move_insn(rtx x, rtx y);
99542 +
99543 +int plugin_is_GPL_compatible;
99544 +
99545 +static struct plugin_info checker_plugin_info = {
99546 + .version = "201111150100",
99547 + .help = NULL,
99548 +};
99549 +
99550 +#define ADDR_SPACE_KERNEL 0
99551 +#define ADDR_SPACE_FORCE_KERNEL 1
99552 +#define ADDR_SPACE_USER 2
99553 +#define ADDR_SPACE_FORCE_USER 3
99554 +#define ADDR_SPACE_IOMEM 0
99555 +#define ADDR_SPACE_FORCE_IOMEM 0
99556 +#define ADDR_SPACE_PERCPU 0
99557 +#define ADDR_SPACE_FORCE_PERCPU 0
99558 +#define ADDR_SPACE_RCU 0
99559 +#define ADDR_SPACE_FORCE_RCU 0
99560 +
99561 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
99562 +{
99563 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
99564 +}
99565 +
99566 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
99567 +{
99568 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
99569 +}
99570 +
99571 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
99572 +{
99573 + return default_addr_space_valid_pointer_mode(mode, as);
99574 +}
99575 +
99576 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
99577 +{
99578 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
99579 +}
99580 +
99581 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
99582 +{
99583 + return default_addr_space_legitimize_address(x, oldx, mode, as);
99584 +}
99585 +
99586 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
99587 +{
99588 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
99589 + return true;
99590 +
99591 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
99592 + return true;
99593 +
99594 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
99595 + return true;
99596 +
99597 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
99598 + return true;
99599 +
99600 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
99601 + return true;
99602 +
99603 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
99604 + return true;
99605 +
99606 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
99607 + return true;
99608 +
99609 + return subset == superset;
99610 +}
99611 +
99612 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
99613 +{
99614 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
99615 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
99616 +
99617 + return op;
99618 +}
99619 +
99620 +static void register_checker_address_spaces(void *event_data, void *data)
99621 +{
99622 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
99623 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
99624 + c_register_addr_space("__user", ADDR_SPACE_USER);
99625 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
99626 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
99627 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
99628 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
99629 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
99630 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
99631 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
99632 +
99633 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
99634 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
99635 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
99636 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
99637 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
99638 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
99639 + targetm.addr_space.convert = checker_addr_space_convert;
99640 +}
99641 +
99642 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99643 +{
99644 + const char * const plugin_name = plugin_info->base_name;
99645 + const int argc = plugin_info->argc;
99646 + const struct plugin_argument * const argv = plugin_info->argv;
99647 + int i;
99648 +
99649 + if (!plugin_default_version_check(version, &gcc_version)) {
99650 + error(G_("incompatible gcc/plugin versions"));
99651 + return 1;
99652 + }
99653 +
99654 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
99655 +
99656 + for (i = 0; i < argc; ++i)
99657 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99658 +
99659 + if (TARGET_64BIT == 0)
99660 + return 0;
99661 +
99662 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
99663 +
99664 + return 0;
99665 +}
99666 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
99667 new file mode 100644
99668 index 0000000..414fe5e
99669 --- /dev/null
99670 +++ b/tools/gcc/colorize_plugin.c
99671 @@ -0,0 +1,151 @@
99672 +/*
99673 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
99674 + * Licensed under the GPL v2
99675 + *
99676 + * Note: the choice of the license means that the compilation process is
99677 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99678 + * but for the kernel it doesn't matter since it doesn't link against
99679 + * any of the gcc libraries
99680 + *
99681 + * gcc plugin to colorize diagnostic output
99682 + *
99683 + */
99684 +
99685 +#include "gcc-plugin.h"
99686 +#include "config.h"
99687 +#include "system.h"
99688 +#include "coretypes.h"
99689 +#include "tree.h"
99690 +#include "tree-pass.h"
99691 +#include "flags.h"
99692 +#include "intl.h"
99693 +#include "toplev.h"
99694 +#include "plugin.h"
99695 +#include "diagnostic.h"
99696 +#include "plugin-version.h"
99697 +#include "tm.h"
99698 +
99699 +int plugin_is_GPL_compatible;
99700 +
99701 +static struct plugin_info colorize_plugin_info = {
99702 + .version = "201302112000",
99703 + .help = NULL,
99704 +};
99705 +
99706 +#define GREEN "\033[32m\033[2m"
99707 +#define LIGHTGREEN "\033[32m\033[1m"
99708 +#define YELLOW "\033[33m\033[2m"
99709 +#define LIGHTYELLOW "\033[33m\033[1m"
99710 +#define RED "\033[31m\033[2m"
99711 +#define LIGHTRED "\033[31m\033[1m"
99712 +#define BLUE "\033[34m\033[2m"
99713 +#define LIGHTBLUE "\033[34m\033[1m"
99714 +#define BRIGHT "\033[m\033[1m"
99715 +#define NORMAL "\033[m"
99716 +
99717 +static diagnostic_starter_fn old_starter;
99718 +static diagnostic_finalizer_fn old_finalizer;
99719 +
99720 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99721 +{
99722 + const char *color;
99723 + char *newprefix;
99724 +
99725 + switch (diagnostic->kind) {
99726 + case DK_NOTE:
99727 + color = LIGHTBLUE;
99728 + break;
99729 +
99730 + case DK_PEDWARN:
99731 + case DK_WARNING:
99732 + color = LIGHTYELLOW;
99733 + break;
99734 +
99735 + case DK_ERROR:
99736 + case DK_FATAL:
99737 + case DK_ICE:
99738 + case DK_PERMERROR:
99739 + case DK_SORRY:
99740 + color = LIGHTRED;
99741 + break;
99742 +
99743 + default:
99744 + color = NORMAL;
99745 + }
99746 +
99747 + old_starter(context, diagnostic);
99748 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
99749 + return;
99750 + pp_destroy_prefix(context->printer);
99751 + pp_set_prefix(context->printer, newprefix);
99752 +}
99753 +
99754 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99755 +{
99756 + old_finalizer(context, diagnostic);
99757 +}
99758 +
99759 +static void colorize_arm(void)
99760 +{
99761 + old_starter = diagnostic_starter(global_dc);
99762 + old_finalizer = diagnostic_finalizer(global_dc);
99763 +
99764 + diagnostic_starter(global_dc) = start_colorize;
99765 + diagnostic_finalizer(global_dc) = finalize_colorize;
99766 +}
99767 +
99768 +static unsigned int execute_colorize_rearm(void)
99769 +{
99770 + if (diagnostic_starter(global_dc) == start_colorize)
99771 + return 0;
99772 +
99773 + colorize_arm();
99774 + return 0;
99775 +}
99776 +
99777 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
99778 + .pass = {
99779 + .type = SIMPLE_IPA_PASS,
99780 + .name = "colorize_rearm",
99781 +#if BUILDING_GCC_VERSION >= 4008
99782 + .optinfo_flags = OPTGROUP_NONE,
99783 +#endif
99784 + .gate = NULL,
99785 + .execute = execute_colorize_rearm,
99786 + .sub = NULL,
99787 + .next = NULL,
99788 + .static_pass_number = 0,
99789 + .tv_id = TV_NONE,
99790 + .properties_required = 0,
99791 + .properties_provided = 0,
99792 + .properties_destroyed = 0,
99793 + .todo_flags_start = 0,
99794 + .todo_flags_finish = 0
99795 + }
99796 +};
99797 +
99798 +static void colorize_start_unit(void *gcc_data, void *user_data)
99799 +{
99800 + colorize_arm();
99801 +}
99802 +
99803 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99804 +{
99805 + const char * const plugin_name = plugin_info->base_name;
99806 + struct register_pass_info colorize_rearm_pass_info = {
99807 + .pass = &pass_ipa_colorize_rearm.pass,
99808 + .reference_pass_name = "*free_lang_data",
99809 + .ref_pass_instance_number = 1,
99810 + .pos_op = PASS_POS_INSERT_AFTER
99811 + };
99812 +
99813 + if (!plugin_default_version_check(version, &gcc_version)) {
99814 + error(G_("incompatible gcc/plugin versions"));
99815 + return 1;
99816 + }
99817 +
99818 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
99819 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
99820 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
99821 + return 0;
99822 +}
99823 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
99824 new file mode 100644
99825 index 0000000..c17312d
99826 --- /dev/null
99827 +++ b/tools/gcc/constify_plugin.c
99828 @@ -0,0 +1,560 @@
99829 +/*
99830 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
99831 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
99832 + * Licensed under the GPL v2, or (at your option) v3
99833 + *
99834 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
99835 + *
99836 + * Homepage:
99837 + * http://www.grsecurity.net/~ephox/const_plugin/
99838 + *
99839 + * Usage:
99840 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
99841 + * $ gcc -fplugin=constify_plugin.so test.c -O2
99842 + */
99843 +
99844 +#include "gcc-plugin.h"
99845 +#include "config.h"
99846 +#include "system.h"
99847 +#include "coretypes.h"
99848 +#include "tree.h"
99849 +#include "tree-pass.h"
99850 +#include "flags.h"
99851 +#include "intl.h"
99852 +#include "toplev.h"
99853 +#include "plugin.h"
99854 +#include "diagnostic.h"
99855 +#include "plugin-version.h"
99856 +#include "tm.h"
99857 +#include "function.h"
99858 +#include "basic-block.h"
99859 +#include "gimple.h"
99860 +#include "rtl.h"
99861 +#include "emit-rtl.h"
99862 +#include "tree-flow.h"
99863 +#include "target.h"
99864 +#include "langhooks.h"
99865 +
99866 +// should come from c-tree.h if only it were installed for gcc 4.5...
99867 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
99868 +
99869 +// unused type flag in all versions 4.5-4.8
99870 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
99871 +
99872 +int plugin_is_GPL_compatible;
99873 +
99874 +static struct plugin_info const_plugin_info = {
99875 + .version = "201305231310",
99876 + .help = "no-constify\tturn off constification\n",
99877 +};
99878 +
99879 +typedef struct {
99880 + bool has_fptr_field;
99881 + bool has_writable_field;
99882 + bool has_do_const_field;
99883 + bool has_no_const_field;
99884 +} constify_info;
99885 +
99886 +static const_tree get_field_type(const_tree field)
99887 +{
99888 + return strip_array_types(TREE_TYPE(field));
99889 +}
99890 +
99891 +static bool is_fptr(const_tree field)
99892 +{
99893 + const_tree ptr = get_field_type(field);
99894 +
99895 + if (TREE_CODE(ptr) != POINTER_TYPE)
99896 + return false;
99897 +
99898 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
99899 +}
99900 +
99901 +/*
99902 + * determine whether the given structure type meets the requirements for automatic constification,
99903 + * including the constification attributes on nested structure types
99904 + */
99905 +static void constifiable(const_tree node, constify_info *cinfo)
99906 +{
99907 + const_tree field;
99908 +
99909 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
99910 +
99911 + // e.g., pointer to structure fields while still constructing the structure type
99912 + if (TYPE_FIELDS(node) == NULL_TREE)
99913 + return;
99914 +
99915 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
99916 + const_tree type = get_field_type(field);
99917 + enum tree_code code = TREE_CODE(type);
99918 +
99919 + if (node == type)
99920 + continue;
99921 +
99922 + if (is_fptr(field))
99923 + cinfo->has_fptr_field = true;
99924 + else if (!TREE_READONLY(field))
99925 + cinfo->has_writable_field = true;
99926 +
99927 + if (code == RECORD_TYPE || code == UNION_TYPE) {
99928 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99929 + cinfo->has_do_const_field = true;
99930 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
99931 + cinfo->has_no_const_field = true;
99932 + else
99933 + constifiable(type, cinfo);
99934 + }
99935 + }
99936 +}
99937 +
99938 +static bool constified(const_tree node)
99939 +{
99940 + constify_info cinfo = {
99941 + .has_fptr_field = false,
99942 + .has_writable_field = false,
99943 + .has_do_const_field = false,
99944 + .has_no_const_field = false
99945 + };
99946 +
99947 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
99948 +
99949 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
99950 + gcc_assert(!TYPE_READONLY(node));
99951 + return false;
99952 + }
99953 +
99954 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
99955 + gcc_assert(TYPE_READONLY(node));
99956 + return true;
99957 + }
99958 +
99959 + constifiable(node, &cinfo);
99960 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
99961 + return false;
99962 +
99963 + return TYPE_READONLY(node);
99964 +}
99965 +
99966 +static void deconstify_tree(tree node);
99967 +
99968 +static void deconstify_type(tree type)
99969 +{
99970 + tree field;
99971 +
99972 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
99973 +
99974 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
99975 + const_tree fieldtype = get_field_type(field);
99976 +
99977 + // special case handling of simple ptr-to-same-array-type members
99978 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
99979 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
99980 +
99981 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
99982 + continue;
99983 + if (TREE_TYPE(TREE_TYPE(field)) == type)
99984 + continue;
99985 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
99986 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
99987 + TREE_TYPE(TREE_TYPE(field)) = type;
99988 + }
99989 + continue;
99990 + }
99991 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
99992 + continue;
99993 + if (!constified(fieldtype))
99994 + continue;
99995 +
99996 + deconstify_tree(field);
99997 + TREE_READONLY(field) = 0;
99998 + }
99999 + TYPE_READONLY(type) = 0;
100000 + C_TYPE_FIELDS_READONLY(type) = 0;
100001 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100002 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100003 +}
100004 +
100005 +static void deconstify_tree(tree node)
100006 +{
100007 + tree old_type, new_type, field;
100008 +
100009 + old_type = TREE_TYPE(node);
100010 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100011 + node = TREE_TYPE(node) = copy_node(old_type);
100012 + old_type = TREE_TYPE(old_type);
100013 + }
100014 +
100015 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100016 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100017 +
100018 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100019 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100020 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100021 + DECL_FIELD_CONTEXT(field) = new_type;
100022 +
100023 + deconstify_type(new_type);
100024 +
100025 + TREE_TYPE(node) = new_type;
100026 +}
100027 +
100028 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100029 +{
100030 + tree type;
100031 + constify_info cinfo = {
100032 + .has_fptr_field = false,
100033 + .has_writable_field = false,
100034 + .has_do_const_field = false,
100035 + .has_no_const_field = false
100036 + };
100037 +
100038 + *no_add_attrs = true;
100039 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100040 + error("%qE attribute does not apply to functions", name);
100041 + return NULL_TREE;
100042 + }
100043 +
100044 + if (TREE_CODE(*node) == PARM_DECL) {
100045 + error("%qE attribute does not apply to function parameters", name);
100046 + return NULL_TREE;
100047 + }
100048 +
100049 + if (TREE_CODE(*node) == VAR_DECL) {
100050 + error("%qE attribute does not apply to variables", name);
100051 + return NULL_TREE;
100052 + }
100053 +
100054 + if (TYPE_P(*node)) {
100055 + *no_add_attrs = false;
100056 + type = *node;
100057 + } else {
100058 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100059 + type = TREE_TYPE(*node);
100060 + }
100061 +
100062 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100063 + error("%qE attribute applies to struct and union types only", name);
100064 + return NULL_TREE;
100065 + }
100066 +
100067 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100068 + error("%qE attribute is already applied to the type", name);
100069 + return NULL_TREE;
100070 + }
100071 +
100072 + if (TYPE_P(*node)) {
100073 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100074 + error("%qE attribute is incompatible with 'do_const'", name);
100075 + return NULL_TREE;
100076 + }
100077 +
100078 + constifiable(type, &cinfo);
100079 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100080 + deconstify_tree(*node);
100081 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100082 + return NULL_TREE;
100083 + }
100084 +
100085 + error("%qE attribute used on type that is not constified", name);
100086 + return NULL_TREE;
100087 +}
100088 +
100089 +static void constify_type(tree type)
100090 +{
100091 + TYPE_READONLY(type) = 1;
100092 + C_TYPE_FIELDS_READONLY(type) = 1;
100093 + TYPE_CONSTIFY_VISITED(type) = 1;
100094 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100095 +}
100096 +
100097 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100098 +{
100099 + *no_add_attrs = true;
100100 + if (!TYPE_P(*node)) {
100101 + error("%qE attribute applies to types only", name);
100102 + return NULL_TREE;
100103 + }
100104 +
100105 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100106 + error("%qE attribute applies to struct and union types only", name);
100107 + return NULL_TREE;
100108 + }
100109 +
100110 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100111 + error("%qE attribute is already applied to the type", name);
100112 + return NULL_TREE;
100113 + }
100114 +
100115 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100116 + error("%qE attribute is incompatible with 'no_const'", name);
100117 + return NULL_TREE;
100118 + }
100119 +
100120 + *no_add_attrs = false;
100121 + return NULL_TREE;
100122 +}
100123 +
100124 +static struct attribute_spec no_const_attr = {
100125 + .name = "no_const",
100126 + .min_length = 0,
100127 + .max_length = 0,
100128 + .decl_required = false,
100129 + .type_required = false,
100130 + .function_type_required = false,
100131 + .handler = handle_no_const_attribute,
100132 +#if BUILDING_GCC_VERSION >= 4007
100133 + .affects_type_identity = true
100134 +#endif
100135 +};
100136 +
100137 +static struct attribute_spec do_const_attr = {
100138 + .name = "do_const",
100139 + .min_length = 0,
100140 + .max_length = 0,
100141 + .decl_required = false,
100142 + .type_required = false,
100143 + .function_type_required = false,
100144 + .handler = handle_do_const_attribute,
100145 +#if BUILDING_GCC_VERSION >= 4007
100146 + .affects_type_identity = true
100147 +#endif
100148 +};
100149 +
100150 +static void register_attributes(void *event_data, void *data)
100151 +{
100152 + register_attribute(&no_const_attr);
100153 + register_attribute(&do_const_attr);
100154 +}
100155 +
100156 +static void finish_type(void *event_data, void *data)
100157 +{
100158 + tree type = (tree)event_data;
100159 + constify_info cinfo = {
100160 + .has_fptr_field = false,
100161 + .has_writable_field = false,
100162 + .has_do_const_field = false,
100163 + .has_no_const_field = false
100164 + };
100165 +
100166 + if (type == NULL_TREE || type == error_mark_node)
100167 + return;
100168 +
100169 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100170 + return;
100171 +
100172 + constifiable(type, &cinfo);
100173 +
100174 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100175 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100176 + return;
100177 + if (cinfo.has_writable_field)
100178 + return;
100179 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100180 + return;
100181 + }
100182 +
100183 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100184 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100185 + deconstify_type(type);
100186 + TYPE_CONSTIFY_VISITED(type) = 1;
100187 + } else
100188 + error("'no_const' attribute used on type that is not constified");
100189 + return;
100190 + }
100191 +
100192 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100193 + constify_type(type);
100194 + return;
100195 + }
100196 +
100197 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100198 + constify_type(type);
100199 + return;
100200 + }
100201 +
100202 + deconstify_type(type);
100203 + TYPE_CONSTIFY_VISITED(type) = 1;
100204 +}
100205 +
100206 +static void check_global_variables(void)
100207 +{
100208 + struct varpool_node *node;
100209 +
100210 +#if BUILDING_GCC_VERSION <= 4007
100211 + for (node = varpool_nodes; node; node = node->next) {
100212 + tree var = node->decl;
100213 +#else
100214 + FOR_EACH_VARIABLE(node) {
100215 + tree var = node->symbol.decl;
100216 +#endif
100217 + tree type = TREE_TYPE(var);
100218 +
100219 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100220 + continue;
100221 +
100222 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100223 + continue;
100224 +
100225 + if (!TYPE_CONSTIFY_VISITED(type))
100226 + continue;
100227 +
100228 + if (DECL_EXTERNAL(var))
100229 + continue;
100230 +
100231 + if (DECL_INITIAL(var))
100232 + continue;
100233 +
100234 + // this works around a gcc bug/feature where uninitialized globals
100235 + // are moved into the .bss section regardless of any constification
100236 + DECL_INITIAL(var) = build_constructor(type, NULL);
100237 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100238 + }
100239 +}
100240 +
100241 +static unsigned int check_local_variables(void)
100242 +{
100243 + unsigned int ret = 0;
100244 + tree var;
100245 +
100246 +#if BUILDING_GCC_VERSION == 4005
100247 + tree vars;
100248 +#else
100249 + unsigned int i;
100250 +#endif
100251 +
100252 +#if BUILDING_GCC_VERSION == 4005
100253 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100254 + var = TREE_VALUE(vars);
100255 +#else
100256 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100257 +#endif
100258 + tree type = TREE_TYPE(var);
100259 +
100260 + gcc_assert(DECL_P(var));
100261 + if (is_global_var(var))
100262 + continue;
100263 +
100264 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100265 + continue;
100266 +
100267 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100268 + continue;
100269 +
100270 + if (!TYPE_CONSTIFY_VISITED(type))
100271 + continue;
100272 +
100273 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
100274 + ret = 1;
100275 + }
100276 + return ret;
100277 +}
100278 +
100279 +static unsigned int check_variables(void)
100280 +{
100281 + check_global_variables();
100282 + return check_local_variables();
100283 +}
100284 +
100285 + unsigned int ret = 0;
100286 +static struct gimple_opt_pass pass_local_variable = {
100287 + {
100288 + .type = GIMPLE_PASS,
100289 + .name = "check_variables",
100290 +#if BUILDING_GCC_VERSION >= 4008
100291 + .optinfo_flags = OPTGROUP_NONE,
100292 +#endif
100293 + .gate = NULL,
100294 + .execute = check_variables,
100295 + .sub = NULL,
100296 + .next = NULL,
100297 + .static_pass_number = 0,
100298 + .tv_id = TV_NONE,
100299 + .properties_required = 0,
100300 + .properties_provided = 0,
100301 + .properties_destroyed = 0,
100302 + .todo_flags_start = 0,
100303 + .todo_flags_finish = 0
100304 + }
100305 +};
100306 +
100307 +static struct {
100308 + const char *name;
100309 + const char *asm_op;
100310 +} sections[] = {
100311 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
100312 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
100313 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
100314 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
100315 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
100316 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
100317 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
100318 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
100319 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
100320 +};
100321 +
100322 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
100323 +
100324 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
100325 +{
100326 + size_t i;
100327 +
100328 + for (i = 0; i < ARRAY_SIZE(sections); i++)
100329 + if (!strcmp(sections[i].name, name))
100330 + return 0;
100331 + return old_section_type_flags(decl, name, reloc);
100332 +}
100333 +
100334 +static void constify_start_unit(void *gcc_data, void *user_data)
100335 +{
100336 +// size_t i;
100337 +
100338 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
100339 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
100340 +// sections[i].section = get_section(sections[i].name, 0, NULL);
100341 +
100342 + old_section_type_flags = targetm.section_type_flags;
100343 + targetm.section_type_flags = constify_section_type_flags;
100344 +}
100345 +
100346 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100347 +{
100348 + const char * const plugin_name = plugin_info->base_name;
100349 + const int argc = plugin_info->argc;
100350 + const struct plugin_argument * const argv = plugin_info->argv;
100351 + int i;
100352 + bool constify = true;
100353 +
100354 + struct register_pass_info local_variable_pass_info = {
100355 + .pass = &pass_local_variable.pass,
100356 + .reference_pass_name = "ssa",
100357 + .ref_pass_instance_number = 1,
100358 + .pos_op = PASS_POS_INSERT_BEFORE
100359 + };
100360 +
100361 + if (!plugin_default_version_check(version, &gcc_version)) {
100362 + error(G_("incompatible gcc/plugin versions"));
100363 + return 1;
100364 + }
100365 +
100366 + for (i = 0; i < argc; ++i) {
100367 + if (!(strcmp(argv[i].key, "no-constify"))) {
100368 + constify = false;
100369 + continue;
100370 + }
100371 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100372 + }
100373 +
100374 + if (strcmp(lang_hooks.name, "GNU C")) {
100375 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
100376 + constify = false;
100377 + }
100378 +
100379 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
100380 + if (constify) {
100381 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
100382 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
100383 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
100384 + }
100385 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
100386 +
100387 + return 0;
100388 +}
100389 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
100390 new file mode 100644
100391 index 0000000..e518932
100392 --- /dev/null
100393 +++ b/tools/gcc/generate_size_overflow_hash.sh
100394 @@ -0,0 +1,94 @@
100395 +#!/bin/bash
100396 +
100397 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
100398 +
100399 +header1="size_overflow_hash.h"
100400 +database="size_overflow_hash.data"
100401 +n=65536
100402 +
100403 +usage() {
100404 +cat <<EOF
100405 +usage: $0 options
100406 +OPTIONS:
100407 + -h|--help help
100408 + -o header file
100409 + -d database file
100410 + -n hash array size
100411 +EOF
100412 + return 0
100413 +}
100414 +
100415 +while true
100416 +do
100417 + case "$1" in
100418 + -h|--help) usage && exit 0;;
100419 + -n) n=$2; shift 2;;
100420 + -o) header1="$2"; shift 2;;
100421 + -d) database="$2"; shift 2;;
100422 + --) shift 1; break ;;
100423 + *) break ;;
100424 + esac
100425 +done
100426 +
100427 +create_defines() {
100428 + for i in `seq 0 31`
100429 + do
100430 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
100431 + done
100432 + echo >> "$header1"
100433 +}
100434 +
100435 +create_structs() {
100436 + rm -f "$header1"
100437 +
100438 + create_defines
100439 +
100440 + cat "$database" | while read data
100441 + do
100442 + data_array=($data)
100443 + struct_hash_name="${data_array[0]}"
100444 + funcn="${data_array[1]}"
100445 + params="${data_array[2]}"
100446 + next="${data_array[4]}"
100447 +
100448 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
100449 +
100450 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
100451 + echo -en "\t.param\t= " >> "$header1"
100452 + line=
100453 + for param_num in ${params//-/ };
100454 + do
100455 + line="${line}PARAM"$param_num"|"
100456 + done
100457 +
100458 + echo -e "${line%?},\n};\n" >> "$header1"
100459 + done
100460 +}
100461 +
100462 +create_headers() {
100463 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
100464 +}
100465 +
100466 +create_array_elements() {
100467 + index=0
100468 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
100469 + do
100470 + data_array=($data)
100471 + i="${data_array[3]}"
100472 + hash="${data_array[0]}"
100473 + while [[ $index -lt $i ]]
100474 + do
100475 + echo -e "\t["$index"]\t= NULL," >> "$header1"
100476 + index=$(($index + 1))
100477 + done
100478 + index=$(($index + 1))
100479 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
100480 + done
100481 + echo '};' >> $header1
100482 +}
100483 +
100484 +create_structs
100485 +create_headers
100486 +create_array_elements
100487 +
100488 +exit 0
100489 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
100490 new file mode 100644
100491 index 0000000..568b360
100492 --- /dev/null
100493 +++ b/tools/gcc/kallocstat_plugin.c
100494 @@ -0,0 +1,170 @@
100495 +/*
100496 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100497 + * Licensed under the GPL v2
100498 + *
100499 + * Note: the choice of the license means that the compilation process is
100500 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100501 + * but for the kernel it doesn't matter since it doesn't link against
100502 + * any of the gcc libraries
100503 + *
100504 + * gcc plugin to find the distribution of k*alloc sizes
100505 + *
100506 + * TODO:
100507 + *
100508 + * BUGS:
100509 + * - none known
100510 + */
100511 +#include "gcc-plugin.h"
100512 +#include "config.h"
100513 +#include "system.h"
100514 +#include "coretypes.h"
100515 +#include "tree.h"
100516 +#include "tree-pass.h"
100517 +#include "flags.h"
100518 +#include "intl.h"
100519 +#include "toplev.h"
100520 +#include "plugin.h"
100521 +//#include "expr.h" where are you...
100522 +#include "diagnostic.h"
100523 +#include "plugin-version.h"
100524 +#include "tm.h"
100525 +#include "function.h"
100526 +#include "basic-block.h"
100527 +#include "gimple.h"
100528 +#include "rtl.h"
100529 +#include "emit-rtl.h"
100530 +
100531 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100532 +
100533 +int plugin_is_GPL_compatible;
100534 +
100535 +static const char * const kalloc_functions[] = {
100536 + "__kmalloc",
100537 + "kmalloc",
100538 + "kmalloc_large",
100539 + "kmalloc_node",
100540 + "kmalloc_order",
100541 + "kmalloc_order_trace",
100542 + "kmalloc_slab",
100543 + "kzalloc",
100544 + "kzalloc_node",
100545 +};
100546 +
100547 +static struct plugin_info kallocstat_plugin_info = {
100548 + .version = "201302112000",
100549 +};
100550 +
100551 +static unsigned int execute_kallocstat(void);
100552 +
100553 +static struct gimple_opt_pass kallocstat_pass = {
100554 + .pass = {
100555 + .type = GIMPLE_PASS,
100556 + .name = "kallocstat",
100557 +#if BUILDING_GCC_VERSION >= 4008
100558 + .optinfo_flags = OPTGROUP_NONE,
100559 +#endif
100560 + .gate = NULL,
100561 + .execute = execute_kallocstat,
100562 + .sub = NULL,
100563 + .next = NULL,
100564 + .static_pass_number = 0,
100565 + .tv_id = TV_NONE,
100566 + .properties_required = 0,
100567 + .properties_provided = 0,
100568 + .properties_destroyed = 0,
100569 + .todo_flags_start = 0,
100570 + .todo_flags_finish = 0
100571 + }
100572 +};
100573 +
100574 +static bool is_kalloc(const char *fnname)
100575 +{
100576 + size_t i;
100577 +
100578 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
100579 + if (!strcmp(fnname, kalloc_functions[i]))
100580 + return true;
100581 + return false;
100582 +}
100583 +
100584 +static unsigned int execute_kallocstat(void)
100585 +{
100586 + basic_block bb;
100587 +
100588 + // 1. loop through BBs and GIMPLE statements
100589 + FOR_EACH_BB(bb) {
100590 + gimple_stmt_iterator gsi;
100591 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100592 + // gimple match:
100593 + tree fndecl, size;
100594 + gimple call_stmt;
100595 + const char *fnname;
100596 +
100597 + // is it a call
100598 + call_stmt = gsi_stmt(gsi);
100599 + if (!is_gimple_call(call_stmt))
100600 + continue;
100601 + fndecl = gimple_call_fndecl(call_stmt);
100602 + if (fndecl == NULL_TREE)
100603 + continue;
100604 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
100605 + continue;
100606 +
100607 + // is it a call to k*alloc
100608 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
100609 + if (!is_kalloc(fnname))
100610 + continue;
100611 +
100612 + // is the size arg the result of a simple const assignment
100613 + size = gimple_call_arg(call_stmt, 0);
100614 + while (true) {
100615 + gimple def_stmt;
100616 + expanded_location xloc;
100617 + size_t size_val;
100618 +
100619 + if (TREE_CODE(size) != SSA_NAME)
100620 + break;
100621 + def_stmt = SSA_NAME_DEF_STMT(size);
100622 + if (!def_stmt || !is_gimple_assign(def_stmt))
100623 + break;
100624 + if (gimple_num_ops(def_stmt) != 2)
100625 + break;
100626 + size = gimple_assign_rhs1(def_stmt);
100627 + if (!TREE_CONSTANT(size))
100628 + continue;
100629 + xloc = expand_location(gimple_location(def_stmt));
100630 + if (!xloc.file)
100631 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
100632 + size_val = TREE_INT_CST_LOW(size);
100633 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
100634 + break;
100635 + }
100636 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
100637 +//debug_tree(gimple_call_fn(call_stmt));
100638 +//print_node(stderr, "pax", fndecl, 4);
100639 + }
100640 + }
100641 +
100642 + return 0;
100643 +}
100644 +
100645 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100646 +{
100647 + const char * const plugin_name = plugin_info->base_name;
100648 + struct register_pass_info kallocstat_pass_info = {
100649 + .pass = &kallocstat_pass.pass,
100650 + .reference_pass_name = "ssa",
100651 + .ref_pass_instance_number = 1,
100652 + .pos_op = PASS_POS_INSERT_AFTER
100653 + };
100654 +
100655 + if (!plugin_default_version_check(version, &gcc_version)) {
100656 + error(G_("incompatible gcc/plugin versions"));
100657 + return 1;
100658 + }
100659 +
100660 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
100661 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
100662 +
100663 + return 0;
100664 +}
100665 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
100666 new file mode 100644
100667 index 0000000..698da67
100668 --- /dev/null
100669 +++ b/tools/gcc/kernexec_plugin.c
100670 @@ -0,0 +1,471 @@
100671 +/*
100672 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100673 + * Licensed under the GPL v2
100674 + *
100675 + * Note: the choice of the license means that the compilation process is
100676 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100677 + * but for the kernel it doesn't matter since it doesn't link against
100678 + * any of the gcc libraries
100679 + *
100680 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
100681 + *
100682 + * TODO:
100683 + *
100684 + * BUGS:
100685 + * - none known
100686 + */
100687 +#include "gcc-plugin.h"
100688 +#include "config.h"
100689 +#include "system.h"
100690 +#include "coretypes.h"
100691 +#include "tree.h"
100692 +#include "tree-pass.h"
100693 +#include "flags.h"
100694 +#include "intl.h"
100695 +#include "toplev.h"
100696 +#include "plugin.h"
100697 +//#include "expr.h" where are you...
100698 +#include "diagnostic.h"
100699 +#include "plugin-version.h"
100700 +#include "tm.h"
100701 +#include "function.h"
100702 +#include "basic-block.h"
100703 +#include "gimple.h"
100704 +#include "rtl.h"
100705 +#include "emit-rtl.h"
100706 +#include "tree-flow.h"
100707 +
100708 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100709 +extern rtx emit_move_insn(rtx x, rtx y);
100710 +
100711 +#if BUILDING_GCC_VERSION <= 4006
100712 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
100713 +#endif
100714 +
100715 +#if BUILDING_GCC_VERSION >= 4008
100716 +#define TODO_dump_func 0
100717 +#endif
100718 +
100719 +int plugin_is_GPL_compatible;
100720 +
100721 +static struct plugin_info kernexec_plugin_info = {
100722 + .version = "201308230150",
100723 + .help = "method=[bts|or]\tinstrumentation method\n"
100724 +};
100725 +
100726 +static unsigned int execute_kernexec_reload(void);
100727 +static unsigned int execute_kernexec_fptr(void);
100728 +static unsigned int execute_kernexec_retaddr(void);
100729 +static bool kernexec_cmodel_check(void);
100730 +
100731 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
100732 +static void (*kernexec_instrument_retaddr)(rtx);
100733 +
100734 +static struct gimple_opt_pass kernexec_reload_pass = {
100735 + .pass = {
100736 + .type = GIMPLE_PASS,
100737 + .name = "kernexec_reload",
100738 +#if BUILDING_GCC_VERSION >= 4008
100739 + .optinfo_flags = OPTGROUP_NONE,
100740 +#endif
100741 + .gate = kernexec_cmodel_check,
100742 + .execute = execute_kernexec_reload,
100743 + .sub = NULL,
100744 + .next = NULL,
100745 + .static_pass_number = 0,
100746 + .tv_id = TV_NONE,
100747 + .properties_required = 0,
100748 + .properties_provided = 0,
100749 + .properties_destroyed = 0,
100750 + .todo_flags_start = 0,
100751 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100752 + }
100753 +};
100754 +
100755 +static struct gimple_opt_pass kernexec_fptr_pass = {
100756 + .pass = {
100757 + .type = GIMPLE_PASS,
100758 + .name = "kernexec_fptr",
100759 +#if BUILDING_GCC_VERSION >= 4008
100760 + .optinfo_flags = OPTGROUP_NONE,
100761 +#endif
100762 + .gate = kernexec_cmodel_check,
100763 + .execute = execute_kernexec_fptr,
100764 + .sub = NULL,
100765 + .next = NULL,
100766 + .static_pass_number = 0,
100767 + .tv_id = TV_NONE,
100768 + .properties_required = 0,
100769 + .properties_provided = 0,
100770 + .properties_destroyed = 0,
100771 + .todo_flags_start = 0,
100772 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100773 + }
100774 +};
100775 +
100776 +static struct rtl_opt_pass kernexec_retaddr_pass = {
100777 + .pass = {
100778 + .type = RTL_PASS,
100779 + .name = "kernexec_retaddr",
100780 +#if BUILDING_GCC_VERSION >= 4008
100781 + .optinfo_flags = OPTGROUP_NONE,
100782 +#endif
100783 + .gate = kernexec_cmodel_check,
100784 + .execute = execute_kernexec_retaddr,
100785 + .sub = NULL,
100786 + .next = NULL,
100787 + .static_pass_number = 0,
100788 + .tv_id = TV_NONE,
100789 + .properties_required = 0,
100790 + .properties_provided = 0,
100791 + .properties_destroyed = 0,
100792 + .todo_flags_start = 0,
100793 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
100794 + }
100795 +};
100796 +
100797 +static bool kernexec_cmodel_check(void)
100798 +{
100799 + tree section;
100800 +
100801 + if (ix86_cmodel != CM_KERNEL)
100802 + return false;
100803 +
100804 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
100805 + if (!section || !TREE_VALUE(section))
100806 + return true;
100807 +
100808 + section = TREE_VALUE(TREE_VALUE(section));
100809 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
100810 + return true;
100811 +
100812 + return false;
100813 +}
100814 +
100815 +/*
100816 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
100817 + */
100818 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
100819 +{
100820 + gimple asm_movabs_stmt;
100821 +
100822 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
100823 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
100824 + gimple_asm_set_volatile(asm_movabs_stmt, true);
100825 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
100826 + update_stmt(asm_movabs_stmt);
100827 +}
100828 +
100829 +/*
100830 + * find all asm() stmts that clobber r10 and add a reload of r10
100831 + */
100832 +static unsigned int execute_kernexec_reload(void)
100833 +{
100834 + basic_block bb;
100835 +
100836 + // 1. loop through BBs and GIMPLE statements
100837 + FOR_EACH_BB(bb) {
100838 + gimple_stmt_iterator gsi;
100839 +
100840 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100841 + // gimple match: __asm__ ("" : : : "r10");
100842 + gimple asm_stmt;
100843 + size_t nclobbers;
100844 +
100845 + // is it an asm ...
100846 + asm_stmt = gsi_stmt(gsi);
100847 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
100848 + continue;
100849 +
100850 + // ... clobbering r10
100851 + nclobbers = gimple_asm_nclobbers(asm_stmt);
100852 + while (nclobbers--) {
100853 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
100854 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
100855 + continue;
100856 + kernexec_reload_fptr_mask(&gsi);
100857 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
100858 + break;
100859 + }
100860 + }
100861 + }
100862 +
100863 + return 0;
100864 +}
100865 +
100866 +/*
100867 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
100868 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
100869 + */
100870 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
100871 +{
100872 + gimple assign_intptr, assign_new_fptr, call_stmt;
100873 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
100874 +
100875 + call_stmt = gsi_stmt(*gsi);
100876 + old_fptr = gimple_call_fn(call_stmt);
100877 +
100878 + // create temporary unsigned long variable used for bitops and cast fptr to it
100879 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
100880 +#if BUILDING_GCC_VERSION <= 4007
100881 + add_referenced_var(intptr);
100882 +#endif
100883 + intptr = make_ssa_name(intptr, NULL);
100884 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
100885 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
100886 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
100887 + update_stmt(assign_intptr);
100888 +
100889 + // apply logical or to temporary unsigned long and bitmask
100890 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
100891 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
100892 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
100893 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
100894 + assign_intptr = gimple_build_assign(intptr, orptr);
100895 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
100896 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
100897 + update_stmt(assign_intptr);
100898 +
100899 + // cast temporary unsigned long back to a temporary fptr variable
100900 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
100901 +#if BUILDING_GCC_VERSION <= 4007
100902 + add_referenced_var(new_fptr);
100903 +#endif
100904 + new_fptr = make_ssa_name(new_fptr, NULL);
100905 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
100906 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
100907 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
100908 + update_stmt(assign_new_fptr);
100909 +
100910 + // replace call stmt fn with the new fptr
100911 + gimple_call_set_fn(call_stmt, new_fptr);
100912 + update_stmt(call_stmt);
100913 +}
100914 +
100915 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
100916 +{
100917 + gimple asm_or_stmt, call_stmt;
100918 + tree old_fptr, new_fptr, input, output;
100919 +#if BUILDING_GCC_VERSION <= 4007
100920 + VEC(tree, gc) *inputs = NULL;
100921 + VEC(tree, gc) *outputs = NULL;
100922 +#else
100923 + vec<tree, va_gc> *inputs = NULL;
100924 + vec<tree, va_gc> *outputs = NULL;
100925 +#endif
100926 +
100927 + call_stmt = gsi_stmt(*gsi);
100928 + old_fptr = gimple_call_fn(call_stmt);
100929 +
100930 + // create temporary fptr variable
100931 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
100932 +#if BUILDING_GCC_VERSION <= 4007
100933 + add_referenced_var(new_fptr);
100934 +#endif
100935 + new_fptr = make_ssa_name(new_fptr, NULL);
100936 +
100937 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
100938 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
100939 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
100940 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
100941 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
100942 +#if BUILDING_GCC_VERSION <= 4007
100943 + VEC_safe_push(tree, gc, inputs, input);
100944 + VEC_safe_push(tree, gc, outputs, output);
100945 +#else
100946 + vec_safe_push(inputs, input);
100947 + vec_safe_push(outputs, output);
100948 +#endif
100949 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
100950 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
100951 + gimple_asm_set_volatile(asm_or_stmt, true);
100952 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
100953 + update_stmt(asm_or_stmt);
100954 +
100955 + // replace call stmt fn with the new fptr
100956 + gimple_call_set_fn(call_stmt, new_fptr);
100957 + update_stmt(call_stmt);
100958 +}
100959 +
100960 +/*
100961 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
100962 + */
100963 +static unsigned int execute_kernexec_fptr(void)
100964 +{
100965 + basic_block bb;
100966 +
100967 + // 1. loop through BBs and GIMPLE statements
100968 + FOR_EACH_BB(bb) {
100969 + gimple_stmt_iterator gsi;
100970 +
100971 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100972 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
100973 + tree fn;
100974 + gimple call_stmt;
100975 +
100976 + // is it a call ...
100977 + call_stmt = gsi_stmt(gsi);
100978 + if (!is_gimple_call(call_stmt))
100979 + continue;
100980 + fn = gimple_call_fn(call_stmt);
100981 + if (TREE_CODE(fn) == ADDR_EXPR)
100982 + continue;
100983 + if (TREE_CODE(fn) != SSA_NAME)
100984 + gcc_unreachable();
100985 +
100986 + // ... through a function pointer
100987 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
100988 + fn = SSA_NAME_VAR(fn);
100989 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
100990 + debug_tree(fn);
100991 + gcc_unreachable();
100992 + }
100993 + }
100994 + fn = TREE_TYPE(fn);
100995 + if (TREE_CODE(fn) != POINTER_TYPE)
100996 + continue;
100997 + fn = TREE_TYPE(fn);
100998 + if (TREE_CODE(fn) != FUNCTION_TYPE)
100999 + continue;
101000 +
101001 + kernexec_instrument_fptr(&gsi);
101002 +
101003 +//debug_tree(gimple_call_fn(call_stmt));
101004 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101005 + }
101006 + }
101007 +
101008 + return 0;
101009 +}
101010 +
101011 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101012 +static void kernexec_instrument_retaddr_bts(rtx insn)
101013 +{
101014 + rtx btsq;
101015 + rtvec argvec, constraintvec, labelvec;
101016 + int line;
101017 +
101018 + // create asm volatile("btsq $63,(%%rsp)":::)
101019 + argvec = rtvec_alloc(0);
101020 + constraintvec = rtvec_alloc(0);
101021 + labelvec = rtvec_alloc(0);
101022 + line = expand_location(RTL_LOCATION(insn)).line;
101023 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101024 + MEM_VOLATILE_P(btsq) = 1;
101025 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101026 + emit_insn_before(btsq, insn);
101027 +}
101028 +
101029 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101030 +static void kernexec_instrument_retaddr_or(rtx insn)
101031 +{
101032 + rtx orq;
101033 + rtvec argvec, constraintvec, labelvec;
101034 + int line;
101035 +
101036 + // create asm volatile("orq %%r10,(%%rsp)":::)
101037 + argvec = rtvec_alloc(0);
101038 + constraintvec = rtvec_alloc(0);
101039 + labelvec = rtvec_alloc(0);
101040 + line = expand_location(RTL_LOCATION(insn)).line;
101041 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101042 + MEM_VOLATILE_P(orq) = 1;
101043 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101044 + emit_insn_before(orq, insn);
101045 +}
101046 +
101047 +/*
101048 + * find all asm level function returns and forcibly set the highest bit of the return address
101049 + */
101050 +static unsigned int execute_kernexec_retaddr(void)
101051 +{
101052 + rtx insn;
101053 +
101054 + // 1. find function returns
101055 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101056 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101057 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101058 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101059 + rtx body;
101060 +
101061 + // is it a retn
101062 + if (!JUMP_P(insn))
101063 + continue;
101064 + body = PATTERN(insn);
101065 + if (GET_CODE(body) == PARALLEL)
101066 + body = XVECEXP(body, 0, 0);
101067 + if (!ANY_RETURN_P(body))
101068 + continue;
101069 + kernexec_instrument_retaddr(insn);
101070 + }
101071 +
101072 +// print_simple_rtl(stderr, get_insns());
101073 +// print_rtl(stderr, get_insns());
101074 +
101075 + return 0;
101076 +}
101077 +
101078 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101079 +{
101080 + const char * const plugin_name = plugin_info->base_name;
101081 + const int argc = plugin_info->argc;
101082 + const struct plugin_argument * const argv = plugin_info->argv;
101083 + int i;
101084 + struct register_pass_info kernexec_reload_pass_info = {
101085 + .pass = &kernexec_reload_pass.pass,
101086 + .reference_pass_name = "ssa",
101087 + .ref_pass_instance_number = 1,
101088 + .pos_op = PASS_POS_INSERT_AFTER
101089 + };
101090 + struct register_pass_info kernexec_fptr_pass_info = {
101091 + .pass = &kernexec_fptr_pass.pass,
101092 + .reference_pass_name = "ssa",
101093 + .ref_pass_instance_number = 1,
101094 + .pos_op = PASS_POS_INSERT_AFTER
101095 + };
101096 + struct register_pass_info kernexec_retaddr_pass_info = {
101097 + .pass = &kernexec_retaddr_pass.pass,
101098 + .reference_pass_name = "pro_and_epilogue",
101099 + .ref_pass_instance_number = 1,
101100 + .pos_op = PASS_POS_INSERT_AFTER
101101 + };
101102 +
101103 + if (!plugin_default_version_check(version, &gcc_version)) {
101104 + error(G_("incompatible gcc/plugin versions"));
101105 + return 1;
101106 + }
101107 +
101108 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101109 +
101110 + if (TARGET_64BIT == 0)
101111 + return 0;
101112 +
101113 + for (i = 0; i < argc; ++i) {
101114 + if (!strcmp(argv[i].key, "method")) {
101115 + if (!argv[i].value) {
101116 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101117 + continue;
101118 + }
101119 + if (!strcmp(argv[i].value, "bts")) {
101120 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101121 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101122 + } else if (!strcmp(argv[i].value, "or")) {
101123 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101124 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101125 + fix_register("r10", 1, 1);
101126 + } else
101127 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101128 + continue;
101129 + }
101130 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101131 + }
101132 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101133 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101134 +
101135 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101136 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101137 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101138 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101139 +
101140 + return 0;
101141 +}
101142 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101143 new file mode 100644
101144 index 0000000..cd6c242
101145 --- /dev/null
101146 +++ b/tools/gcc/latent_entropy_plugin.c
101147 @@ -0,0 +1,321 @@
101148 +/*
101149 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101150 + * Licensed under the GPL v2
101151 + *
101152 + * Note: the choice of the license means that the compilation process is
101153 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101154 + * but for the kernel it doesn't matter since it doesn't link against
101155 + * any of the gcc libraries
101156 + *
101157 + * gcc plugin to help generate a little bit of entropy from program state,
101158 + * used during boot in the kernel
101159 + *
101160 + * TODO:
101161 + * - add ipa pass to identify not explicitly marked candidate functions
101162 + * - mix in more program state (function arguments/return values, loop variables, etc)
101163 + * - more instrumentation control via attribute parameters
101164 + *
101165 + * BUGS:
101166 + * - LTO needs -flto-partition=none for now
101167 + */
101168 +#include "gcc-plugin.h"
101169 +#include "config.h"
101170 +#include "system.h"
101171 +#include "coretypes.h"
101172 +#include "tree.h"
101173 +#include "tree-pass.h"
101174 +#include "flags.h"
101175 +#include "intl.h"
101176 +#include "toplev.h"
101177 +#include "plugin.h"
101178 +//#include "expr.h" where are you...
101179 +#include "diagnostic.h"
101180 +#include "plugin-version.h"
101181 +#include "tm.h"
101182 +#include "function.h"
101183 +#include "basic-block.h"
101184 +#include "gimple.h"
101185 +#include "rtl.h"
101186 +#include "emit-rtl.h"
101187 +#include "tree-flow.h"
101188 +#include "langhooks.h"
101189 +
101190 +#if BUILDING_GCC_VERSION >= 4008
101191 +#define TODO_dump_func 0
101192 +#endif
101193 +
101194 +int plugin_is_GPL_compatible;
101195 +
101196 +static tree latent_entropy_decl;
101197 +
101198 +static struct plugin_info latent_entropy_plugin_info = {
101199 + .version = "201308230230",
101200 + .help = NULL
101201 +};
101202 +
101203 +static unsigned int execute_latent_entropy(void);
101204 +static bool gate_latent_entropy(void);
101205 +
101206 +static struct gimple_opt_pass latent_entropy_pass = {
101207 + .pass = {
101208 + .type = GIMPLE_PASS,
101209 + .name = "latent_entropy",
101210 +#if BUILDING_GCC_VERSION >= 4008
101211 + .optinfo_flags = OPTGROUP_NONE,
101212 +#endif
101213 + .gate = gate_latent_entropy,
101214 + .execute = execute_latent_entropy,
101215 + .sub = NULL,
101216 + .next = NULL,
101217 + .static_pass_number = 0,
101218 + .tv_id = TV_NONE,
101219 + .properties_required = PROP_gimple_leh | PROP_cfg,
101220 + .properties_provided = 0,
101221 + .properties_destroyed = 0,
101222 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101223 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101224 + }
101225 +};
101226 +
101227 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101228 +{
101229 + if (TREE_CODE(*node) != FUNCTION_DECL) {
101230 + *no_add_attrs = true;
101231 + error("%qE attribute only applies to functions", name);
101232 + }
101233 + return NULL_TREE;
101234 +}
101235 +
101236 +static struct attribute_spec latent_entropy_attr = {
101237 + .name = "latent_entropy",
101238 + .min_length = 0,
101239 + .max_length = 0,
101240 + .decl_required = true,
101241 + .type_required = false,
101242 + .function_type_required = false,
101243 + .handler = handle_latent_entropy_attribute,
101244 +#if BUILDING_GCC_VERSION >= 4007
101245 + .affects_type_identity = false
101246 +#endif
101247 +};
101248 +
101249 +static void register_attributes(void *event_data, void *data)
101250 +{
101251 + register_attribute(&latent_entropy_attr);
101252 +}
101253 +
101254 +static bool gate_latent_entropy(void)
101255 +{
101256 + tree latent_entropy_attr;
101257 +
101258 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
101259 + return latent_entropy_attr != NULL_TREE;
101260 +}
101261 +
101262 +static unsigned HOST_WIDE_INT seed;
101263 +static unsigned HOST_WIDE_INT get_random_const(void)
101264 +{
101265 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101266 + return seed;
101267 +}
101268 +
101269 +static enum tree_code get_op(tree *rhs)
101270 +{
101271 + static enum tree_code op;
101272 + unsigned HOST_WIDE_INT random_const;
101273 +
101274 + random_const = get_random_const();
101275 +
101276 + switch (op) {
101277 + case BIT_XOR_EXPR:
101278 + op = PLUS_EXPR;
101279 + break;
101280 +
101281 + case PLUS_EXPR:
101282 + if (rhs) {
101283 + op = LROTATE_EXPR;
101284 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
101285 + break;
101286 + }
101287 +
101288 + case LROTATE_EXPR:
101289 + default:
101290 + op = BIT_XOR_EXPR;
101291 + break;
101292 + }
101293 + if (rhs)
101294 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
101295 + return op;
101296 +}
101297 +
101298 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
101299 +{
101300 + gimple_stmt_iterator gsi;
101301 + gimple assign;
101302 + tree addxorrol, rhs;
101303 + enum tree_code op;
101304 +
101305 + op = get_op(&rhs);
101306 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
101307 + assign = gimple_build_assign(local_entropy, addxorrol);
101308 + gsi = gsi_after_labels(bb);
101309 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101310 + update_stmt(assign);
101311 +//debug_bb(bb);
101312 +}
101313 +
101314 +static void perturb_latent_entropy(basic_block bb, tree rhs)
101315 +{
101316 + gimple_stmt_iterator gsi;
101317 + gimple assign;
101318 + tree addxorrol, temp;
101319 +
101320 + // 1. create temporary copy of latent_entropy
101321 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
101322 +#if BUILDING_GCC_VERSION <= 4007
101323 + add_referenced_var(temp);
101324 +#endif
101325 +
101326 + // 2. read...
101327 + temp = make_ssa_name(temp, NULL);
101328 + assign = gimple_build_assign(temp, latent_entropy_decl);
101329 + SSA_NAME_DEF_STMT(temp) = assign;
101330 +#if BUILDING_GCC_VERSION <= 4007
101331 + add_referenced_var(latent_entropy_decl);
101332 +#endif
101333 + gsi = gsi_after_labels(bb);
101334 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101335 + update_stmt(assign);
101336 +
101337 + // 3. ...modify...
101338 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
101339 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
101340 + assign = gimple_build_assign(temp, addxorrol);
101341 + SSA_NAME_DEF_STMT(temp) = assign;
101342 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101343 + update_stmt(assign);
101344 +
101345 + // 4. ...write latent_entropy
101346 + assign = gimple_build_assign(latent_entropy_decl, temp);
101347 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101348 + update_stmt(assign);
101349 +}
101350 +
101351 +static unsigned int execute_latent_entropy(void)
101352 +{
101353 + basic_block bb;
101354 + gimple assign;
101355 + gimple_stmt_iterator gsi;
101356 + tree local_entropy;
101357 +
101358 + if (!latent_entropy_decl) {
101359 + struct varpool_node *node;
101360 +
101361 +#if BUILDING_GCC_VERSION <= 4007
101362 + for (node = varpool_nodes; node; node = node->next) {
101363 + tree var = node->decl;
101364 +#else
101365 + FOR_EACH_VARIABLE(node) {
101366 + tree var = node->symbol.decl;
101367 +#endif
101368 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
101369 + continue;
101370 + latent_entropy_decl = var;
101371 +// debug_tree(var);
101372 + break;
101373 + }
101374 + if (!latent_entropy_decl) {
101375 +// debug_tree(current_function_decl);
101376 + return 0;
101377 + }
101378 + }
101379 +
101380 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
101381 +
101382 + // 1. create local entropy variable
101383 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
101384 +#if BUILDING_GCC_VERSION <= 4007
101385 + add_referenced_var(local_entropy);
101386 + mark_sym_for_renaming(local_entropy);
101387 +#endif
101388 +
101389 + // 2. initialize local entropy variable
101390 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101391 + if (dom_info_available_p(CDI_DOMINATORS))
101392 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
101393 + gsi = gsi_start_bb(bb);
101394 +
101395 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
101396 +// gimple_set_location(assign, loc);
101397 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101398 + update_stmt(assign);
101399 +//debug_bb(bb);
101400 + bb = bb->next_bb;
101401 +
101402 + // 3. instrument each BB with an operation on the local entropy variable
101403 + while (bb != EXIT_BLOCK_PTR) {
101404 + perturb_local_entropy(bb, local_entropy);
101405 +//debug_bb(bb);
101406 + bb = bb->next_bb;
101407 + };
101408 +
101409 + // 4. mix local entropy into the global entropy variable
101410 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
101411 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
101412 + return 0;
101413 +}
101414 +
101415 +static void start_unit_callback(void *gcc_data, void *user_data)
101416 +{
101417 + tree latent_entropy_type;
101418 +
101419 +#if BUILDING_GCC_VERSION >= 4007
101420 + seed = get_random_seed(false);
101421 +#else
101422 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
101423 + seed *= seed;
101424 +#endif
101425 +
101426 + if (in_lto_p)
101427 + return;
101428 +
101429 + // extern volatile u64 latent_entropy
101430 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
101431 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
101432 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
101433 +
101434 + TREE_STATIC(latent_entropy_decl) = 1;
101435 + TREE_PUBLIC(latent_entropy_decl) = 1;
101436 + TREE_USED(latent_entropy_decl) = 1;
101437 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
101438 + DECL_EXTERNAL(latent_entropy_decl) = 1;
101439 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
101440 + DECL_INITIAL(latent_entropy_decl) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101441 + lang_hooks.decls.pushdecl(latent_entropy_decl);
101442 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
101443 +// varpool_finalize_decl(latent_entropy_decl);
101444 +// varpool_mark_needed_node(latent_entropy_decl);
101445 +}
101446 +
101447 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101448 +{
101449 + const char * const plugin_name = plugin_info->base_name;
101450 + struct register_pass_info latent_entropy_pass_info = {
101451 + .pass = &latent_entropy_pass.pass,
101452 + .reference_pass_name = "optimized",
101453 + .ref_pass_instance_number = 1,
101454 + .pos_op = PASS_POS_INSERT_BEFORE
101455 + };
101456 +
101457 + if (!plugin_default_version_check(version, &gcc_version)) {
101458 + error(G_("incompatible gcc/plugin versions"));
101459 + return 1;
101460 + }
101461 +
101462 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
101463 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101464 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
101465 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101466 +
101467 + return 0;
101468 +}
101469 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
101470 new file mode 100644
101471 index 0000000..b04803b
101472 --- /dev/null
101473 +++ b/tools/gcc/size_overflow_hash.data
101474 @@ -0,0 +1,6350 @@
101475 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
101476 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
101477 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
101478 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
101479 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
101480 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
101481 +padzero_55 padzero 1 55 &sel_read_policyvers_55
101482 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
101483 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
101484 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
101485 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
101486 +load_msg_95 load_msg 2 95 NULL
101487 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
101488 +init_q_132 init_q 4 132 NULL
101489 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
101490 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
101491 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
101492 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
101493 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
101494 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
101495 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
101496 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
101497 +br_port_info_size_268 br_port_info_size 0 268 NULL
101498 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
101499 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
101500 +SYSC_connect_304 SYSC_connect 3 304 NULL
101501 +syslog_print_307 syslog_print 2 307 NULL
101502 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
101503 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
101504 +next_node_allowed_318 next_node_allowed 1 318 NULL
101505 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
101506 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
101507 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
101508 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
101509 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
101510 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
101511 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
101512 +pidlist_resize_496 pidlist_resize 2 496 NULL
101513 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
101514 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
101515 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
101516 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
101517 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
101518 +dle_count_543 dle_count 0 543 NULL
101519 +devres_alloc_551 devres_alloc 2 551 NULL
101520 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
101521 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
101522 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
101523 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
101524 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
101525 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
101526 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
101527 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
101528 +isp1760_register_628 isp1760_register 1-2 628 NULL
101529 +clone_split_bio_633 clone_split_bio 6 633 NULL
101530 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
101531 +remap_to_cache_640 remap_to_cache 3 640 NULL
101532 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
101533 +unlink_queued_645 unlink_queued 3-4 645 NULL
101534 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
101535 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
101536 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
101537 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
101538 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
101539 +disk_max_parts_719 disk_max_parts 0 719 NULL
101540 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
101541 +dvb_video_write_754 dvb_video_write 3 754 NULL
101542 +if_writecmd_815 if_writecmd 2 815 NULL
101543 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
101544 +read_fifo_826 read_fifo 3 826 NULL
101545 +um_idi_read_850 um_idi_read 3 850 NULL
101546 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
101547 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
101548 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
101549 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
101550 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
101551 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
101552 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
101553 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
101554 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
101555 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
101556 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
101557 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
101558 +_do_truncate_1019 _do_truncate 2 1019 NULL
101559 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
101560 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
101561 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
101562 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
101563 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
101564 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
101565 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
101566 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
101567 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
101568 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
101569 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
101570 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
101571 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
101572 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
101573 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
101574 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
101575 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
101576 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
101577 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
101578 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
101579 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
101580 +nested_get_page_1252 nested_get_page 2 1252 NULL
101581 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
101582 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
101583 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
101584 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
101585 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
101586 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
101587 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
101588 +ffs_1322 ffs 0 1322 NULL
101589 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
101590 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
101591 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
101592 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
101593 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
101594 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
101595 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
101596 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
101597 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
101598 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
101599 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
101600 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
101601 +zone_page_state_1393 zone_page_state 0 1393 NULL
101602 +file_read_actor_1401 file_read_actor 4 1401 NULL
101603 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
101604 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
101605 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
101606 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
101607 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
101608 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
101609 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
101610 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
101611 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
101612 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
101613 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
101614 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
101615 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
101616 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
101617 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
101618 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
101619 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
101620 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
101621 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
101622 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
101623 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
101624 +rmap_add_1677 rmap_add 3 1677 NULL
101625 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
101626 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
101627 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
101628 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
101629 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
101630 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
101631 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
101632 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
101633 +cosa_write_1774 cosa_write 3 1774 NULL
101634 +update_macheader_1775 update_macheader 7 1775 NULL
101635 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
101636 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
101637 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
101638 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
101639 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
101640 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
101641 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
101642 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
101643 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
101644 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
101645 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
101646 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
101647 +read_swap_header_1957 read_swap_header 0 1957 NULL
101648 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
101649 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
101650 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
101651 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
101652 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
101653 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
101654 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
101655 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
101656 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
101657 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
101658 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
101659 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
101660 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
101661 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
101662 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
101663 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
101664 +audit_expand_2098 audit_expand 2 2098 NULL
101665 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
101666 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
101667 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
101668 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
101669 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
101670 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
101671 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
101672 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
101673 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
101674 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
101675 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
101676 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
101677 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
101678 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
101679 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
101680 +vhci_write_2224 vhci_write 3 2224 NULL
101681 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
101682 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
101683 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
101684 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
101685 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
101686 +do_update_counters_2259 do_update_counters 4 2259 NULL
101687 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
101688 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
101689 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
101690 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
101691 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
101692 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
101693 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
101694 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
101695 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
101696 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
101697 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
101698 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
101699 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
101700 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
101701 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
101702 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
101703 +raid1_size_2419 raid1_size 0-2 2419 NULL
101704 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
101705 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
101706 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
101707 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
101708 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
101709 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
101710 +update_pmkid_2481 update_pmkid 4 2481 NULL
101711 +wiphy_new_2482 wiphy_new 2 2482 NULL
101712 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
101713 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
101714 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
101715 +dm_write_2513 dm_write 3 2513 NULL
101716 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
101717 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
101718 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
101719 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
101720 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
101721 +slot_bytes_2609 slot_bytes 0 2609 NULL
101722 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
101723 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
101724 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
101725 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
101726 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
101727 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
101728 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
101729 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
101730 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
101731 +__next_cpu_2782 __next_cpu 1 2782 NULL
101732 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
101733 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
101734 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
101735 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
101736 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
101737 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
101738 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
101739 +mq_map_2871 mq_map 2 2871 NULL
101740 +nla_padlen_2883 nla_padlen 1 2883 NULL
101741 +cmm_write_2896 cmm_write 3 2896 NULL
101742 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
101743 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
101744 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
101745 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
101746 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
101747 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
101748 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
101749 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
101750 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
101751 +depth_write_3021 depth_write 3 3021 NULL
101752 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
101753 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
101754 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
101755 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
101756 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
101757 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
101758 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
101759 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
101760 +free_coherent_3082 free_coherent 4-2 3082 NULL
101761 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
101762 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
101763 +rb_alloc_3102 rb_alloc 1 3102 NULL
101764 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
101765 +print_time_3132 print_time 0 3132 NULL
101766 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
101767 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
101768 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
101769 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
101770 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
101771 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
101772 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
101773 +alloc_context_3194 alloc_context 1 3194 NULL
101774 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
101775 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
101776 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
101777 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
101778 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
101779 +key_key_read_3241 key_key_read 3 3241 NULL
101780 +number_3243 number 0 3243 NULL
101781 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
101782 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
101783 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
101784 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
101785 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
101786 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
101787 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
101788 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
101789 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
101790 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
101791 +scnprintf_3360 scnprintf 0-2 3360 NULL
101792 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
101793 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
101794 +send_stream_3397 send_stream 4 3397 NULL
101795 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
101796 +msix_map_region_3411 msix_map_region 3 3411 NULL
101797 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
101798 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
101799 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
101800 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
101801 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
101802 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
101803 +map_single_3449 map_single 0-2 3449 NULL
101804 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
101805 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
101806 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
101807 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
101808 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
101809 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
101810 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
101811 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
101812 +SyS_readv_3539 SyS_readv 3 3539 NULL
101813 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
101814 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
101815 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
101816 +evtchn_read_3569 evtchn_read 3 3569 NULL
101817 +vc_resize_3585 vc_resize 2-3 3585 NULL
101818 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
101819 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
101820 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
101821 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
101822 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
101823 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
101824 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
101825 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
101826 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
101827 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
101828 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
101829 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
101830 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
101831 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
101832 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
101833 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
101834 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
101835 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
101836 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
101837 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
101838 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
101839 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
101840 +get_fd_set_3866 get_fd_set 1 3866 NULL
101841 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
101842 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
101843 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
101844 +nvram_write_3894 nvram_write 3 3894 NULL
101845 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
101846 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
101847 +vcs_write_3910 vcs_write 3 3910 NULL
101848 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
101849 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
101850 +do_add_counters_3992 do_add_counters 3 3992 NULL
101851 +userspace_status_4004 userspace_status 4 4004 NULL
101852 +mei_write_4005 mei_write 3 4005 NULL nohasharray
101853 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
101854 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
101855 +mm_populate_4016 mm_populate 1 4016 NULL
101856 +blk_end_request_4024 blk_end_request 3 4024 NULL
101857 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
101858 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
101859 +read_file_queues_4078 read_file_queues 3 4078 NULL
101860 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
101861 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
101862 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
101863 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
101864 +tm6000_read_4151 tm6000_read 3 4151 NULL
101865 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
101866 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
101867 +get_alua_req_4166 get_alua_req 3 4166 NULL
101868 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
101869 +read_file_bool_4180 read_file_bool 3 4180 NULL
101870 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
101871 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
101872 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
101873 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
101874 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
101875 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
101876 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
101877 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
101878 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
101879 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
101880 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
101881 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
101882 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
101883 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
101884 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
101885 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
101886 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
101887 +memparse_4444 memparse 0 4444 NULL
101888 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
101889 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
101890 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
101891 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
101892 +set_link_security_4502 set_link_security 4 4502 NULL
101893 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
101894 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
101895 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
101896 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
101897 +tty_register_device_4544 tty_register_device 2 4544 NULL
101898 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
101899 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
101900 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
101901 +bch_alloc_4593 bch_alloc 1 4593 NULL
101902 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
101903 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
101904 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
101905 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
101906 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
101907 +kone_receive_4690 kone_receive 4 4690 NULL
101908 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
101909 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
101910 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
101911 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
101912 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
101913 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
101914 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
101915 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
101916 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
101917 +create_subvol_4791 create_subvol 4 4791 NULL
101918 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
101919 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
101920 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
101921 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
101922 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
101923 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
101924 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
101925 +sys_ipc_4889 sys_ipc 3 4889 NULL
101926 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
101927 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
101928 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
101929 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
101930 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
101931 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
101932 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
101933 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
101934 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
101935 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
101936 +do_mincore_5018 do_mincore 0-1 5018 NULL
101937 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
101938 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
101939 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
101940 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
101941 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
101942 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
101943 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
101944 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
101945 +sound_write_5102 sound_write 3 5102 NULL
101946 +clear_dirty_5105 clear_dirty 3 5105 NULL
101947 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
101948 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
101949 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
101950 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
101951 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
101952 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
101953 +skb_network_header_5203 skb_network_header 0 5203 NULL
101954 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
101955 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
101956 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
101957 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
101958 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
101959 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
101960 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
101961 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
101962 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
101963 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
101964 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
101965 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
101966 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
101967 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
101968 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
101969 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
101970 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
101971 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
101972 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
101973 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
101974 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
101975 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
101976 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
101977 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
101978 +tty_write_5494 tty_write 3 5494 NULL
101979 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
101980 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
101981 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
101982 +spidev_message_5518 spidev_message 3 5518 NULL
101983 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
101984 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
101985 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
101986 +le_readq_5557 le_readq 0 5557 NULL
101987 +inw_5558 inw 0 5558 NULL
101988 +fir16_create_5574 fir16_create 3 5574 NULL
101989 +bioset_create_5580 bioset_create 1 5580 NULL
101990 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
101991 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
101992 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
101993 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
101994 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
101995 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
101996 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
101997 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
101998 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
101999 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102000 +get_arg_5694 get_arg 3 5694 NULL
102001 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102002 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102003 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
102004 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
102005 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
102006 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
102007 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
102008 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
102009 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
102010 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
102011 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
102012 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
102013 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
102014 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
102015 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
102016 +setup_req_5848 setup_req 3 5848 NULL
102017 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
102018 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
102019 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
102020 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
102021 +port_show_regs_5904 port_show_regs 3 5904 NULL
102022 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
102023 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
102024 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
102025 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
102026 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
102027 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
102028 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
102029 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
102030 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
102031 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
102032 +native_pte_val_5978 native_pte_val 0 5978 NULL
102033 +SyS_semop_5980 SyS_semop 3 5980 NULL
102034 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
102035 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
102036 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
102037 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
102038 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
102039 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
102040 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
102041 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
102042 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
102043 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
102044 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
102045 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102046 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102047 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102048 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102049 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102050 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102051 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102052 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102053 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102054 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102055 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102056 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
102057 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102058 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102059 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102060 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
102061 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
102062 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
102063 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102064 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
102065 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102066 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102067 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102068 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102069 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102070 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
102071 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102072 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102073 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
102074 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102075 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
102076 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102077 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102078 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102079 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102080 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102081 +mei_read_6507 mei_read 3 6507 NULL
102082 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102083 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102084 +wdm_read_6549 wdm_read 3 6549 NULL
102085 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102086 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102087 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102088 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102089 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102090 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102091 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102092 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102093 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102094 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102095 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102096 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102097 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102098 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102099 +mpeg_read_6708 mpeg_read 3 6708 NULL
102100 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102101 +video_proc_write_6724 video_proc_write 3 6724 NULL
102102 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102103 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102104 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102105 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102106 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102107 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102108 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102109 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102110 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102111 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102112 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102113 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102114 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102115 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102116 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102117 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102118 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102119 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102120 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102121 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102122 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102123 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102124 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102125 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102126 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102127 +request_key_async_6990 request_key_async 4 6990 NULL
102128 +tpl_write_6998 tpl_write 3 6998 NULL
102129 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102130 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102131 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102132 +wimax_msg_7030 wimax_msg 4 7030 NULL
102133 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102134 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102135 +event_enable_read_7074 event_enable_read 3 7074 NULL
102136 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102137 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102138 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102139 +check_header_7108 check_header 0 7108 NULL
102140 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102141 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102142 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102143 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102144 +get_param_h_7247 get_param_h 0 7247 NULL
102145 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102146 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102147 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102148 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102149 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102150 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102151 +mgmt_control_7349 mgmt_control 3 7349 NULL
102152 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102153 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102154 +hweight_long_7388 hweight_long 0-1 7388 NULL
102155 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102156 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102157 +readb_7401 readb 0 7401 NULL
102158 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102159 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102160 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102161 +numa_emulation_7466 numa_emulation 2 7466 NULL
102162 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102163 +garp_request_join_7471 garp_request_join 4 7471 NULL
102164 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102165 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102166 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102167 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102168 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102169 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102170 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102171 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102172 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102173 +groups_alloc_7614 groups_alloc 1 7614 NULL
102174 +sg_virt_7616 sg_virt 0 7616 NULL
102175 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102176 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102177 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
102178 +dev_write_7708 dev_write 3 7708 NULL
102179 +unmap_region_7709 unmap_region 1 7709 NULL
102180 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
102181 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
102182 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
102183 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
102184 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
102185 +ioread32be_7773 ioread32be 0 7773 NULL
102186 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
102187 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
102188 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
102189 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
102190 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
102191 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
102192 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
102193 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
102194 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
102195 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
102196 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
102197 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
102198 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
102199 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
102200 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
102201 +sys_mbind_7990 sys_mbind 5 7990 NULL
102202 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
102203 +vcs_read_8017 vcs_read 3 8017 NULL
102204 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
102205 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
102206 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
102207 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
102208 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
102209 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
102210 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
102211 +venus_lookup_8121 venus_lookup 4 8121 NULL
102212 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
102213 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
102214 +ore_truncate_8181 ore_truncate 3 8181 NULL
102215 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
102216 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
102217 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
102218 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
102219 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
102220 +play_iframe_8219 play_iframe 3 8219 NULL
102221 +create_log_8225 create_log 2 8225 NULL nohasharray
102222 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
102223 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
102224 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
102225 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
102226 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
102227 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
102228 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
102229 +init_cdev_8274 init_cdev 1 8274 NULL
102230 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
102231 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
102232 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
102233 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
102234 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
102235 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
102236 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
102237 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
102238 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
102239 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
102240 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
102241 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
102242 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
102243 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
102244 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
102245 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
102246 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
102247 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
102248 +dev_config_8506 dev_config 3 8506 NULL
102249 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
102250 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
102251 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
102252 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
102253 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
102254 +user_on_off_8552 user_on_off 2 8552 NULL
102255 +profile_remove_8556 profile_remove 3 8556 NULL
102256 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
102257 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
102258 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
102259 +tower_write_8580 tower_write 3 8580 NULL
102260 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
102261 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
102262 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
102263 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
102264 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
102265 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
102266 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
102267 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
102268 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
102269 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
102270 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
102271 +arcfb_write_8702 arcfb_write 3 8702 NULL
102272 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
102273 +init_header_8703 init_header 0 8703 &i_size_read_8703
102274 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
102275 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
102276 +f_dupfd_8730 f_dupfd 1 8730 NULL
102277 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
102278 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
102279 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
102280 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
102281 +sys_prctl_8766 sys_prctl 4 8766 NULL
102282 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
102283 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
102284 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
102285 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
102286 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
102287 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
102288 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
102289 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
102290 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
102291 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
102292 +clear_bitset_8840 clear_bitset 2 8840 NULL
102293 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
102294 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
102295 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
102296 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
102297 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
102298 +layout_commit_8926 layout_commit 3 8926 NULL
102299 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
102300 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
102301 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
102302 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
102303 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
102304 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
102305 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
102306 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
102307 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
102308 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
102309 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
102310 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
102311 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
102312 +nla_put_9042 nla_put 3 9042 NULL
102313 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
102314 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
102315 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
102316 +string_9080 string 0 9080 NULL
102317 +create_queues_9088 create_queues 2-3 9088 NULL
102318 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
102319 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
102320 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
102321 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
102322 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
102323 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
102324 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
102325 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
102326 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
102327 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
102328 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
102329 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
102330 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
102331 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
102332 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
102333 +get_pfn_9207 get_pfn 1 9207 NULL
102334 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
102335 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
102336 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
102337 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
102338 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
102339 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
102340 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
102341 +flakey_status_9274 flakey_status 5 9274 NULL
102342 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
102343 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
102344 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
102345 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
102346 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
102347 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
102348 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
102349 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
102350 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
102351 +read_9397 read 3 9397 NULL
102352 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
102353 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
102354 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
102355 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
102356 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
102357 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
102358 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
102359 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
102360 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
102361 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
102362 +lp_write_9511 lp_write 3 9511 NULL
102363 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
102364 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
102365 +read_file_dma_9530 read_file_dma 3 9530 NULL
102366 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
102367 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
102368 +fw_node_create_9559 fw_node_create 2 9559 NULL
102369 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
102370 +kobj_map_9566 kobj_map 2-3 9566 NULL
102371 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
102372 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
102373 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
102374 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
102375 +do_sync_9604 do_sync 1 9604 NULL
102376 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
102377 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
102378 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
102379 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
102380 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
102381 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
102382 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
102383 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
102384 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
102385 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
102386 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
102387 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
102388 +is_hole_9694 is_hole 2 9694 NULL nohasharray
102389 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
102390 +fnb_9703 fnb 2-3 9703 NULL
102391 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
102392 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
102393 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
102394 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
102395 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
102396 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
102397 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
102398 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
102399 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
102400 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
102401 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
102402 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
102403 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
102404 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
102405 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
102406 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
102407 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
102408 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
102409 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
102410 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
102411 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
102412 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
102413 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
102414 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
102415 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
102416 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
102417 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
102418 +read_file_misc_9948 read_file_misc 3 9948 NULL
102419 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
102420 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
102421 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
102422 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
102423 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
102424 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
102425 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
102426 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
102427 +handle_request_10024 handle_request 9 10024 NULL
102428 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
102429 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
102430 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
102431 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
102432 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
102433 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
102434 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
102435 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
102436 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
102437 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
102438 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
102439 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
102440 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
102441 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
102442 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
102443 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
102444 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
102445 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
102446 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
102447 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
102448 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
102449 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
102450 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
102451 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
102452 +read_emulate_10310 read_emulate 2-4 10310 NULL
102453 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
102454 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
102455 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
102456 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
102457 +get_dump_page_10338 get_dump_page 1 10338 NULL
102458 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
102459 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
102460 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
102461 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
102462 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
102463 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
102464 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
102465 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
102466 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
102467 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
102468 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
102469 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
102470 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
102471 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
102472 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
102473 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
102474 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
102475 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
102476 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
102477 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
102478 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
102479 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
102480 +otp_read_10594 otp_read 2-4-5 10594 NULL
102481 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
102482 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
102483 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
102484 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
102485 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
102486 +parport_write_10669 parport_write 0 10669 NULL
102487 +inl_10708 inl 0 10708 NULL nohasharray
102488 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
102489 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
102490 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
102491 +spi_sync_10731 spi_sync 0 10731 NULL
102492 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
102493 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
102494 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
102495 +sys_syslog_10746 sys_syslog 3 10746 NULL
102496 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
102497 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
102498 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
102499 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
102500 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
102501 +sys_bind_10799 sys_bind 3 10799 NULL
102502 +compat_put_int_10828 compat_put_int 1 10828 NULL
102503 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
102504 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
102505 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
102506 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
102507 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
102508 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
102509 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
102510 +get_scq_10897 get_scq 2 10897 NULL
102511 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
102512 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
102513 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
102514 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
102515 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
102516 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
102517 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
102518 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
102519 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
102520 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
102521 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
102522 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
102523 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
102524 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
102525 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
102526 +count_argc_11083 count_argc 0 11083 NULL
102527 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
102528 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
102529 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
102530 +page_offset_11120 page_offset 0 11120 NULL
102531 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
102532 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
102533 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
102534 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
102535 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
102536 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
102537 +__swab16p_11220 __swab16p 0 11220 NULL
102538 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
102539 +mmap_region_11247 mmap_region 0-2 11247 NULL
102540 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
102541 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
102542 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
102543 +cru_detect_11272 cru_detect 1 11272 NULL
102544 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
102545 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
102546 +construct_key_11329 construct_key 3 11329 NULL nohasharray
102547 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
102548 +next_segment_11330 next_segment 0-2-1 11330 NULL
102549 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
102550 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
102551 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
102552 +sel_write_create_11353 sel_write_create 3 11353 NULL
102553 +handle_unit_11355 handle_unit 0-1 11355 NULL
102554 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
102555 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
102556 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
102557 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
102558 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
102559 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
102560 +str_to_user_11411 str_to_user 2 11411 NULL
102561 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
102562 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
102563 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
102564 +trace_options_read_11419 trace_options_read 3 11419 NULL
102565 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
102566 +prepare_image_11424 prepare_image 0 11424 NULL
102567 +vring_size_11426 vring_size 0-1-2 11426 NULL
102568 +bttv_read_11432 bttv_read 3 11432 NULL
102569 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
102570 +swp_offset_11475 swp_offset 0 11475 NULL
102571 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
102572 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
102573 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
102574 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
102575 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
102576 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
102577 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
102578 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
102579 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
102580 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
102581 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
102582 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
102583 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
102584 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
102585 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
102586 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
102587 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
102588 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
102589 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
102590 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
102591 +split_11691 split 2 11691 NULL
102592 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
102593 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
102594 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
102595 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
102596 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
102597 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
102598 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
102599 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
102600 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
102601 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
102602 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
102603 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
102604 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
102605 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
102606 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
102607 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
102608 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
102609 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
102610 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
102611 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
102612 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
102613 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
102614 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
102615 +atmel_read16_11981 atmel_read16 0 11981 NULL
102616 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
102617 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
102618 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
102619 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
102620 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
102621 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
102622 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
102623 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
102624 +set_powered_12129 set_powered 4 12129 NULL
102625 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
102626 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
102627 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
102628 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
102629 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
102630 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
102631 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
102632 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
102633 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
102634 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
102635 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
102636 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
102637 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
102638 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
102639 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
102640 +scaled_div_12201 scaled_div 1-2 12201 NULL
102641 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
102642 +receive_copy_12216 receive_copy 3 12216 NULL
102643 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
102644 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
102645 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
102646 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
102647 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
102648 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
102649 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
102650 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
102651 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
102652 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
102653 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
102654 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
102655 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
102656 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
102657 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
102658 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
102659 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
102660 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
102661 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
102662 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
102663 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
102664 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
102665 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
102666 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
102667 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
102668 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
102669 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
102670 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
102671 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
102672 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
102673 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
102674 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
102675 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
102676 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
102677 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
102678 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
102679 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
102680 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
102681 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
102682 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
102683 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
102684 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
102685 +wb_create_12651 wb_create 1 12651 NULL
102686 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
102687 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
102688 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
102689 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
102690 +ivtv_write_12721 ivtv_write 3 12721 NULL
102691 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
102692 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
102693 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
102694 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
102695 +listxattr_12769 listxattr 3 12769 NULL
102696 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
102697 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
102698 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
102699 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
102700 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
102701 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
102702 +readq_12825 readq 0 12825 NULL
102703 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
102704 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
102705 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
102706 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
102707 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
102708 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
102709 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
102710 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
102711 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
102712 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
102713 +bm_status_write_12964 bm_status_write 3 12964 NULL
102714 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
102715 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
102716 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
102717 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
102718 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
102719 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
102720 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
102721 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
102722 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
102723 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
102724 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
102725 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
102726 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
102727 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
102728 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
102729 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
102730 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
102731 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
102732 +blk_update_request_13146 blk_update_request 3 13146 NULL
102733 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
102734 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
102735 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
102736 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
102737 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
102738 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
102739 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
102740 +comedi_read_13199 comedi_read 3 13199 NULL
102741 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
102742 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
102743 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
102744 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
102745 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
102746 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
102747 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
102748 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
102749 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
102750 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
102751 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
102752 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
102753 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
102754 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
102755 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
102756 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
102757 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
102758 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
102759 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
102760 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
102761 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
102762 +cache_ctr_13364 cache_ctr 2 13364 NULL
102763 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
102764 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
102765 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
102766 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
102767 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
102768 +sky2_receive_13407 sky2_receive 2 13407 NULL
102769 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
102770 +keyring_read_13438 keyring_read 3 13438 NULL
102771 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
102772 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
102773 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
102774 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
102775 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
102776 +core_status_13515 core_status 4 13515 NULL
102777 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
102778 +bm_init_13529 bm_init 2 13529 NULL
102779 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
102780 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
102781 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
102782 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
102783 +sys_madvise_13569 sys_madvise 1 13569 NULL
102784 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
102785 +cache_write_13589 cache_write 3 13589 NULL
102786 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
102787 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
102788 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
102789 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
102790 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
102791 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
102792 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
102793 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
102794 +packet_snd_13634 packet_snd 3 13634 NULL
102795 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
102796 +cache_downcall_13666 cache_downcall 3 13666 NULL
102797 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
102798 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
102799 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
102800 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
102801 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
102802 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
102803 +random_read_13815 random_read 3 13815 NULL
102804 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
102805 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
102806 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
102807 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
102808 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
102809 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
102810 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
102811 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
102812 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
102813 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
102814 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
102815 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
102816 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
102817 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
102818 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
102819 +com90xx_found_13974 com90xx_found 3 13974 NULL
102820 +qcam_read_13977 qcam_read 3 13977 NULL
102821 +dsp_read_13980 dsp_read 2 13980 NULL
102822 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
102823 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
102824 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
102825 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
102826 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
102827 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
102828 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
102829 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
102830 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
102831 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
102832 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
102833 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
102834 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
102835 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
102836 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
102837 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
102838 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
102839 +em_canid_change_14150 em_canid_change 3 14150 NULL
102840 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
102841 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
102842 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
102843 +alloc_async_14208 alloc_async 1 14208 NULL
102844 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
102845 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
102846 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
102847 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
102848 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
102849 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
102850 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
102851 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
102852 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
102853 +rr_status_14293 rr_status 5 14293 NULL
102854 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
102855 +oo_objects_14319 oo_objects 0 14319 NULL
102856 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
102857 +scsi2int_14358 scsi2int 0 14358 NULL
102858 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
102859 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
102860 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
102861 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
102862 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
102863 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
102864 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
102865 +block_size_14443 block_size 0 14443 NULL
102866 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
102867 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
102868 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
102869 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
102870 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
102871 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
102872 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
102873 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
102874 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
102875 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
102876 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
102877 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
102878 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
102879 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
102880 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
102881 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
102882 +dbJoin_14644 dbJoin 0 14644 NULL
102883 +profile_replace_14652 profile_replace 3 14652 NULL
102884 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
102885 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
102886 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
102887 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
102888 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
102889 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
102890 +get_bio_block_14714 get_bio_block 0 14714 NULL
102891 +vfd_write_14717 vfd_write 3 14717 NULL
102892 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
102893 +raid1_resize_14740 raid1_resize 2 14740 NULL
102894 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
102895 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
102896 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
102897 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
102898 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
102899 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
102900 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
102901 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
102902 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
102903 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
102904 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
102905 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
102906 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
102907 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
102908 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
102909 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
102910 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
102911 +unifi_read_14899 unifi_read 3 14899 NULL
102912 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
102913 +krealloc_14908 krealloc 2 14908 NULL
102914 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
102915 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
102916 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
102917 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
102918 +queue_cnt_14951 queue_cnt 0 14951 NULL
102919 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
102920 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
102921 +setkey_14987 setkey 3 14987 NULL nohasharray
102922 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
102923 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
102924 +vmap_15025 vmap 2 15025 NULL
102925 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
102926 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
102927 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
102928 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
102929 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
102930 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
102931 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
102932 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
102933 +start_port_15124 start_port 0 15124 NULL
102934 +memchr_15126 memchr 0 15126 NULL
102935 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
102936 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
102937 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
102938 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
102939 +reserve_resources_15194 reserve_resources 3 15194 NULL
102940 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
102941 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
102942 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
102943 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
102944 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
102945 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
102946 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
102947 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
102948 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
102949 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
102950 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
102951 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
102952 +ioread16_15342 ioread16 0 15342 NULL
102953 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
102954 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
102955 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
102956 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
102957 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
102958 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
102959 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
102960 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
102961 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
102962 +get_modalias_15406 get_modalias 2 15406 NULL
102963 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
102964 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
102965 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
102966 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
102967 +memweight_15450 memweight 2 15450 NULL
102968 +vmalloc_15464 vmalloc 1 15464 NULL
102969 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
102970 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
102971 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
102972 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
102973 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
102974 +persistent_status_15574 persistent_status 4 15574 NULL
102975 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
102976 +vme_user_write_15587 vme_user_write 3 15587 NULL
102977 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
102978 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
102979 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
102980 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
102981 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
102982 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
102983 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
102984 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
102985 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
102986 +fs_path_add_15648 fs_path_add 3 15648 NULL
102987 +xsd_read_15653 xsd_read 3 15653 NULL
102988 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
102989 +unix_bind_15668 unix_bind 3 15668 NULL
102990 +dm_read_15674 dm_read 3 15674 NULL
102991 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
102992 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
102993 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
102994 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
102995 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
102996 +do_test_15766 do_test 1 15766 NULL
102997 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
102998 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
102999 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
103000 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
103001 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
103002 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
103003 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
103004 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
103005 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
103006 +table_size_15851 table_size 0-1-2 15851 NULL
103007 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
103008 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
103009 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
103010 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
103011 +native_read_msr_15905 native_read_msr 0 15905 NULL
103012 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
103013 +power_read_15939 power_read 3 15939 NULL
103014 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
103015 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
103016 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
103017 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
103018 +frame_alloc_15981 frame_alloc 4 15981 NULL
103019 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
103020 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
103021 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
103022 +got_frame_16028 got_frame 2 16028 NULL
103023 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
103024 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
103025 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
103026 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
103027 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
103028 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
103029 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
103030 +fsm_init_16134 fsm_init 2 16134 NULL
103031 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
103032 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
103033 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
103034 +mapping_level_16188 mapping_level 2 16188 NULL
103035 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
103036 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
103037 +create_table_16213 create_table 2 16213 NULL
103038 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
103039 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
103040 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
103041 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
103042 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
103043 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
103044 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
103045 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
103046 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
103047 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
103048 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
103049 +account_16283 account 0-2-4 16283 NULL nohasharray
103050 +mirror_status_16283 mirror_status 5 16283 &account_16283
103051 +retry_instruction_16285 retry_instruction 2 16285 NULL
103052 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
103053 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
103054 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
103055 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
103056 +wb_map_16301 wb_map 2 16301 NULL
103057 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
103058 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
103059 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
103060 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
103061 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
103062 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
103063 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
103064 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
103065 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
103066 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
103067 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
103068 +raid10_resize_16537 raid10_resize 2 16537 NULL
103069 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
103070 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
103071 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
103072 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
103073 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
103074 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
103075 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
103076 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103077 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103078 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103079 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103080 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103081 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103082 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103083 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103084 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103085 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103086 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103087 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103088 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103089 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103090 +st_write_16874 st_write 3 16874 NULL
103091 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103092 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103093 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103094 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103095 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103096 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103097 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103098 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103099 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103100 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103101 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103102 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103103 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103104 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103105 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103106 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103107 +mac_address_string_17091 mac_address_string 0 17091 NULL
103108 +entry_length_17093 entry_length 0 17093 NULL
103109 +sys_preadv_17100 sys_preadv 3 17100 NULL
103110 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103111 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103112 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103113 +sep_read_17161 sep_read 3 17161 NULL
103114 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103115 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103116 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103117 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103118 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103119 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103120 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103121 +to_oblock_17254 to_oblock 0-1 17254 NULL
103122 +unpack_value_17259 unpack_value 1 17259 NULL
103123 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103124 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103125 +alloc_ep_17269 alloc_ep 1 17269 NULL
103126 +pg_read_17276 pg_read 3 17276 NULL
103127 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103128 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103129 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103130 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103131 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103132 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103133 +skb_pad_17302 skb_pad 2 17302 NULL
103134 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103135 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103136 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103137 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103138 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103139 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103140 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103141 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103142 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103143 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103144 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103145 +compat_cmd_17465 compat_cmd 2 17465 NULL
103146 +probe_bios_17467 probe_bios 1 17467 NULL
103147 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103148 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103149 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103150 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103151 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103152 +copy_from_user_17559 copy_from_user 3 17559 NULL
103153 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103154 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103155 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103156 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103157 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103158 +osst_execute_17607 osst_execute 7-6 17607 NULL
103159 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103160 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103161 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103162 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103163 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103164 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103165 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103166 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103167 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103168 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103169 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103170 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103171 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103172 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103173 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103174 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103175 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103176 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103177 +perf_clock_17787 perf_clock 0 17787 NULL
103178 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
103179 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
103180 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
103181 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
103182 +count_leafs_17842 count_leafs 0 17842 NULL
103183 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
103184 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
103185 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
103186 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
103187 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
103188 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
103189 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
103190 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
103191 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
103192 +recover_head_17904 recover_head 3 17904 NULL
103193 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
103194 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
103195 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
103196 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
103197 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
103198 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
103199 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
103200 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
103201 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
103202 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
103203 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
103204 +fill_read_18019 fill_read 0 18019 NULL
103205 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
103206 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
103207 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
103208 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
103209 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
103210 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
103211 +packet_came_18072 packet_came 3 18072 NULL
103212 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
103213 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
103214 +get_vm_area_18080 get_vm_area 1 18080 NULL
103215 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
103216 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
103217 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
103218 +svc_getnl_18120 svc_getnl 0 18120 NULL
103219 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
103220 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
103221 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
103222 +_has_tag_18169 _has_tag 2 18169 NULL
103223 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
103224 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
103225 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
103226 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
103227 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
103228 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
103229 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
103230 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
103231 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
103232 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
103233 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
103234 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
103235 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
103236 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
103237 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
103238 +um_idi_write_18293 um_idi_write 3 18293 NULL
103239 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
103240 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
103241 +vga_r_18310 vga_r 0 18310 NULL
103242 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
103243 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
103244 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
103245 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
103246 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
103247 +ep_io_18367 ep_io 0 18367 NULL
103248 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
103249 +ci_role_write_18388 ci_role_write 3 18388 NULL
103250 +__video_register_device_18399 __video_register_device 3 18399 NULL
103251 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
103252 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
103253 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
103254 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
103255 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
103256 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
103257 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
103258 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
103259 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
103260 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
103261 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
103262 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
103263 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
103264 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
103265 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
103266 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
103267 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
103268 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
103269 +debug_output_18575 debug_output 3 18575 NULL
103270 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
103271 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
103272 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
103273 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
103274 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
103275 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
103276 +from_buffer_18625 from_buffer 3 18625 NULL
103277 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
103278 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
103279 +unmap_page_18665 unmap_page 2-3 18665 NULL
103280 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
103281 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
103282 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
103283 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
103284 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
103285 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
103286 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
103287 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
103288 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
103289 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
103290 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
103291 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
103292 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
103293 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
103294 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
103295 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
103296 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
103297 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
103298 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
103299 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
103300 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
103301 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
103302 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
103303 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
103304 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
103305 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
103306 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
103307 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
103308 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
103309 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
103310 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
103311 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
103312 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
103313 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
103314 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
103315 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
103316 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
103317 +huge_page_size_19008 huge_page_size 0 19008 NULL
103318 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
103319 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
103320 +revalidate_19043 revalidate 2 19043 NULL
103321 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
103322 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
103323 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
103324 +msix_map_region_19072 msix_map_region 2 19072 NULL
103325 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
103326 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
103327 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
103328 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
103329 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
103330 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
103331 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
103332 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
103333 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
103334 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
103335 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
103336 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
103337 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
103338 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
103339 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
103340 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
103341 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
103342 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
103343 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
103344 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
103345 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
103346 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
103347 +qc_capture_19298 qc_capture 3 19298 NULL
103348 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
103349 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
103350 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
103351 +debug_read_19322 debug_read 3 19322 NULL
103352 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
103353 +closure_sub_19359 closure_sub 2 19359 NULL
103354 +read_zero_19366 read_zero 3 19366 NULL
103355 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
103356 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
103357 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
103358 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
103359 +__phys_addr_19434 __phys_addr 0 19434 NULL
103360 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
103361 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
103362 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
103363 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
103364 +sky2_read16_19475 sky2_read16 0 19475 NULL
103365 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
103366 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
103367 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
103368 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
103369 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
103370 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
103371 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
103372 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
103373 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
103374 +nfsd_read_19568 nfsd_read 5 19568 NULL
103375 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
103376 +bm_status_read_19583 bm_status_read 3 19583 NULL
103377 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
103378 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
103379 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
103380 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
103381 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
103382 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
103383 +bio_detain_19690 bio_detain 2 19690 NULL
103384 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
103385 +read_reg_19723 read_reg 0 19723 NULL
103386 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
103387 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
103388 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
103389 +p9_client_read_19750 p9_client_read 5 19750 NULL
103390 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
103391 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
103392 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
103393 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
103394 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
103395 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
103396 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
103397 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
103398 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
103399 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
103400 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
103401 +__nla_put_19857 __nla_put 3 19857 NULL
103402 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
103403 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
103404 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
103405 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
103406 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
103407 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
103408 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
103409 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
103410 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
103411 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
103412 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
103413 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
103414 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
103415 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
103416 +team_options_register_20091 team_options_register 3 20091 NULL
103417 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
103418 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
103419 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
103420 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
103421 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
103422 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
103423 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
103424 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
103425 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
103426 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
103427 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
103428 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
103429 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
103430 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
103431 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
103432 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
103433 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
103434 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
103435 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
103436 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
103437 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
103438 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
103439 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
103440 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
103441 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
103442 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
103443 +read_buf_20469 read_buf 2 20469 NULL
103444 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
103445 +fast_user_write_20494 fast_user_write 5 20494 NULL
103446 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
103447 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
103448 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
103449 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
103450 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
103451 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
103452 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
103453 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
103454 +venus_create_20555 venus_create 4 20555 NULL
103455 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
103456 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
103457 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
103458 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
103459 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
103460 +lirc_write_20604 lirc_write 3 20604 NULL
103461 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
103462 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
103463 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
103464 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
103465 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
103466 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
103467 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
103468 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
103469 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
103470 +cpumask_size_20683 cpumask_size 0 20683 NULL
103471 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
103472 +gru_vtop_20689 gru_vtop 2 20689 NULL
103473 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
103474 +__maestro_read_20700 __maestro_read 0 20700 NULL
103475 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
103476 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
103477 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
103478 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
103479 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
103480 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
103481 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
103482 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
103483 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
103484 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
103485 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
103486 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
103487 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
103488 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
103489 +sys_sendto_20809 sys_sendto 6 20809 NULL
103490 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
103491 +strndup_user_20819 strndup_user 2 20819 NULL
103492 +calc_layout_20829 calc_layout 3 20829 NULL
103493 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
103494 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
103495 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
103496 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
103497 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
103498 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
103499 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
103500 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
103501 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
103502 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
103503 +htable_bits_20933 htable_bits 0 20933 NULL
103504 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
103505 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
103506 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
103507 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
103508 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
103509 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
103510 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
103511 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
103512 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
103513 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
103514 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
103515 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
103516 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
103517 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
103518 +multipath_status_21094 multipath_status 5 21094 NULL
103519 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
103520 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
103521 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
103522 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
103523 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
103524 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
103525 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
103526 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
103527 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
103528 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
103529 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
103530 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
103531 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
103532 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
103533 +input_ff_create_21240 input_ff_create 2 21240 NULL
103534 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
103535 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
103536 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
103537 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
103538 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
103539 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
103540 +add_res_range_21310 add_res_range 4 21310 NULL
103541 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
103542 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
103543 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
103544 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
103545 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
103546 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
103547 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
103548 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
103549 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
103550 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
103551 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
103552 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
103553 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
103554 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
103555 +concat_writev_21451 concat_writev 3 21451 NULL
103556 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
103557 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
103558 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
103559 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
103560 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
103561 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
103562 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
103563 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
103564 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
103565 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
103566 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
103567 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
103568 +validate_nnode_21638 validate_nnode 0 21638 NULL
103569 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
103570 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
103571 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
103572 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
103573 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
103574 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
103575 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
103576 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
103577 +vm_brk_21739 vm_brk 1 21739 NULL
103578 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
103579 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
103580 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
103581 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
103582 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
103583 +min_odd_21802 min_odd 0 21802 NULL
103584 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
103585 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
103586 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
103587 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
103588 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
103589 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
103590 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
103591 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
103592 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
103593 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
103594 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
103595 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
103596 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
103597 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
103598 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
103599 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
103600 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
103601 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
103602 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
103603 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
103604 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
103605 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
103606 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
103607 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
103608 +write_opcode_22082 write_opcode 2 22082 NULL
103609 +mem_rw_22085 mem_rw 3 22085 NULL
103610 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
103611 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
103612 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
103613 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
103614 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
103615 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
103616 +compat_insn_22142 compat_insn 2 22142 NULL
103617 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
103618 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
103619 +fls_22210 fls 0 22210 NULL
103620 +mem_write_22232 mem_write 3 22232 NULL
103621 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
103622 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
103623 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
103624 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
103625 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
103626 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
103627 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
103628 +extend_brk_22301 extend_brk 0 22301 NULL
103629 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
103630 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
103631 +get_segment_base_22324 get_segment_base 0 22324 NULL
103632 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
103633 +atomic_read_22342 atomic_read 0 22342 NULL
103634 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
103635 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
103636 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
103637 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
103638 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
103639 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
103640 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
103641 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
103642 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
103643 +zoran_write_22404 zoran_write 3 22404 NULL
103644 +queue_reply_22416 queue_reply 3 22416 NULL
103645 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
103646 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
103647 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
103648 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
103649 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
103650 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
103651 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
103652 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
103653 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
103654 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
103655 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
103656 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
103657 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
103658 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
103659 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
103660 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
103661 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
103662 +snapshot_read_22601 snapshot_read 3 22601 NULL
103663 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
103664 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
103665 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
103666 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
103667 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
103668 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
103669 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
103670 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
103671 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
103672 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
103673 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
103674 +map_22700 map 2 22700 NULL
103675 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
103676 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
103677 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
103678 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
103679 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
103680 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
103681 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
103682 +print_frame_22769 print_frame 0 22769 NULL
103683 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
103684 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
103685 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
103686 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
103687 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
103688 +create_attr_set_22861 create_attr_set 1 22861 NULL
103689 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
103690 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
103691 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
103692 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
103693 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
103694 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
103695 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
103696 +vme_get_size_22964 vme_get_size 0 22964 NULL
103697 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
103698 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
103699 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
103700 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
103701 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
103702 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
103703 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
103704 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
103705 +st_status_23032 st_status 5 23032 NULL
103706 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
103707 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
103708 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
103709 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
103710 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
103711 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
103712 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
103713 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
103714 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
103715 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
103716 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
103717 +fls_long_23096 fls_long 0 23096 NULL
103718 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
103719 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
103720 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
103721 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
103722 +__clear_user_23118 __clear_user 0 23118 NULL
103723 +dm_write_async_23120 dm_write_async 3 23120 NULL
103724 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
103725 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
103726 +read_file_ani_23161 read_file_ani 3 23161 NULL
103727 +ioremap_23172 ioremap 1-2 23172 NULL
103728 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
103729 +usblp_write_23178 usblp_write 3 23178 NULL
103730 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
103731 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
103732 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
103733 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
103734 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
103735 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
103736 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
103737 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
103738 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
103739 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
103740 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
103741 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
103742 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
103743 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
103744 +doc_probe_23285 doc_probe 1 23285 NULL
103745 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
103746 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
103747 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
103748 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
103749 +page_readlink_23346 page_readlink 3 23346 NULL
103750 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
103751 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
103752 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
103753 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
103754 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
103755 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
103756 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
103757 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
103758 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
103759 +event_filter_read_23494 event_filter_read 3 23494 NULL
103760 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
103761 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
103762 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
103763 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
103764 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
103765 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
103766 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
103767 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
103768 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
103769 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
103770 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
103771 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
103772 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
103773 +sInW_23663 sInW 0 23663 NULL
103774 +SyS_connect_23669 SyS_connect 3 23669 NULL
103775 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
103776 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
103777 +cx18_read_23699 cx18_read 3 23699 NULL
103778 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
103779 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
103780 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
103781 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
103782 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
103783 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
103784 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
103785 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
103786 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
103787 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
103788 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
103789 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
103790 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
103791 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
103792 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
103793 +p54_init_common_23850 p54_init_common 1 23850 NULL
103794 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
103795 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
103796 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
103797 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
103798 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
103799 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
103800 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
103801 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
103802 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
103803 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
103804 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
103805 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
103806 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
103807 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
103808 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
103809 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
103810 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
103811 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
103812 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
103813 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
103814 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
103815 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
103816 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
103817 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
103818 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
103819 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
103820 +mpu401_read_24126 mpu401_read 3 24126 NULL
103821 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
103822 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
103823 +set_discard_24162 set_discard 2 24162 NULL
103824 +adu_read_24177 adu_read 3 24177 NULL
103825 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
103826 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
103827 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
103828 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
103829 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
103830 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
103831 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
103832 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
103833 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
103834 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
103835 +thin_status_24278 thin_status 5 24278 NULL
103836 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
103837 +msg_size_24288 msg_size 0 24288 NULL
103838 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
103839 +map_page_24298 map_page 3-4 24298 NULL
103840 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
103841 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
103842 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
103843 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
103844 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
103845 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
103846 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
103847 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
103848 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
103849 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
103850 +igetword_24373 igetword 0 24373 NULL
103851 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
103852 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
103853 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
103854 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
103855 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
103856 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
103857 +smk_user_access_24440 smk_user_access 3 24440 NULL
103858 +page_address_24444 page_address 0 24444 NULL
103859 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
103860 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
103861 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
103862 +pd_video_read_24510 pd_video_read 3 24510 NULL
103863 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
103864 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
103865 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
103866 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
103867 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
103868 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
103869 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
103870 +count_preds_24600 count_preds 0 24600 NULL
103871 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
103872 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
103873 +context_alloc_24645 context_alloc 3 24645 NULL
103874 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
103875 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
103876 +read_fs_24717 read_fs 0 24717 NULL
103877 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
103878 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
103879 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
103880 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
103881 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
103882 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
103883 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
103884 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
103885 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
103886 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
103887 +cache_read_24790 cache_read 3 24790 NULL
103888 +unpack_str_24798 unpack_str 0 24798 NULL
103889 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
103890 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
103891 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
103892 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
103893 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
103894 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
103895 +setup_buffering_24872 setup_buffering 3 24872 NULL
103896 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
103897 +queues_read_24877 queues_read 3 24877 NULL nohasharray
103898 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
103899 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
103900 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
103901 +next_token_24929 next_token 0 24929 NULL
103902 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
103903 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
103904 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
103905 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
103906 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
103907 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
103908 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
103909 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
103910 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
103911 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
103912 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
103913 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
103914 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
103915 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
103916 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
103917 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
103918 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
103919 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
103920 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
103921 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
103922 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
103923 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
103924 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
103925 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
103926 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
103927 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
103928 +stripe_status_25259 stripe_status 5 25259 NULL
103929 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
103930 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
103931 +vfs_writev_25278 vfs_writev 3 25278 NULL
103932 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
103933 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
103934 +help_25316 help 5 25316 NULL nohasharray
103935 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
103936 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
103937 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
103938 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
103939 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
103940 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
103941 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
103942 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
103943 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
103944 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
103945 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
103946 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
103947 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
103948 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
103949 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
103950 +sb_permission_25523 sb_permission 0 25523 NULL
103951 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
103952 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
103953 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
103954 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
103955 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
103956 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
103957 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
103958 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
103959 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
103960 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
103961 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
103962 +__direct_map_25647 __direct_map 5-6 25647 NULL
103963 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
103964 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
103965 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
103966 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
103967 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
103968 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
103969 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
103970 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
103971 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
103972 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
103973 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
103974 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
103975 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
103976 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
103977 +sg_read_25799 sg_read 3 25799 NULL
103978 +system_enable_read_25815 system_enable_read 3 25815 NULL
103979 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
103980 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
103981 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
103982 +parport_read_25855 parport_read 0 25855 NULL
103983 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
103984 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
103985 +key_attr_size_25865 key_attr_size 0 25865 NULL
103986 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
103987 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
103988 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
103989 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
103990 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
103991 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
103992 +rcname_read_25919 rcname_read 3 25919 NULL
103993 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
103994 +key_flags_read_25931 key_flags_read 3 25931 NULL
103995 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
103996 +flush_25957 flush 2 25957 NULL
103997 +video_register_device_25971 video_register_device 3 25971 NULL
103998 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
103999 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
104000 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
104001 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
104002 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
104003 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
104004 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
104005 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
104006 +tun_do_read_26047 tun_do_read 5 26047 NULL
104007 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
104008 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
104009 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
104010 +skb_cow_26138 skb_cow 2 26138 NULL
104011 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
104012 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
104013 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
104014 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
104015 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
104016 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
104017 +disk_devt_26180 disk_devt 0 26180 NULL
104018 +get_registers_26187 get_registers 3 26187 NULL
104019 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
104020 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
104021 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
104022 +mce_write_26201 mce_write 3 26201 NULL
104023 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
104024 +bio_split_26235 bio_split 2 26235 NULL
104025 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
104026 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
104027 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
104028 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
104029 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
104030 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
104031 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
104032 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
104033 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
104034 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
104035 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
104036 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
104037 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
104038 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
104039 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
104040 +read_vmcore_26501 read_vmcore 3 26501 NULL
104041 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
104042 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
104043 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
104044 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
104045 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
104046 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
104047 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
104048 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
104049 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
104050 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
104051 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
104052 +pack_value_26625 pack_value 1 26625 NULL
104053 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
104054 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
104055 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
104056 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
104057 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
104058 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
104059 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
104060 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
104061 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
104062 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
104063 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
104064 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
104065 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
104066 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
104067 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
104068 +smk_write_load_26829 smk_write_load 3 26829 NULL
104069 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
104070 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
104071 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
104072 +scnprint_id_26842 scnprint_id 3 26842 NULL
104073 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
104074 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
104075 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
104076 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104077 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104078 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104079 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104080 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104081 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104082 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104083 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104084 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104085 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104086 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104087 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104088 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104089 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104090 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104091 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104092 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104093 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104094 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104095 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104096 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104097 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104098 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104099 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104100 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104101 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104102 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104103 +pms_capture_27142 pms_capture 4 27142 NULL
104104 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104105 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104106 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104107 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104108 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104109 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104110 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104111 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104112 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104113 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104114 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104115 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104116 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104117 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104118 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104119 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104120 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104121 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104122 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104123 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104124 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104125 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104126 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104127 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104128 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104129 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104130 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104131 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104132 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104133 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104134 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104135 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104136 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104137 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104138 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104139 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104140 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104141 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104142 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104143 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104144 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104145 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104146 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104147 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104148 +qword_get_27670 qword_get 0 27670 NULL
104149 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104150 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104151 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104152 +evm_write_key_27715 evm_write_key 3 27715 NULL
104153 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104154 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104155 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104156 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104157 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104158 +kcalloc_27770 kcalloc 1-2 27770 NULL
104159 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104160 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104161 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104162 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104163 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104164 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104165 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104166 +read_profile_27859 read_profile 3 27859 NULL
104167 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104168 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104169 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104170 +gluebi_write_27905 gluebi_write 3 27905 NULL
104171 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104172 +bm_find_next_27929 bm_find_next 2 27929 NULL
104173 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104174 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104175 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104176 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104177 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
104178 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
104179 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
104180 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
104181 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
104182 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
104183 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
104184 +pool_status_28055 pool_status 5 28055 NULL
104185 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
104186 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
104187 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
104188 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
104189 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
104190 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
104191 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
104192 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
104193 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
104194 +video_read_28148 video_read 3 28148 NULL
104195 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
104196 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
104197 +vread_28173 vread 0 28173 NULL
104198 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
104199 +d_path_28198 d_path 0 28198 NULL
104200 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
104201 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
104202 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
104203 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
104204 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
104205 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
104206 +usemap_size_28281 usemap_size 0 28281 NULL
104207 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
104208 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
104209 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
104210 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
104211 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
104212 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
104213 +snapshot_write_28351 snapshot_write 3 28351 NULL
104214 +sys_writev_28384 sys_writev 3 28384 NULL
104215 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
104216 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
104217 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
104218 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
104219 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
104220 +__split_large_page_28429 __split_large_page 2 28429 NULL
104221 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
104222 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
104223 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
104224 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
104225 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
104226 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
104227 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
104228 +max_response_pages_28492 max_response_pages 0 28492 NULL
104229 +clear_discard_28494 clear_discard 2 28494 NULL
104230 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
104231 +__next_node_28521 __next_node 1 28521 NULL
104232 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
104233 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
104234 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
104235 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
104236 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
104237 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
104238 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
104239 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
104240 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
104241 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
104242 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
104243 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
104244 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
104245 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
104246 +_set_range_28627 _set_range 3 28627 NULL
104247 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
104248 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
104249 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
104250 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
104251 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
104252 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
104253 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
104254 +spi_execute_28736 spi_execute 5 28736 NULL
104255 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
104256 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
104257 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
104258 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
104259 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
104260 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
104261 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
104262 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
104263 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
104264 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
104265 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
104266 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
104267 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
104268 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
104269 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
104270 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
104271 +to_cblock_28899 to_cblock 0-1 28899 NULL
104272 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
104273 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
104274 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
104275 +push_rx_28939 push_rx 3 28939 NULL
104276 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
104277 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
104278 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
104279 +bin_uuid_28999 bin_uuid 3 28999 NULL
104280 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
104281 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
104282 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
104283 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
104284 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
104285 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
104286 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
104287 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
104288 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
104289 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
104290 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
104291 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
104292 +snprintf_29125 snprintf 0 29125 NULL
104293 +iov_shorten_29130 iov_shorten 0 29130 NULL
104294 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
104295 +reshape_ring_29147 reshape_ring 2 29147 NULL
104296 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
104297 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
104298 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
104299 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
104300 +__mm_populate_29204 __mm_populate 1 29204 NULL
104301 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
104302 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
104303 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
104304 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
104305 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
104306 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
104307 +recover_peb_29238 recover_peb 6-7 29238 NULL
104308 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
104309 +block_div_29268 block_div 0-1-2 29268 NULL
104310 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
104311 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
104312 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
104313 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
104314 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
104315 +tun_put_user_29337 tun_put_user 5 29337 NULL
104316 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
104317 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
104318 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
104319 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
104320 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
104321 +mempool_create_29437 mempool_create 1 29437 NULL
104322 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
104323 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
104324 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
104325 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
104326 +do_register_entry_29478 do_register_entry 4 29478 NULL
104327 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
104328 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
104329 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
104330 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
104331 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
104332 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
104333 +set_brk_29551 set_brk 1 29551 NULL nohasharray
104334 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
104335 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
104336 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
104337 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
104338 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
104339 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
104340 +slots_per_page_29601 slots_per_page 0 29601 NULL
104341 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
104342 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
104343 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
104344 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
104345 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
104346 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
104347 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
104348 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
104349 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
104350 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
104351 +probes_write_29711 probes_write 3 29711 NULL
104352 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
104353 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
104354 +std_nic_write_29752 std_nic_write 3 29752 NULL
104355 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
104356 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
104357 +dbAlloc_29794 dbAlloc 0 29794 NULL
104358 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
104359 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
104360 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
104361 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
104362 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
104363 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
104364 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
104365 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
104366 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
104367 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
104368 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
104369 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
104370 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
104371 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
104372 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
104373 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
104374 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
104375 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
104376 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
104377 +drp_wmove_30043 drp_wmove 4 30043 NULL
104378 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
104379 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
104380 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
104381 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
104382 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
104383 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
104384 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
104385 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
104386 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
104387 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
104388 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
104389 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
104390 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
104391 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
104392 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
104393 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
104394 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
104395 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
104396 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
104397 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
104398 +compat_readv_30273 compat_readv 3 30273 NULL
104399 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
104400 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
104401 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
104402 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
104403 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
104404 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
104405 +resource_from_user_30341 resource_from_user 3 30341 NULL
104406 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
104407 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
104408 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
104409 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
104410 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
104411 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
104412 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
104413 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
104414 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
104415 +mq_create_30425 mq_create 1 30425 NULL
104416 +enable_write_30456 enable_write 3 30456 NULL
104417 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
104418 +urandom_read_30462 urandom_read 3 30462 NULL
104419 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
104420 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
104421 +write_head_30481 write_head 4 30481 NULL
104422 +adu_write_30487 adu_write 3 30487 NULL
104423 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
104424 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
104425 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
104426 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
104427 +set_le_30581 set_le 4 30581 NULL
104428 +from_cblock_30582 from_cblock 0-1 30582 NULL
104429 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
104430 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
104431 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
104432 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
104433 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
104434 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
104435 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
104436 +agp_remap_30665 agp_remap 2 30665 NULL
104437 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
104438 +il_free_pages_30692 il_free_pages 2 30692 NULL
104439 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
104440 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
104441 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
104442 +snapshot_status_30744 snapshot_status 5 30744 NULL
104443 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
104444 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
104445 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
104446 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
104447 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
104448 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
104449 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
104450 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
104451 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
104452 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
104453 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
104454 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
104455 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
104456 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
104457 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
104458 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
104459 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
104460 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
104461 +sys_mincore_31079 sys_mincore 1 31079 NULL
104462 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
104463 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
104464 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
104465 +depth_read_31112 depth_read 3 31112 NULL
104466 +ssb_read16_31139 ssb_read16 0 31139 NULL
104467 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
104468 +size_inside_page_31141 size_inside_page 0 31141 NULL
104469 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
104470 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
104471 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
104472 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
104473 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
104474 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
104475 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
104476 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
104477 +__read_reg_31216 __read_reg 0 31216 NULL
104478 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
104479 +cyy_readb_31240 cyy_readb 0 31240 NULL
104480 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
104481 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
104482 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
104483 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
104484 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
104485 +command_file_write_31318 command_file_write 3 31318 NULL
104486 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
104487 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
104488 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
104489 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
104490 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
104491 +inb_31388 inb 0 31388 NULL
104492 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
104493 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
104494 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
104495 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
104496 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
104497 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
104498 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
104499 +do_fcntl_31468 do_fcntl 3 31468 NULL
104500 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
104501 +alg_setkey_31485 alg_setkey 3 31485 NULL
104502 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
104503 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
104504 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
104505 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
104506 +hidraw_write_31536 hidraw_write 3 31536 NULL
104507 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
104508 +usbvision_read_31555 usbvision_read 3 31555 NULL
104509 +normalize_31566 normalize 0-1-2 31566 NULL
104510 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
104511 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
104512 +osst_write_31581 osst_write 3 31581 NULL
104513 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
104514 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
104515 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
104516 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
104517 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
104518 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
104519 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
104520 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
104521 +__lgread_31668 __lgread 4 31668 NULL
104522 +symbol_string_31670 symbol_string 0 31670 NULL
104523 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
104524 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
104525 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
104526 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
104527 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
104528 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
104529 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
104530 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
104531 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
104532 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
104533 +muldiv64_31743 muldiv64 2-3 31743 NULL
104534 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
104535 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
104536 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
104537 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
104538 +get_count_order_31800 get_count_order 0 31800 NULL
104539 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
104540 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
104541 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
104542 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
104543 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
104544 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
104545 +xattr_permission_31907 xattr_permission 0 31907 NULL
104546 +new_dir_31919 new_dir 3 31919 NULL
104547 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
104548 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
104549 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
104550 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
104551 +vb2_write_31948 vb2_write 3 31948 NULL
104552 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
104553 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
104554 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
104555 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
104556 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
104557 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
104558 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
104559 +calc_hmac_32010 calc_hmac 3 32010 NULL
104560 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
104561 +aead_len_32021 aead_len 0 32021 NULL
104562 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
104563 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
104564 +stk_read_32038 stk_read 3 32038 NULL
104565 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
104566 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
104567 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
104568 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
104569 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
104570 +bio_alloc_32095 bio_alloc 2 32095 NULL
104571 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
104572 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
104573 +disk_status_32120 disk_status 4 32120 NULL
104574 +venus_link_32165 venus_link 5 32165 NULL
104575 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
104576 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
104577 +load_header_32183 load_header 0 32183 NULL
104578 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
104579 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
104580 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
104581 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
104582 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
104583 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
104584 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
104585 +hex_string_32310 hex_string 0 32310 NULL
104586 +SyS_select_32319 SyS_select 1 32319 NULL
104587 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
104588 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
104589 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
104590 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
104591 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
104592 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
104593 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
104594 +local_clock_32385 local_clock 0 32385 NULL
104595 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
104596 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
104597 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
104598 +log_text_32428 log_text 0 32428 NULL
104599 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
104600 +hid_input_report_32458 hid_input_report 4 32458 NULL
104601 +cache_status_32462 cache_status 5 32462 NULL
104602 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
104603 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
104604 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
104605 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
104606 +disconnect_32521 disconnect 4 32521 NULL
104607 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
104608 +ilo_read_32531 ilo_read 3 32531 NULL
104609 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
104610 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
104611 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
104612 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
104613 +__first_node_32558 __first_node 0 32558 NULL
104614 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
104615 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
104616 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
104617 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
104618 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
104619 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
104620 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
104621 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
104622 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
104623 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
104624 +kvmalloc_32646 kvmalloc 1 32646 NULL
104625 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
104626 +generic_readlink_32654 generic_readlink 3 32654 NULL
104627 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
104628 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
104629 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
104630 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
104631 +get_arg_page_32746 get_arg_page 2 32746 NULL
104632 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
104633 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
104634 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
104635 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
104636 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
104637 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
104638 +vga_rseq_32848 vga_rseq 0 32848 NULL
104639 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
104640 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
104641 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
104642 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
104643 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
104644 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
104645 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
104646 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
104647 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
104648 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
104649 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
104650 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
104651 +compat_filldir_32999 compat_filldir 3 32999 NULL
104652 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
104653 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
104654 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
104655 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
104656 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
104657 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
104658 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
104659 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
104660 +alloc_tio_33077 alloc_tio 3 33077 NULL
104661 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
104662 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
104663 +write_node_33121 write_node 4 33121 NULL
104664 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
104665 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
104666 +__len_within_target_33132 __len_within_target 0 33132 NULL
104667 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
104668 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
104669 +pp_read_33210 pp_read 3 33210 NULL
104670 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
104671 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
104672 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
104673 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
104674 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
104675 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
104676 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
104677 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
104678 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
104679 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
104680 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
104681 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
104682 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
104683 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
104684 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
104685 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
104686 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
104687 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
104688 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
104689 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
104690 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
104691 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
104692 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
104693 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
104694 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
104695 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
104696 +create_entry_33479 create_entry 2 33479 NULL
104697 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
104698 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
104699 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
104700 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
104701 +res_counter_read_33499 res_counter_read 4 33499 NULL
104702 +fb_read_33506 fb_read 3 33506 NULL
104703 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
104704 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
104705 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
104706 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
104707 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
104708 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
104709 +dup_array_33551 dup_array 3 33551 NULL
104710 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
104711 +count_subheaders_33591 count_subheaders 0 33591 NULL
104712 +scsi_execute_33596 scsi_execute 5 33596 NULL
104713 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
104714 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
104715 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
104716 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
104717 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
104718 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
104719 +inw_p_33668 inw_p 0 33668 NULL
104720 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
104721 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
104722 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
104723 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
104724 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
104725 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
104726 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
104727 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
104728 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
104729 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
104730 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
104731 +Read_hfc_33755 Read_hfc 0 33755 NULL
104732 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
104733 +hashtab_create_33769 hashtab_create 3 33769 NULL
104734 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
104735 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
104736 +find_next_offset_33804 find_next_offset 3 33804 NULL
104737 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
104738 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
104739 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
104740 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
104741 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
104742 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
104743 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
104744 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
104745 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
104746 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
104747 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
104748 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
104749 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
104750 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
104751 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
104752 +ppp_write_34034 ppp_write 3 34034 NULL
104753 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
104754 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
104755 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
104756 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
104757 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
104758 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
104759 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
104760 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
104761 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
104762 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
104763 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
104764 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
104765 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
104766 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
104767 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
104768 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
104769 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
104770 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
104771 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
104772 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
104773 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
104774 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
104775 +__insert_34349 __insert 2-3 34349 NULL
104776 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
104777 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
104778 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
104779 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
104780 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
104781 +ea_read_34378 ea_read 0 34378 NULL
104782 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
104783 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
104784 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
104785 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
104786 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
104787 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
104788 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
104789 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
104790 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
104791 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
104792 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
104793 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
104794 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
104795 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
104796 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
104797 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
104798 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
104799 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
104800 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
104801 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
104802 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
104803 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
104804 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
104805 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
104806 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
104807 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
104808 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
104809 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
104810 +port_print_34704 port_print 3 34704 NULL
104811 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
104812 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
104813 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
104814 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
104815 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
104816 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
104817 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
104818 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
104819 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
104820 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
104821 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
104822 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
104823 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
104824 +msg_print_text_34889 msg_print_text 0 34889 NULL
104825 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
104826 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
104827 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
104828 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
104829 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
104830 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
104831 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
104832 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
104833 +Realloc_34961 Realloc 2 34961 NULL
104834 +mq_lookup_34990 mq_lookup 2 34990 NULL
104835 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
104836 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
104837 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
104838 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
104839 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
104840 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
104841 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
104842 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
104843 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
104844 +store_ifalias_35088 store_ifalias 4 35088 NULL
104845 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
104846 +capi_write_35104 capi_write 3 35104 NULL nohasharray
104847 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
104848 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
104849 +pointer_35138 pointer 0 35138 NULL
104850 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
104851 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
104852 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
104853 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
104854 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
104855 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
104856 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
104857 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
104858 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
104859 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
104860 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
104861 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
104862 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
104863 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
104864 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
104865 +set_fd_set_35249 set_fd_set 1 35249 NULL
104866 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
104867 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
104868 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
104869 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
104870 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
104871 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
104872 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
104873 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
104874 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
104875 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
104876 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
104877 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
104878 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
104879 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
104880 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
104881 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
104882 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
104883 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
104884 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
104885 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
104886 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
104887 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
104888 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
104889 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
104890 +async_setkey_35521 async_setkey 3 35521 NULL
104891 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
104892 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
104893 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
104894 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
104895 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
104896 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
104897 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
104898 +ReadZReg_35604 ReadZReg 0 35604 NULL
104899 +kernel_readv_35617 kernel_readv 3 35617 NULL
104900 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
104901 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
104902 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
104903 +store_debug_level_35652 store_debug_level 3 35652 NULL
104904 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
104905 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
104906 +dm_table_create_35687 dm_table_create 3 35687 NULL
104907 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
104908 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
104909 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
104910 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
104911 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
104912 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
104913 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
104914 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
104915 +fls64_35862 fls64 0 35862 NULL
104916 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
104917 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
104918 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
104919 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
104920 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
104921 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
104922 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
104923 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
104924 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
104925 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
104926 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
104927 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
104928 +acl_alloc_35979 acl_alloc 1 35979 NULL
104929 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
104930 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
104931 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
104932 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
104933 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
104934 +account_shadowed_36048 account_shadowed 2 36048 NULL
104935 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
104936 +write_emulate_36065 write_emulate 2-4 36065 NULL
104937 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
104938 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
104939 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
104940 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
104941 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
104942 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
104943 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
104944 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
104945 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
104946 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
104947 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
104948 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
104949 +twl_set_36154 twl_set 2 36154 NULL
104950 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
104951 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
104952 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
104953 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
104954 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
104955 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
104956 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
104957 +is_dirty_36223 is_dirty 2 36223 NULL
104958 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
104959 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
104960 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
104961 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
104962 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
104963 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
104964 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
104965 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
104966 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
104967 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
104968 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
104969 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
104970 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
104971 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
104972 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
104973 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
104974 +lc_create_36332 lc_create 4 36332 NULL
104975 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
104976 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
104977 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
104978 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
104979 +to_sector_36361 to_sector 0-1 36361 NULL
104980 +tunables_read_36385 tunables_read 3 36385 NULL
104981 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
104982 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
104983 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
104984 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
104985 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
104986 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
104987 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
104988 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
104989 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
104990 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
104991 +get_param_l_36518 get_param_l 0 36518 NULL
104992 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
104993 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
104994 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
104995 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
104996 +get_entry_len_36549 get_entry_len 0 36549 NULL
104997 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
104998 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
104999 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
105000 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
105001 +__erst_read_36579 __erst_read 0 36579 NULL
105002 +put_cmsg_36589 put_cmsg 4 36589 NULL
105003 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
105004 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
105005 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
105006 +format_decode_36638 format_decode 0 36638 NULL
105007 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
105008 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
105009 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
105010 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
105011 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
105012 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
105013 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
105014 +sched_clock_36717 sched_clock 0 36717 NULL
105015 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
105016 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
105017 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
105018 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
105019 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
105020 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
105021 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
105022 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
105023 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
105024 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
105025 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
105026 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
105027 +cm_write_36858 cm_write 3 36858 NULL
105028 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
105029 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
105030 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
105031 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
105032 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
105033 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
105034 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
105035 +build_key_36931 build_key 1 36931 NULL
105036 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
105037 +write_leb_36957 write_leb 5 36957 NULL
105038 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
105039 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
105040 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
105041 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
105042 +setxattr_37006 setxattr 4 37006 NULL
105043 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
105044 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
105045 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
105046 +parse_command_37079 parse_command 2 37079 NULL
105047 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
105048 +tun_get_user_37094 tun_get_user 5 37094 NULL
105049 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
105050 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
105051 +msg_word_37164 msg_word 0 37164 NULL
105052 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
105053 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
105054 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
105055 +__do_replace_37227 __do_replace 5 37227 NULL
105056 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
105057 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
105058 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
105059 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
105060 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
105061 +c101_run_37279 c101_run 2 37279 NULL
105062 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
105063 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
105064 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
105065 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
105066 +send_msg_37323 send_msg 4 37323 NULL
105067 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
105068 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
105069 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
105070 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
105071 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
105072 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
105073 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
105074 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
105075 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
105076 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105077 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105078 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105079 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105080 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105081 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105082 +__remove_37457 __remove 2 37457 NULL
105083 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105084 +get_est_timing_37484 get_est_timing 0 37484 NULL
105085 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105086 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105087 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105088 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105089 +hdr_size_37536 hdr_size 0 37536 NULL
105090 +a2p_37544 a2p 0-1 37544 NULL
105091 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105092 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105093 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105094 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105095 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105096 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105097 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105098 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105099 +check_pt_base_37635 check_pt_base 3 37635 NULL
105100 +alloc_fd_37637 alloc_fd 1 37637 NULL
105101 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105102 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105103 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105104 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105105 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105106 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105107 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105108 +nametbl_header_37698 nametbl_header 2 37698 NULL
105109 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105110 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105111 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105112 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105113 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105114 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105115 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105116 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105117 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105118 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105119 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105120 +deny_write_access_37813 deny_write_access 0 37813 NULL
105121 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105122 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105123 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105124 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105125 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105126 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105127 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105128 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105129 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105130 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105131 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105132 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105133 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105134 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105135 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105136 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105137 +vfs_readv_38011 vfs_readv 3 38011 NULL
105138 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105139 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105140 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105141 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105142 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105143 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105144 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105145 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105146 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105147 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105148 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105149 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105150 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105151 +ep0_read_38095 ep0_read 3 38095 NULL
105152 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105153 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105154 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105155 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105156 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105157 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105158 +cdev_add_38176 cdev_add 2-3 38176 NULL
105159 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105160 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105161 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105162 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105163 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105164 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105165 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105166 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105167 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105168 +from_dblock_38256 from_dblock 0-1 38256 NULL
105169 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105170 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105171 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105172 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105173 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105174 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105175 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105176 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105177 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
105178 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
105179 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
105180 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
105181 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
105182 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
105183 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
105184 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
105185 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
105186 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
105187 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
105188 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
105189 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
105190 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
105191 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
105192 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
105193 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
105194 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
105195 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
105196 +dev_names_read_38509 dev_names_read 3 38509 NULL
105197 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
105198 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
105199 +set_queue_count_38519 set_queue_count 0 38519 NULL
105200 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
105201 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
105202 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
105203 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
105204 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
105205 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
105206 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
105207 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
105208 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
105209 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
105210 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
105211 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
105212 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
105213 +cma_create_area_38642 cma_create_area 2 38642 NULL
105214 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
105215 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
105216 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
105217 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
105218 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
105219 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
105220 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
105221 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
105222 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
105223 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
105224 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
105225 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
105226 +udf_readpages_38761 udf_readpages 4 38761 NULL
105227 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
105228 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
105229 +err_decode_38804 err_decode 2 38804 NULL
105230 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
105231 +sys_select_38827 sys_select 1 38827 NULL
105232 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
105233 +direct_entry_38836 direct_entry 3 38836 NULL
105234 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
105235 +interfaces_38859 interfaces 2 38859 NULL
105236 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
105237 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
105238 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
105239 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
105240 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
105241 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
105242 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
105243 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
105244 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
105245 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
105246 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
105247 +udf_new_block_38999 udf_new_block 4 38999 NULL
105248 +get_nodes_39012 get_nodes 3 39012 NULL
105249 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
105250 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
105251 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
105252 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
105253 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
105254 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
105255 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
105256 +ea_foreach_39133 ea_foreach 0 39133 NULL
105257 +generic_permission_39150 generic_permission 0 39150 NULL
105258 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
105259 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
105260 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
105261 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
105262 +init_list_set_39188 init_list_set 2-3 39188 NULL
105263 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
105264 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
105265 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
105266 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
105267 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
105268 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
105269 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
105270 +drm_order_39244 drm_order 0 39244 NULL
105271 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
105272 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
105273 +__skb_cow_39254 __skb_cow 2 39254 NULL
105274 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
105275 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
105276 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
105277 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
105278 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
105279 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
105280 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
105281 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
105282 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
105283 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
105284 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
105285 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
105286 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
105287 +__send_to_port_39386 __send_to_port 3 39386 NULL
105288 +user_power_read_39414 user_power_read 3 39414 NULL
105289 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
105290 +sys_semop_39457 sys_semop 3 39457 NULL
105291 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
105292 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
105293 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
105294 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
105295 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
105296 +int_proc_write_39542 int_proc_write 3 39542 NULL
105297 +pp_write_39554 pp_write 3 39554 NULL
105298 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
105299 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
105300 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
105301 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
105302 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
105303 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
105304 +ext_depth_39607 ext_depth 0 39607 NULL
105305 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
105306 +sdio_readb_39618 sdio_readb 0 39618 NULL
105307 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
105308 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
105309 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
105310 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
105311 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
105312 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
105313 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
105314 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
105315 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
105316 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
105317 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
105318 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
105319 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
105320 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
105321 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
105322 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
105323 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
105324 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
105325 +pkt_add_39897 pkt_add 3 39897 NULL
105326 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
105327 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
105328 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
105329 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
105330 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
105331 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
105332 +__spi_async_39932 __spi_async 0 39932 NULL
105333 +__get_order_39935 __get_order 0 39935 NULL
105334 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
105335 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
105336 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
105337 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
105338 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
105339 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
105340 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
105341 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
105342 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
105343 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
105344 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
105345 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
105346 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
105347 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
105348 +add_tty_40055 add_tty 1 40055 NULL nohasharray
105349 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
105350 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
105351 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
105352 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
105353 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
105354 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
105355 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
105356 +pt_write_40159 pt_write 3 40159 NULL
105357 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
105358 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
105359 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
105360 +allocate_probes_40204 allocate_probes 1 40204 NULL
105361 +compat_put_long_40214 compat_put_long 1 40214 NULL
105362 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
105363 +osst_read_40237 osst_read 3 40237 NULL
105364 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
105365 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
105366 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
105367 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
105368 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
105369 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
105370 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
105371 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
105372 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
105373 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
105374 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
105375 +mmio_read_40348 mmio_read 4 40348 NULL
105376 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
105377 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
105378 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
105379 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
105380 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
105381 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
105382 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
105383 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
105384 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
105385 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
105386 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
105387 +tty_write_room_40495 tty_write_room 0 40495 NULL
105388 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
105389 +sg_phys_40507 sg_phys 0 40507 NULL
105390 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
105391 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
105392 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
105393 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
105394 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
105395 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
105396 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
105397 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
105398 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
105399 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
105400 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
105401 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
105402 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
105403 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
105404 +fops_read_40672 fops_read 3 40672 NULL
105405 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
105406 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
105407 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
105408 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
105409 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
105410 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
105411 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
105412 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
105413 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
105414 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
105415 +card_send_command_40757 card_send_command 3 40757 NULL
105416 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
105417 +pg_write_40766 pg_write 3 40766 NULL
105418 +show_list_40775 show_list 3 40775 NULL
105419 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
105420 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
105421 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
105422 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
105423 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
105424 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
105425 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
105426 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
105427 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
105428 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
105429 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
105430 +read_file_queue_40895 read_file_queue 3 40895 NULL
105431 +waiters_read_40902 waiters_read 3 40902 NULL
105432 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
105433 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
105434 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
105435 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
105436 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
105437 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
105438 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
105439 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
105440 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
105441 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
105442 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
105443 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
105444 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
105445 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
105446 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
105447 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
105448 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
105449 +dma_attach_41094 dma_attach 5-6 41094 NULL
105450 +provide_user_output_41105 provide_user_output 3 41105 NULL
105451 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
105452 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
105453 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
105454 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
105455 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
105456 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
105457 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
105458 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
105459 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
105460 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
105461 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
105462 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
105463 +erst_read_41260 erst_read 0 41260 NULL
105464 +__fprog_create_41263 __fprog_create 2 41263 NULL
105465 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
105466 +alloc_context_41283 alloc_context 1 41283 NULL
105467 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
105468 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
105469 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
105470 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
105471 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
105472 +kmp_init_41373 kmp_init 2 41373 NULL
105473 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
105474 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
105475 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
105476 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
105477 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
105478 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
105479 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
105480 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
105481 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
105482 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
105483 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
105484 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
105485 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
105486 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
105487 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
105488 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
105489 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
105490 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
105491 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
105492 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
105493 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
105494 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
105495 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
105496 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
105497 +vga_io_r_41609 vga_io_r 0 41609 NULL
105498 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
105499 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
105500 +a2mp_send_41615 a2mp_send 4 41615 NULL
105501 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
105502 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
105503 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
105504 +get_std_timing_41654 get_std_timing 0 41654 NULL
105505 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
105506 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
105507 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
105508 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
105509 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
105510 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
105511 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
105512 +fillonedir_41746 fillonedir 3 41746 NULL
105513 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
105514 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
105515 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
105516 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
105517 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
105518 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
105519 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
105520 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
105521 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
105522 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
105523 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
105524 +get_packet_41914 get_packet 3 41914 NULL
105525 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
105526 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
105527 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
105528 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
105529 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
105530 +read_gssp_41947 read_gssp 3 41947 NULL
105531 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
105532 +portnames_read_41958 portnames_read 3 41958 NULL
105533 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
105534 +dst_mtu_41969 dst_mtu 0 41969 NULL
105535 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
105536 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
105537 +lguest_map_42008 lguest_map 1-2 42008 NULL
105538 +pool_allocate_42012 pool_allocate 3 42012 NULL
105539 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
105540 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
105541 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
105542 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
105543 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
105544 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
105545 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
105546 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
105547 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
105548 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
105549 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
105550 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
105551 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
105552 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
105553 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
105554 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
105555 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
105556 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
105557 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
105558 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
105559 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
105560 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
105561 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
105562 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
105563 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
105564 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
105565 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
105566 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
105567 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
105568 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
105569 +free_cblock_42318 free_cblock 2 42318 NULL
105570 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
105571 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
105572 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
105573 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
105574 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
105575 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
105576 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
105577 +krng_get_random_42420 krng_get_random 3 42420 NULL
105578 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
105579 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
105580 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
105581 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
105582 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
105583 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
105584 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
105585 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
105586 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
105587 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
105588 +bypass_write_42498 bypass_write 3 42498 NULL
105589 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
105590 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
105591 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
105592 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
105593 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
105594 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
105595 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
105596 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
105597 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
105598 +map_state_42602 map_state 1 42602 NULL nohasharray
105599 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
105600 +nd_get_link_42603 nd_get_link 0 42603 NULL
105601 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
105602 +resp_write_42628 resp_write 2 42628 NULL
105603 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
105604 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
105605 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
105606 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
105607 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
105608 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
105609 +vb2_read_42703 vb2_read 3 42703 NULL
105610 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
105611 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
105612 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
105613 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
105614 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
105615 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
105616 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
105617 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
105618 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
105619 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
105620 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
105621 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
105622 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
105623 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
105624 +set_arg_42824 set_arg 3 42824 NULL
105625 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
105626 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
105627 +prandom_u32_42853 prandom_u32 0 42853 NULL
105628 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
105629 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
105630 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
105631 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
105632 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
105633 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
105634 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
105635 +hd_end_request_42904 hd_end_request 2 42904 NULL
105636 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
105637 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
105638 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
105639 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
105640 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
105641 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
105642 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
105643 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
105644 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
105645 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
105646 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
105647 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
105648 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
105649 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
105650 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
105651 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
105652 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
105653 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
105654 +uuid_string_43154 uuid_string 0 43154 NULL
105655 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
105656 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
105657 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
105658 +process_measurement_43190 process_measurement 0 43190 NULL
105659 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
105660 +uio_write_43202 uio_write 3 43202 NULL
105661 +iso_callback_43208 iso_callback 3 43208 NULL
105662 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
105663 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
105664 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
105665 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
105666 +fixup_leb_43256 fixup_leb 3 43256 NULL
105667 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
105668 +evtchn_write_43278 evtchn_write 3 43278 NULL
105669 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
105670 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
105671 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
105672 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
105673 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
105674 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
105675 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
105676 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
105677 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
105678 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
105679 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
105680 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
105681 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
105682 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
105683 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
105684 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
105685 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
105686 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
105687 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
105688 +do_readlink_43518 do_readlink 2 43518 NULL
105689 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
105690 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
105691 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
105692 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
105693 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
105694 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
105695 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
105696 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
105697 +proc_read_43614 proc_read 3 43614 NULL
105698 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
105699 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
105700 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
105701 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
105702 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
105703 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
105704 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
105705 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
105706 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
105707 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
105708 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
105709 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
105710 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
105711 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
105712 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
105713 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
105714 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
105715 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
105716 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
105717 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
105718 +read_flush_43851 read_flush 3 43851 NULL
105719 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
105720 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
105721 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
105722 +SendString_43928 SendString 3 43928 NULL
105723 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
105724 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
105725 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
105726 +nla_reserve_43984 nla_reserve 3 43984 NULL
105727 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
105728 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
105729 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
105730 +emit_flags_44006 emit_flags 4-3 44006 NULL
105731 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
105732 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
105733 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
105734 +load_discard_44083 load_discard 3 44083 NULL
105735 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
105736 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
105737 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
105738 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
105739 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
105740 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
105741 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
105742 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
105743 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
105744 +__set_free_44211 __set_free 2 44211 NULL
105745 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
105746 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
105747 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
105748 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
105749 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
105750 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
105751 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
105752 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
105753 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
105754 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
105755 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
105756 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
105757 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
105758 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
105759 +__is_discarded_44359 __is_discarded 2 44359 NULL
105760 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
105761 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
105762 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
105763 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
105764 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
105765 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
105766 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
105767 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
105768 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
105769 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
105770 +bio_advance_44496 bio_advance 2 44496 NULL
105771 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
105772 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
105773 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
105774 +spidev_write_44510 spidev_write 3 44510 NULL
105775 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
105776 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
105777 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
105778 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
105779 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
105780 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
105781 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
105782 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
105783 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
105784 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
105785 +mpi_resize_44674 mpi_resize 2 44674 NULL
105786 +ts_read_44687 ts_read 3 44687 NULL
105787 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
105788 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
105789 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
105790 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
105791 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
105792 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
105793 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
105794 +set_brk_44749 set_brk 1 44749 NULL
105795 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
105796 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
105797 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
105798 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
105799 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
105800 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
105801 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
105802 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
105803 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
105804 +sisusb_write_44834 sisusb_write 3 44834 NULL
105805 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
105806 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
105807 +cubic_root_44848 cubic_root 1 44848 NULL
105808 +copydesc_user_44855 copydesc_user 3 44855 NULL
105809 +skb_availroom_44883 skb_availroom 0 44883 NULL
105810 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
105811 +do_tty_write_44896 do_tty_write 5 44896 NULL
105812 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
105813 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
105814 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
105815 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
105816 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
105817 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
105818 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
105819 +sel_write_user_45060 sel_write_user 3 45060 NULL
105820 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
105821 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
105822 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
105823 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
105824 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
105825 +usbdev_read_45114 usbdev_read 3 45114 NULL
105826 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
105827 +send_to_tty_45141 send_to_tty 3 45141 NULL
105828 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
105829 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
105830 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
105831 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
105832 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
105833 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
105834 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
105835 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
105836 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
105837 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
105838 +add_child_45201 add_child 4 45201 NULL
105839 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
105840 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
105841 +__dirty_45228 __dirty 2 45228 NULL
105842 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
105843 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
105844 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
105845 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
105846 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
105847 +pte_val_45313 pte_val 0 45313 NULL
105848 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
105849 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
105850 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
105851 +keymap_store_45406 keymap_store 4 45406 NULL
105852 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
105853 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
105854 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
105855 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
105856 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
105857 +__node_remap_45458 __node_remap 4 45458 NULL
105858 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
105859 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
105860 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
105861 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
105862 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
105863 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
105864 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
105865 +copy_macs_45534 copy_macs 4 45534 NULL
105866 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
105867 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
105868 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
105869 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
105870 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
105871 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
105872 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
105873 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
105874 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
105875 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
105876 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
105877 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
105878 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
105879 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
105880 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
105881 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
105882 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
105883 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
105884 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
105885 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
105886 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
105887 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
105888 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
105889 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
105890 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
105891 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
105892 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
105893 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
105894 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
105895 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
105896 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
105897 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
105898 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
105899 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
105900 +isdn_write_45863 isdn_write 3 45863 NULL
105901 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
105902 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
105903 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
105904 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
105905 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
105906 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
105907 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
105908 +alloc_mr_45935 alloc_mr 1 45935 NULL
105909 +split_large_page_45941 split_large_page 2 45941 NULL
105910 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
105911 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
105912 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
105913 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
105914 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
105915 +get_free_entries_46030 get_free_entries 1 46030 NULL
105916 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
105917 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
105918 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
105919 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
105920 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
105921 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
105922 +slhc_toss_46066 slhc_toss 0 46066 NULL
105923 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
105924 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
105925 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
105926 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
105927 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
105928 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
105929 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
105930 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
105931 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
105932 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
105933 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
105934 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
105935 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
105936 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
105937 +add_conn_list_46197 add_conn_list 3 46197 NULL
105938 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
105939 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
105940 +dsp_write_46218 dsp_write 2 46218 NULL
105941 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
105942 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
105943 +ReadReg_46277 ReadReg 0 46277 NULL
105944 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
105945 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
105946 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
105947 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
105948 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
105949 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
105950 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
105951 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
105952 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
105953 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
105954 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
105955 +filldir64_46469 filldir64 3 46469 NULL
105956 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
105957 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
105958 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
105959 +kmsg_read_46514 kmsg_read 3 46514 NULL
105960 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
105961 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
105962 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
105963 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
105964 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
105965 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
105966 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
105967 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
105968 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
105969 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
105970 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
105971 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
105972 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
105973 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
105974 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
105975 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
105976 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
105977 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
105978 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
105979 +prepare_copy_46725 prepare_copy 2 46725 NULL
105980 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
105981 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
105982 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
105983 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
105984 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
105985 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
105986 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
105987 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
105988 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
105989 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
105990 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
105991 +spi_async_46857 spi_async 0 46857 NULL
105992 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
105993 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
105994 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
105995 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
105996 +rvmalloc_46873 rvmalloc 1 46873 NULL
105997 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
105998 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
105999 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
106000 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
106001 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
106002 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
106003 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
106004 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
106005 +fb_write_46924 fb_write 3 46924 NULL
106006 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
106007 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
106008 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
106009 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
106010 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
106011 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
106012 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
106013 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
106014 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
106015 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
106016 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
106017 +__map_single_47020 __map_single 3-4-7 47020 NULL
106018 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
106019 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
106020 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
106021 +fs_path_len_47060 fs_path_len 0 47060 NULL
106022 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
106023 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
106024 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
106025 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
106026 +mousedev_read_47123 mousedev_read 3 47123 NULL
106027 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
106028 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
106029 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
106030 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
106031 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
106032 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
106033 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
106034 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
106035 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
106036 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
106037 +l2headersize_47238 l2headersize 0 47238 NULL
106038 +options_write_47243 options_write 3 47243 NULL
106039 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
106040 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
106041 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
106042 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
106043 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
106044 +vsnprintf_47291 vsnprintf 0 47291 NULL
106045 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
106046 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
106047 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
106048 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
106049 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
106050 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
106051 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
106052 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
106053 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
106054 +nametbl_list_47391 nametbl_list 2 47391 NULL
106055 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
106056 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
106057 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
106058 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
106059 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
106060 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
106061 +vzalloc_47421 vzalloc 1 47421 NULL
106062 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
106063 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
106064 +__load_mapping_47460 __load_mapping 2 47460 NULL
106065 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
106066 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
106067 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
106068 +core_sys_select_47494 core_sys_select 1 47494 NULL
106069 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
106070 +unlink_simple_47506 unlink_simple 3 47506 NULL
106071 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
106072 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
106073 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
106074 +oz_events_read_47535 oz_events_read 3 47535 NULL
106075 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
106076 +read_ldt_47570 read_ldt 2 47570 NULL
106077 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106078 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106079 +pci_iomap_47575 pci_iomap 3 47575 NULL
106080 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106081 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106082 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106083 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106084 +uea_request_47613 uea_request 4 47613 NULL
106085 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106086 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106087 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106088 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106089 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106090 +save_microcode_47717 save_microcode 3 47717 NULL
106091 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106092 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106093 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106094 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106095 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106096 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106097 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106098 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106099 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106100 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106101 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106102 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106103 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106104 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106105 +vhci_read_47878 vhci_read 3 47878 NULL
106106 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106107 +load_mapping_47904 load_mapping 3 47904 NULL
106108 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106109 +comedi_write_47926 comedi_write 3 47926 NULL
106110 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106111 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106112 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106113 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106114 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106115 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106116 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106117 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106118 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106119 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106120 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106121 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106122 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106123 +disc_write_48070 disc_write 3 48070 NULL
106124 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106125 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106126 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106127 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106128 +set_discoverable_48141 set_discoverable 4 48141 NULL
106129 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106130 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106131 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106132 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106133 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106134 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106135 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106136 +init_ipath_48187 init_ipath 1 48187 NULL
106137 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106138 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106139 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106140 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106141 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106142 +read_file_recv_48232 read_file_recv 3 48232 NULL
106143 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106144 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106145 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106146 +send_set_info_48288 send_set_info 7 48288 NULL
106147 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106148 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106149 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106150 +hash_setkey_48310 hash_setkey 3 48310 NULL
106151 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106152 +skb_add_data_48363 skb_add_data 3 48363 NULL
106153 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106154 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106155 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106156 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106157 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106158 +print_filtered_48442 print_filtered 2-0 48442 NULL
106159 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106160 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106161 +send_control_msg_48498 send_control_msg 6 48498 NULL
106162 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106163 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106164 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106165 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106166 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106167 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106168 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106169 +named_distribute_48544 named_distribute 4 48544 NULL
106170 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106171 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106172 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106173 +mtd_read_48655 mtd_read 0 48655 NULL
106174 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106175 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106176 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106177 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
106178 +altera_drscan_48698 altera_drscan 2 48698 NULL
106179 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
106180 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
106181 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
106182 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
106183 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
106184 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
106185 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
106186 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
106187 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
106188 +azx_get_position_48841 azx_get_position 0 48841 NULL
106189 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
106190 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
106191 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
106192 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
106193 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
106194 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
106195 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
106196 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
106197 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
106198 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
106199 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
106200 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
106201 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
106202 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
106203 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
106204 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
106205 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
106206 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
106207 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
106208 +transient_status_49027 transient_status 4 49027 NULL
106209 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
106210 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
106211 +ubi_read_49061 ubi_read 0 49061 NULL
106212 +scsi_register_49094 scsi_register 2 49094 NULL
106213 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
106214 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
106215 +check_exists_49119 check_exists 2 49119 NULL nohasharray
106216 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
106217 +pt_read_49136 pt_read 3 49136 NULL
106218 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
106219 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
106220 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
106221 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
106222 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
106223 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
106224 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
106225 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
106226 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
106227 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
106228 +resp_write_same_49217 resp_write_same 2 49217 NULL
106229 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
106230 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
106231 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
106232 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
106233 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
106234 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
106235 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
106236 +uio_read_49300 uio_read 3 49300 NULL
106237 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
106238 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
106239 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
106240 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
106241 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
106242 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
106243 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
106244 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
106245 +px_raw_event_49371 px_raw_event 4 49371 NULL
106246 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
106247 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
106248 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
106249 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
106250 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
106251 +md_domain_init_49432 md_domain_init 2 49432 NULL
106252 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
106253 +get_lru_size_49441 get_lru_size 0 49441 NULL
106254 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
106255 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
106256 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
106257 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
106258 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
106259 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
106260 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
106261 +smk_write_access_49561 smk_write_access 3 49561 NULL
106262 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
106263 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
106264 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
106265 +tap_write_49595 tap_write 3 49595 NULL
106266 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
106267 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
106268 +heap_init_49617 heap_init 2 49617 NULL
106269 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
106270 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
106271 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
106272 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
106273 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
106274 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
106275 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
106276 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
106277 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
106278 +check_frame_49741 check_frame 0 49741 NULL
106279 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
106280 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
106281 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
106282 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
106283 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
106284 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
106285 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
106286 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
106287 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
106288 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
106289 +add_uuid_49831 add_uuid 4 49831 NULL
106290 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
106291 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
106292 +twl4030_write_49846 twl4030_write 2 49846 NULL
106293 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
106294 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
106295 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
106296 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
106297 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
106298 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
106299 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
106300 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
106301 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
106302 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
106303 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
106304 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
106305 +__module_alloc_50004 __module_alloc 1 50004 NULL
106306 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
106307 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
106308 +isdn_read_50021 isdn_read 3 50021 NULL
106309 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
106310 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
106311 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
106312 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
106313 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
106314 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
106315 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
106316 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
106317 +read_file_slot_50111 read_file_slot 3 50111 NULL
106318 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
106319 +copy_items_50140 copy_items 6 50140 NULL
106320 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
106321 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
106322 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
106323 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
106324 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
106325 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
106326 +odev_update_50169 odev_update 2 50169 NULL
106327 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
106328 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
106329 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
106330 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
106331 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
106332 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
106333 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
106334 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
106335 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
106336 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
106337 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
106338 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
106339 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
106340 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
106341 +do_launder_page_50329 do_launder_page 0 50329 NULL
106342 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
106343 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
106344 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
106345 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
106346 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
106347 +tpm_read_50344 tpm_read 3 50344 NULL
106348 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
106349 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
106350 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
106351 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
106352 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
106353 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
106354 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
106355 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
106356 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
106357 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
106358 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
106359 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
106360 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
106361 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
106362 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
106363 +force_mapping_50464 force_mapping 2 50464 NULL
106364 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
106365 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
106366 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
106367 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
106368 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
106369 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
106370 +fat_readpages_50582 fat_readpages 4 50582 NULL
106371 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
106372 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
106373 +sge_rx_50594 sge_rx 3 50594 NULL
106374 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
106375 +__ffs_50625 __ffs 0 50625 NULL
106376 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
106377 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
106378 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
106379 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
106380 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
106381 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
106382 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
106383 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
106384 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
106385 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
106386 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
106387 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
106388 +skb_padto_50759 skb_padto 2 50759 NULL
106389 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
106390 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
106391 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
106392 +tpm_write_50798 tpm_write 3 50798 NULL
106393 +write_flush_50803 write_flush 3 50803 NULL
106394 +dvb_play_50814 dvb_play 3 50814 NULL
106395 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
106396 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
106397 +SetArea_50835 SetArea 4 50835 NULL nohasharray
106398 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
106399 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
106400 +self_check_write_50856 self_check_write 5 50856 NULL
106401 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
106402 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
106403 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
106404 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
106405 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
106406 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
106407 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
106408 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
106409 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
106410 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
106411 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
106412 +timeout_write_50991 timeout_write 3 50991 NULL
106413 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
106414 +proc_write_51003 proc_write 3 51003 NULL
106415 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
106416 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
106417 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
106418 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
106419 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
106420 +dump_midi_51040 dump_midi 3 51040 NULL
106421 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
106422 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
106423 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
106424 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
106425 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
106426 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
106427 +ti_recv_51110 ti_recv 3 51110 NULL
106428 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
106429 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
106430 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
106431 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
106432 +set_dirty_51144 set_dirty 3 51144 NULL
106433 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
106434 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
106435 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
106436 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
106437 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
106438 +tipc_send_51238 tipc_send 4 51238 NULL
106439 +drm_property_create_51239 drm_property_create 4 51239 NULL
106440 +st_read_51251 st_read 3 51251 NULL
106441 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
106442 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
106443 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
106444 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
106445 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
106446 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
106447 +get_cell_51316 get_cell 2 51316 NULL
106448 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
106449 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
106450 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
106451 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
106452 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
106453 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
106454 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
106455 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
106456 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
106457 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
106458 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
106459 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
106460 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
106461 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
106462 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
106463 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
106464 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
106465 +vaddr_51480 vaddr 0 51480 NULL
106466 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
106467 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
106468 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
106469 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
106470 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
106471 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
106472 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
106473 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
106474 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
106475 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
106476 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
106477 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
106478 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
106479 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
106480 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
106481 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
106482 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
106483 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
106484 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
106485 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
106486 +sel_write_access_51704 sel_write_access 3 51704 NULL
106487 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
106488 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
106489 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
106490 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
106491 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
106492 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
106493 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
106494 +if_write_51756 if_write 3 51756 NULL
106495 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
106496 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
106497 +to_ratio_51809 to_ratio 2-1 51809 NULL
106498 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
106499 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
106500 +ioread32_51847 ioread32 0 51847 NULL nohasharray
106501 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
106502 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
106503 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
106504 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
106505 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
106506 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
106507 +user_read_51881 user_read 3 51881 NULL
106508 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
106509 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
106510 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
106511 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
106512 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
106513 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
106514 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
106515 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
106516 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
106517 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
106518 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
106519 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
106520 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
106521 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
106522 +rdmalt_52022 rdmalt 0 52022 NULL
106523 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
106524 +override_release_52032 override_release 2 52032 NULL
106525 +end_port_52042 end_port 0 52042 NULL
106526 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
106527 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
106528 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
106529 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
106530 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
106531 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
106532 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
106533 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
106534 +retry_count_read_52129 retry_count_read 3 52129 NULL
106535 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
106536 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
106537 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
106538 +htable_size_52148 htable_size 0-1 52148 NULL
106539 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
106540 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
106541 +alix_present_52165 alix_present 1 52165 NULL
106542 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
106543 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
106544 +print_prefix_52176 print_prefix 0 52176 NULL
106545 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
106546 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
106547 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
106548 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
106549 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
106550 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
106551 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
106552 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
106553 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
106554 +atomic64_read_52300 atomic64_read 0 52300 NULL
106555 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
106556 +read_file_reset_52310 read_file_reset 3 52310 NULL
106557 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
106558 +hwflags_read_52318 hwflags_read 3 52318 NULL
106559 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
106560 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
106561 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
106562 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
106563 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
106564 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
106565 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
106566 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
106567 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
106568 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
106569 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
106570 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
106571 +delay_status_52431 delay_status 5 52431 NULL
106572 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
106573 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
106574 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
106575 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
106576 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
106577 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
106578 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
106579 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
106580 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
106581 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
106582 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
106583 +from_oblock_52546 from_oblock 0-1 52546 NULL
106584 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
106585 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
106586 +emit_code_52583 emit_code 0-3 52583 NULL
106587 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
106588 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
106589 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
106590 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
106591 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
106592 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
106593 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
106594 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
106595 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
106596 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
106597 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
106598 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
106599 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
106600 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
106601 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
106602 +twlreg_write_52880 twlreg_write 3 52880 NULL
106603 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
106604 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
106605 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
106606 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
106607 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
106608 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
106609 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
106610 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
106611 +send_packet_52960 send_packet 4 52960 NULL
106612 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
106613 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
106614 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
106615 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
106616 +num_node_state_52989 num_node_state 0 52989 NULL
106617 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
106618 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
106619 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
106620 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
106621 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
106622 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
106623 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
106624 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
106625 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
106626 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
106627 +verity_status_53120 verity_status 5 53120 NULL
106628 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
106629 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
106630 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
106631 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
106632 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
106633 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
106634 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
106635 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
106636 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
106637 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
106638 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
106639 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
106640 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
106641 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
106642 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
106643 +vm_mmap_53339 vm_mmap 0 53339 NULL
106644 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
106645 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
106646 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
106647 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
106648 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
106649 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
106650 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
106651 +n2_run_53459 n2_run 3 53459 NULL
106652 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
106653 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
106654 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
106655 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
106656 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
106657 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
106658 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
106659 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
106660 +check_acl_53512 check_acl 0 53512 NULL
106661 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
106662 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
106663 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
106664 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
106665 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
106666 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
106667 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
106668 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
106669 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
106670 +_preload_range_53676 _preload_range 2-3 53676 NULL
106671 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
106672 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
106673 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
106674 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
106675 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
106676 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
106677 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
106678 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
106679 +wdm_write_53735 wdm_write 3 53735 NULL
106680 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
106681 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
106682 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
106683 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
106684 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
106685 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
106686 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
106687 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
106688 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
106689 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
106690 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
106691 +pms_read_53873 pms_read 3 53873 NULL
106692 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
106693 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
106694 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
106695 +proc_file_read_53905 proc_file_read 3 53905 NULL
106696 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
106697 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
106698 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
106699 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
106700 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
106701 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
106702 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
106703 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
106704 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
106705 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
106706 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
106707 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
106708 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
106709 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
106710 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
106711 +_malloc_54077 _malloc 1 54077 NULL
106712 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
106713 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
106714 +create_xattr_54106 create_xattr 5 54106 NULL
106715 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
106716 +strn_len_54122 strn_len 0 54122 NULL
106717 +isku_receive_54130 isku_receive 4 54130 NULL
106718 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
106719 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
106720 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
106721 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
106722 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
106723 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
106724 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
106725 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
106726 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
106727 +reada_add_block_54247 reada_add_block 2 54247 NULL
106728 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
106729 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
106730 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
106731 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
106732 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
106733 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
106734 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
106735 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
106736 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
106737 +sprintf_54306 sprintf 0 54306 NULL
106738 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
106739 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
106740 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
106741 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
106742 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
106743 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
106744 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
106745 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
106746 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
106747 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
106748 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
106749 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
106750 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
106751 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
106752 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
106753 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
106754 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
106755 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
106756 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
106757 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
106758 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
106759 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
106760 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
106761 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
106762 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
106763 +viacam_read_54526 viacam_read 3 54526 NULL
106764 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
106765 +setsockopt_54539 setsockopt 5 54539 NULL
106766 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
106767 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
106768 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
106769 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
106770 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
106771 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
106772 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
106773 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
106774 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
106775 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
106776 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
106777 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
106778 +evm_read_key_54674 evm_read_key 3 54674 NULL
106779 +resource_string_54699 resource_string 0 54699 NULL
106780 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
106781 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
106782 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
106783 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
106784 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
106785 +kzalloc_54740 kzalloc 1 54740 NULL
106786 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
106787 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
106788 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
106789 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
106790 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
106791 +domain_init_54797 domain_init 2 54797 NULL
106792 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
106793 +get_dev_size_54807 get_dev_size 0 54807 NULL
106794 +nfsd_write_54809 nfsd_write 6 54809 NULL
106795 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
106796 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
106797 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
106798 +write_rio_54837 write_rio 3 54837 NULL
106799 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
106800 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
106801 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
106802 +printer_read_54851 printer_read 3 54851 NULL
106803 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
106804 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
106805 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
106806 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
106807 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
106808 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
106809 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
106810 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
106811 +add_port_54941 add_port 2 54941 NULL
106812 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
106813 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
106814 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
106815 +c4_add_card_54968 c4_add_card 3 54968 NULL
106816 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
106817 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
106818 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
106819 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
106820 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
106821 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
106822 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
106823 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
106824 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
106825 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
106826 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
106827 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
106828 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
106829 +corrupt_data_55120 corrupt_data 0 55120 NULL
106830 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
106831 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
106832 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
106833 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
106834 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
106835 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
106836 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
106837 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
106838 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
106839 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
106840 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
106841 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
106842 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
106843 +dump_command_55220 dump_command 1 55220 NULL
106844 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
106845 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
106846 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
106847 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
106848 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
106849 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
106850 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
106851 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
106852 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
106853 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
106854 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
106855 +do_shmat_55336 do_shmat 5 55336 NULL
106856 +vme_user_read_55338 vme_user_read 3 55338 NULL
106857 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
106858 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
106859 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
106860 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
106861 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
106862 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
106863 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
106864 +alloc_skb_55439 alloc_skb 1 55439 NULL
106865 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
106866 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
106867 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
106868 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
106869 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
106870 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
106871 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
106872 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
106873 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
106874 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
106875 +ea_get_55522 ea_get 0 55522 NULL
106876 +buffer_size_55534 buffer_size 0 55534 NULL
106877 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
106878 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
106879 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
106880 +add_partition_55588 add_partition 2 55588 NULL
106881 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
106882 +free_pages_55603 free_pages 1 55603 NULL
106883 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
106884 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
106885 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
106886 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
106887 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
106888 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
106889 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
106890 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
106891 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
106892 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
106893 +read_oldmem_55658 read_oldmem 3 55658 NULL
106894 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
106895 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
106896 +get_info_55681 get_info 3 55681 NULL
106897 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
106898 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
106899 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
106900 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
106901 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
106902 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
106903 +set_local_name_55757 set_local_name 4 55757 NULL
106904 +strlen_55778 strlen 0 55778 NULL
106905 +set_spte_55783 set_spte 5-4 55783 NULL
106906 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
106907 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
106908 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
106909 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
106910 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
106911 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
106912 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
106913 +hsc_write_55875 hsc_write 3 55875 NULL
106914 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
106915 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
106916 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
106917 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
106918 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
106919 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
106920 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
106921 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
106922 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
106923 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
106924 +__set_discard_56081 __set_discard 2 56081 NULL
106925 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
106926 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
106927 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
106928 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
106929 +map_addr_56144 map_addr 7 56144 NULL
106930 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
106931 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
106932 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
106933 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
106934 +skb_headroom_56200 skb_headroom 0 56200 NULL
106935 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
106936 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
106937 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
106938 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
106939 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
106940 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
106941 +fd_copyin_56247 fd_copyin 3 56247 NULL
106942 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
106943 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
106944 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
106945 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
106946 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
106947 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
106948 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
106949 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
106950 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
106951 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
106952 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
106953 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
106954 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
106955 +dev_read_56369 dev_read 3 56369 NULL
106956 +write_gssp_56404 write_gssp 3 56404 NULL
106957 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
106958 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
106959 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
106960 +store_msg_56417 store_msg 3 56417 NULL
106961 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
106962 +fl_create_56435 fl_create 5 56435 NULL
106963 +gnttab_map_56439 gnttab_map 2 56439 NULL
106964 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
106965 +set_connectable_56458 set_connectable 4 56458 NULL
106966 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
106967 +putused_user_56467 putused_user 3 56467 NULL
106968 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
106969 +global_rt_period_56476 global_rt_period 0 56476 NULL
106970 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
106971 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
106972 +init_map_ip_56508 init_map_ip 5 56508 NULL
106973 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
106974 +ip_options_get_56538 ip_options_get 4 56538 NULL
106975 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
106976 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
106977 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
106978 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
106979 +event_filter_write_56609 event_filter_write 3 56609 NULL
106980 +gather_array_56641 gather_array 3 56641 NULL
106981 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
106982 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
106983 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
106984 +build_map_info_56696 build_map_info 2 56696 NULL
106985 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
106986 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
106987 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
106988 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
106989 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
106990 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
106991 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
106992 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
106993 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
106994 +hash_lookup_56792 hash_lookup 2 56792 NULL
106995 +do_syslog_56807 do_syslog 3 56807 NULL
106996 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
106997 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
106998 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
106999 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
107000 +wb_lookup_56858 wb_lookup 2 56858 NULL
107001 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
107002 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
107003 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
107004 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
107005 +strcspn_56913 strcspn 0 56913 NULL
107006 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
107007 +check_header_56930 check_header 2 56930 NULL
107008 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
107009 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
107010 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
107011 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
107012 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
107013 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
107014 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
107015 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
107016 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
107017 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
107018 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
107019 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
107020 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
107021 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
107022 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
107023 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
107024 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
107025 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
107026 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
107027 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
107028 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
107029 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
107030 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
107031 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
107032 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
107033 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
107034 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
107035 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
107036 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
107037 +flush_space_57241 flush_space 3 57241 NULL
107038 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
107039 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
107040 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
107041 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
107042 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
107043 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
107044 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
107045 +fw_file_size_57307 fw_file_size 0 57307 NULL
107046 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
107047 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
107048 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
107049 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
107050 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
107051 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
107052 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
107053 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
107054 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
107055 +read_file_blob_57406 read_file_blob 3 57406 NULL
107056 +enclosure_register_57412 enclosure_register 3 57412 NULL
107057 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
107058 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
107059 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
107060 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
107061 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
107062 +ReadReg_57453 ReadReg 0 57453 NULL
107063 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
107064 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
107065 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
107066 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
107067 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
107068 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
107069 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
107070 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
107071 +skb_headlen_57501 skb_headlen 0 57501 NULL
107072 +copy_in_user_57502 copy_in_user 3 57502 NULL
107073 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
107074 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
107075 +init_tag_map_57515 init_tag_map 3 57515 NULL
107076 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107077 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107078 +inode_permission_57531 inode_permission 0 57531 NULL
107079 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107080 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107081 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107082 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107083 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107084 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107085 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107086 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107087 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107088 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107089 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107090 +mem_read_57631 mem_read 3 57631 NULL
107091 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107092 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107093 +r3964_write_57662 r3964_write 4 57662 NULL
107094 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107095 +__lgwrite_57669 __lgwrite 4 57669 NULL
107096 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107097 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107098 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107099 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107100 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107101 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107102 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107103 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107104 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107105 +ld2_57794 ld2 0 57794 NULL
107106 +ivtv_read_57796 ivtv_read 3 57796 NULL
107107 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107108 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107109 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107110 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107111 +copy_to_user_57835 copy_to_user 3 57835 NULL
107112 +flash_read_57843 flash_read 3 57843 NULL
107113 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107114 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107115 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107116 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107117 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107118 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107119 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107120 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107121 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107122 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107123 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107124 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107125 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107126 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107127 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107128 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107129 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107130 +mce_async_out_58056 mce_async_out 3 58056 NULL
107131 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107132 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107133 +cm4040_write_58079 cm4040_write 3 58079 NULL
107134 +udi_log_event_58105 udi_log_event 3 58105 NULL
107135 +savemem_58129 savemem 3 58129 NULL
107136 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107137 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107138 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107139 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107140 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107141 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107142 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107143 +read_file_debug_58256 read_file_debug 3 58256 NULL
107144 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107145 +profile_load_58267 profile_load 3 58267 NULL
107146 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107147 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107148 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107149 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107150 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107151 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107152 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107153 +next_pidmap_58347 next_pidmap 2 58347 NULL
107154 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107155 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107156 +save_hint_58359 save_hint 2 58359 NULL
107157 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107158 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107159 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107160 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107161 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107162 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107163 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107164 +capabilities_read_58457 capabilities_read 3 58457 NULL
107165 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107166 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107167 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107168 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107169 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107170 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107171 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107172 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107173 +__clear_discard_58546 __clear_discard 2 58546 NULL
107174 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107175 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107176 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107177 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
107178 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
107179 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
107180 +xip_file_read_58592 xip_file_read 3 58592 NULL
107181 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
107182 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
107183 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
107184 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
107185 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
107186 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
107187 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
107188 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
107189 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
107190 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
107191 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
107192 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
107193 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
107194 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
107195 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
107196 +acpi_map_58725 acpi_map 1-2 58725 NULL
107197 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
107198 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
107199 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
107200 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
107201 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
107202 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
107203 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
107204 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
107205 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
107206 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
107207 +ep_read_58813 ep_read 3 58813 NULL
107208 +command_write_58841 command_write 3 58841 NULL
107209 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
107210 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
107211 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
107212 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
107213 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
107214 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
107215 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
107216 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
107217 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
107218 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
107219 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
107220 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
107221 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
107222 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
107223 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
107224 +ep_write_59008 ep_write 3 59008 NULL
107225 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
107226 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
107227 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
107228 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
107229 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
107230 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
107231 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
107232 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
107233 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
107234 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
107235 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
107236 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
107237 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
107238 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
107239 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
107240 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
107241 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
107242 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
107243 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
107244 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
107245 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
107246 +dt3155_read_59226 dt3155_read 3 59226 NULL
107247 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
107248 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
107249 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
107250 +nla_len_59258 nla_len 0 59258 NULL
107251 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
107252 +fd_copyout_59323 fd_copyout 3 59323 NULL
107253 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
107254 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
107255 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
107256 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
107257 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
107258 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
107259 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
107260 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
107261 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
107262 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
107263 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
107264 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
107265 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
107266 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
107267 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
107268 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
107269 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
107270 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
107271 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
107272 +tunables_write_59563 tunables_write 3 59563 NULL
107273 +memdup_user_59590 memdup_user 2 59590 NULL
107274 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
107275 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
107276 +mtrr_write_59622 mtrr_write 3 59622 NULL
107277 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
107278 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
107279 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
107280 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
107281 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
107282 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
107283 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
107284 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
107285 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
107286 +sriov_enable_59689 sriov_enable 2 59689 NULL
107287 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
107288 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
107289 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
107290 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
107291 +strnlen_59746 strnlen 0 59746 NULL
107292 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
107293 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
107294 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
107295 +venus_remove_59781 venus_remove 4 59781 NULL
107296 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
107297 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
107298 +ipw_write_59807 ipw_write 3 59807 NULL
107299 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
107300 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
107301 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
107302 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
107303 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
107304 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
107305 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
107306 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
107307 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
107308 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
107309 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
107310 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
107311 +lookup_node_59953 lookup_node 2 59953 NULL
107312 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
107313 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
107314 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
107315 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
107316 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
107317 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
107318 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
107319 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
107320 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
107321 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
107322 +register_device_60015 register_device 2-3 60015 NULL
107323 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
107324 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
107325 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
107326 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
107327 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
107328 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
107329 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
107330 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
107331 +compat_writev_60063 compat_writev 3 60063 NULL
107332 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
107333 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
107334 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
107335 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
107336 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
107337 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
107338 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
107339 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
107340 +init_state_60165 init_state 2 60165 NULL
107341 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
107342 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
107343 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
107344 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
107345 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
107346 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
107347 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
107348 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
107349 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
107350 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
107351 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
107352 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
107353 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
107354 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
107355 +printer_write_60276 printer_write 3 60276 NULL
107356 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
107357 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
107358 +getDataLength_60301 getDataLength 0 60301 NULL
107359 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
107360 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
107361 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
107362 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
107363 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
107364 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
107365 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
107366 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
107367 +driver_names_read_60399 driver_names_read 3 60399 NULL
107368 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
107369 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
107370 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
107371 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
107372 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
107373 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
107374 +rx_data_60442 rx_data 4 60442 NULL nohasharray
107375 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
107376 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
107377 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
107378 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
107379 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
107380 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
107381 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
107382 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
107383 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
107384 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
107385 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
107386 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
107387 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
107388 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
107389 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
107390 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
107391 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
107392 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
107393 +init_data_container_60709 init_data_container 1 60709 NULL
107394 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
107395 +raid_status_60755 raid_status 5 60755 NULL
107396 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
107397 +opticon_write_60775 opticon_write 4 60775 NULL
107398 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
107399 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
107400 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
107401 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
107402 +generic_writepages_60871 generic_writepages 0 60871 NULL
107403 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
107404 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
107405 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
107406 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
107407 +sys_mlock_60932 sys_mlock 1 60932 NULL
107408 +pti_char_write_60960 pti_char_write 3 60960 NULL
107409 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
107410 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
107411 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
107412 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
107413 +symtab_init_61050 symtab_init 2 61050 NULL
107414 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
107415 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
107416 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
107417 +get_derived_key_61100 get_derived_key 4 61100 NULL
107418 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
107419 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
107420 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
107421 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
107422 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
107423 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
107424 +__vmalloc_61168 __vmalloc 1 61168 NULL
107425 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
107426 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
107427 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
107428 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
107429 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
107430 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
107431 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
107432 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
107433 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
107434 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
107435 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
107436 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
107437 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
107438 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
107439 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
107440 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
107441 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
107442 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
107443 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
107444 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
107445 +change_xattr_61390 change_xattr 5 61390 NULL
107446 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
107447 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
107448 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
107449 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
107450 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
107451 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
107452 +erst_errno_61526 erst_errno 0 61526 NULL
107453 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
107454 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
107455 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
107456 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
107457 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
107458 +seq_open_private_61589 seq_open_private 3 61589 NULL
107459 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
107460 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
107461 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
107462 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
107463 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
107464 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
107465 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
107466 +resize_stripes_61650 resize_stripes 2 61650 NULL
107467 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
107468 +insert_one_name_61668 insert_one_name 7 61668 NULL
107469 +lock_loop_61681 lock_loop 1 61681 NULL
107470 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
107471 +filter_read_61692 filter_read 3 61692 NULL
107472 +iov_length_61716 iov_length 0 61716 NULL
107473 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
107474 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
107475 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
107476 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
107477 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
107478 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
107479 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
107480 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
107481 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
107482 +get_fw_name_61874 get_fw_name 3 61874 NULL
107483 +free_init_pages_61875 free_init_pages 2 61875 NULL
107484 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
107485 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
107486 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
107487 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
107488 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
107489 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
107490 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
107491 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
107492 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
107493 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
107494 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
107495 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
107496 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
107497 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
107498 +cow_file_range_61979 cow_file_range 3 61979 NULL
107499 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
107500 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
107501 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
107502 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
107503 +SYSC_select_62024 SYSC_select 1 62024 NULL
107504 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
107505 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
107506 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
107507 +do_pselect_62061 do_pselect 1 62061 NULL
107508 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
107509 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
107510 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
107511 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
107512 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
107513 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
107514 +ql_status_62135 ql_status 5 62135 NULL
107515 +video_usercopy_62151 video_usercopy 2 62151 NULL
107516 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
107517 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
107518 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
107519 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
107520 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
107521 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
107522 +allocate_partition_62245 allocate_partition 4 62245 NULL
107523 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
107524 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
107525 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
107526 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
107527 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
107528 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
107529 +subseq_list_62332 subseq_list 3-0 62332 NULL
107530 +flash_write_62354 flash_write 3 62354 NULL
107531 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
107532 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
107533 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
107534 +altera_irscan_62396 altera_irscan 2 62396 NULL
107535 +set_ssp_62411 set_ssp 4 62411 NULL
107536 +unmap_single_62423 unmap_single 2 62423 NULL
107537 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
107538 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
107539 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
107540 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
107541 +remove_mapping_62491 remove_mapping 2 62491 NULL
107542 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
107543 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
107544 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
107545 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
107546 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
107547 +debugfs_read_62535 debugfs_read 3 62535 NULL
107548 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
107549 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
107550 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
107551 +get_subdir_62581 get_subdir 3 62581 NULL
107552 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
107553 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
107554 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
107555 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
107556 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
107557 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
107558 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
107559 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
107560 +write_62671 write 3 62671 NULL
107561 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
107562 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
107563 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
107564 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
107565 +rdm_62719 rdm 0 62719 NULL
107566 +key_replays_read_62746 key_replays_read 3 62746 NULL
107567 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
107568 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
107569 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
107570 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
107571 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
107572 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
107573 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
107574 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
107575 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
107576 +set_swbp_62853 set_swbp 3 62853 NULL
107577 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
107578 +aoechr_write_62883 aoechr_write 3 62883 NULL
107579 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
107580 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
107581 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
107582 +getdqbuf_62908 getdqbuf 1 62908 NULL
107583 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
107584 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
107585 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
107586 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
107587 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
107588 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
107589 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
107590 +unlink1_63059 unlink1 3 63059 NULL
107591 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
107592 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
107593 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
107594 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
107595 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
107596 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
107597 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
107598 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
107599 +vme_master_read_63221 vme_master_read 0 63221 NULL
107600 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
107601 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
107602 +ptp_read_63251 ptp_read 4 63251 NULL
107603 +raid5_resize_63306 raid5_resize 2 63306 NULL
107604 +proc_info_read_63344 proc_info_read 3 63344 NULL
107605 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
107606 +idmouse_read_63374 idmouse_read 3 63374 NULL
107607 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
107608 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
107609 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
107610 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
107611 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
107612 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
107613 +kone_send_63435 kone_send 4 63435 NULL
107614 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
107615 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
107616 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
107617 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
107618 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
107619 +read_kcore_63488 read_kcore 3 63488 NULL
107620 +save_hint_63497 save_hint 2 63497 NULL
107621 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
107622 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
107623 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
107624 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
107625 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
107626 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
107627 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
107628 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
107629 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
107630 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
107631 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
107632 +module_alloc_63630 module_alloc 1 63630 NULL
107633 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
107634 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
107635 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
107636 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
107637 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
107638 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
107639 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
107640 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
107641 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
107642 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
107643 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
107644 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
107645 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
107646 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
107647 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
107648 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
107649 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
107650 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
107651 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
107652 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
107653 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
107654 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
107655 +prepare_copy_63826 prepare_copy 2 63826 NULL
107656 +sel_write_load_63830 sel_write_load 3 63830 NULL
107657 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
107658 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
107659 +divas_write_63901 divas_write 3 63901 NULL
107660 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
107661 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
107662 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
107663 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
107664 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
107665 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
107666 +__team_options_register_63941 __team_options_register 3 63941 NULL
107667 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
107668 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
107669 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
107670 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
107671 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
107672 +kmemdup_64015 kmemdup 2 64015 NULL
107673 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
107674 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
107675 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
107676 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
107677 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
107678 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
107679 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
107680 +get_u8_64076 get_u8 0 64076 NULL
107681 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
107682 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
107683 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
107684 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
107685 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
107686 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
107687 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
107688 +init_bch_64130 init_bch 1-2 64130 NULL
107689 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
107690 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
107691 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
107692 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
107693 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
107694 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
107695 +read_pulse_64227 read_pulse 0-3 64227 NULL
107696 +header_len_64232 header_len 0 64232 NULL
107697 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
107698 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
107699 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
107700 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
107701 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
107702 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
107703 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
107704 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
107705 +ffz_64324 ffz 0 64324 NULL
107706 +map_region_64328 map_region 1 64328 NULL
107707 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
107708 +ts_write_64336 ts_write 3 64336 NULL
107709 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
107710 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
107711 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
107712 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
107713 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
107714 +ilo_write_64378 ilo_write 3 64378 NULL
107715 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
107716 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
107717 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
107718 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
107719 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
107720 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
107721 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
107722 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
107723 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
107724 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
107725 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
107726 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
107727 +cap_capable_64462 cap_capable 0 64462 NULL
107728 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
107729 +single_open_size_64483 single_open_size 4 64483 NULL
107730 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
107731 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
107732 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
107733 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
107734 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
107735 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
107736 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
107737 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
107738 +SyS_bind_64544 SyS_bind 3 64544 NULL
107739 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
107740 +__spi_sync_64561 __spi_sync 0 64561 NULL
107741 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
107742 +fanotify_write_64623 fanotify_write 3 64623 NULL
107743 +to_dblock_64655 to_dblock 0-1 64655 NULL
107744 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
107745 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
107746 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
107747 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
107748 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
107749 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
107750 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
107751 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
107752 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
107753 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
107754 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
107755 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
107756 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
107757 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
107758 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
107759 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
107760 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
107761 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
107762 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
107763 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
107764 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
107765 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
107766 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
107767 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
107768 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
107769 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
107770 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
107771 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
107772 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
107773 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
107774 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
107775 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
107776 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
107777 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
107778 +pskb_pull_65005 pskb_pull 2 65005 NULL
107779 +unifi_write_65012 unifi_write 3 65012 NULL
107780 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
107781 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
107782 +insert_dent_65034 insert_dent 7 65034 NULL
107783 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
107784 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
107785 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
107786 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
107787 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
107788 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
107789 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
107790 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
107791 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
107792 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
107793 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
107794 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
107795 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
107796 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
107797 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
107798 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
107799 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
107800 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
107801 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
107802 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
107803 +get_var_len_65304 get_var_len 0 65304 NULL
107804 +unpack_array_65318 unpack_array 0 65318 NULL
107805 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
107806 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
107807 +init_list_set_65351 init_list_set 2-3 65351 NULL
107808 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
107809 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
107810 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
107811 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
107812 +strchr_65372 strchr 0 65372 NULL nohasharray
107813 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
107814 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
107815 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
107816 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
107817 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
107818 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
107819 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
107820 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
107821 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
107822 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
107823 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
107824 +alloc_dr_65495 alloc_dr 2 65495 NULL
107825 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
107826 new file mode 100644
107827 index 0000000..03d0c84
107828 --- /dev/null
107829 +++ b/tools/gcc/size_overflow_plugin.c
107830 @@ -0,0 +1,2113 @@
107831 +/*
107832 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
107833 + * Licensed under the GPL v2, or (at your option) v3
107834 + *
107835 + * Homepage:
107836 + * http://www.grsecurity.net/~ephox/overflow_plugin/
107837 + *
107838 + * Documentation:
107839 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
107840 + *
107841 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
107842 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
107843 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
107844 + *
107845 + * Usage:
107846 + * $ 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
107847 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
107848 + */
107849 +
107850 +#include "gcc-plugin.h"
107851 +#include "config.h"
107852 +#include "system.h"
107853 +#include "coretypes.h"
107854 +#include "tree.h"
107855 +#include "tree-pass.h"
107856 +#include "intl.h"
107857 +#include "plugin-version.h"
107858 +#include "tm.h"
107859 +#include "toplev.h"
107860 +#include "function.h"
107861 +#include "tree-flow.h"
107862 +#include "plugin.h"
107863 +#include "gimple.h"
107864 +#include "diagnostic.h"
107865 +#include "cfgloop.h"
107866 +
107867 +#if BUILDING_GCC_VERSION >= 4008
107868 +#define TODO_dump_func 0
107869 +#endif
107870 +
107871 +struct size_overflow_hash {
107872 + const struct size_overflow_hash * const next;
107873 + const char * const name;
107874 + const unsigned int param;
107875 +};
107876 +
107877 +#include "size_overflow_hash.h"
107878 +
107879 +enum mark {
107880 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
107881 +};
107882 +
107883 +enum err_code_conditions {
107884 + CAST_ONLY, FROM_CONST
107885 +};
107886 +
107887 +static unsigned int call_count = 0;
107888 +
107889 +#define __unused __attribute__((__unused__))
107890 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
107891 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
107892 +#define BEFORE_STMT true
107893 +#define AFTER_STMT false
107894 +#define CREATE_NEW_VAR NULL_TREE
107895 +#define CODES_LIMIT 32
107896 +#define MAX_PARAM 31
107897 +#define MY_STMT GF_PLF_1
107898 +#define NO_CAST_CHECK GF_PLF_2
107899 +#define FROM_ARG true
107900 +#define FROM_RET false
107901 +
107902 +#if BUILDING_GCC_VERSION == 4005
107903 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
107904 +#endif
107905 +
107906 +int plugin_is_GPL_compatible;
107907 +void debug_gimple_stmt(gimple gs);
107908 +
107909 +static tree expand(struct pointer_set_t *visited, tree lhs);
107910 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
107911 +static tree report_size_overflow_decl;
107912 +static const_tree const_char_ptr_type_node;
107913 +static unsigned int handle_function(void);
107914 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
107915 +static tree get_size_overflow_type(gimple stmt, const_tree node);
107916 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
107917 +static void print_missing_msg(tree func, unsigned int argnum);
107918 +
107919 +static struct plugin_info size_overflow_plugin_info = {
107920 + .version = "20130822beta",
107921 + .help = "no-size-overflow\tturn off size overflow checking\n",
107922 +};
107923 +
107924 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
107925 +{
107926 + unsigned int arg_count;
107927 + enum tree_code code = TREE_CODE(*node);
107928 +
107929 + switch (code) {
107930 + case FUNCTION_DECL:
107931 + arg_count = type_num_arguments(TREE_TYPE(*node));
107932 + break;
107933 + case FUNCTION_TYPE:
107934 + case METHOD_TYPE:
107935 + arg_count = type_num_arguments(*node);
107936 + break;
107937 + default:
107938 + *no_add_attrs = true;
107939 + error("%s: %qE attribute only applies to functions", __func__, name);
107940 + return NULL_TREE;
107941 + }
107942 +
107943 + for (; args; args = TREE_CHAIN(args)) {
107944 + tree position = TREE_VALUE(args);
107945 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
107946 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
107947 + *no_add_attrs = true;
107948 + }
107949 + }
107950 + return NULL_TREE;
107951 +}
107952 +
107953 +static const char* get_asm_name(tree node)
107954 +{
107955 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
107956 +}
107957 +
107958 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
107959 +{
107960 + unsigned int arg_count, arg_num;
107961 + enum tree_code code = TREE_CODE(*node);
107962 +
107963 + switch (code) {
107964 + case FUNCTION_DECL:
107965 + arg_count = type_num_arguments(TREE_TYPE(*node));
107966 + break;
107967 + case FUNCTION_TYPE:
107968 + case METHOD_TYPE:
107969 + arg_count = type_num_arguments(*node);
107970 + break;
107971 + case FIELD_DECL:
107972 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
107973 + if (arg_num != 0) {
107974 + *no_add_attrs = true;
107975 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
107976 + }
107977 + return NULL_TREE;
107978 + default:
107979 + *no_add_attrs = true;
107980 + error("%qE attribute only applies to functions", name);
107981 + return NULL_TREE;
107982 + }
107983 +
107984 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
107985 + return NULL_TREE;
107986 +
107987 + for (; args; args = TREE_CHAIN(args)) {
107988 + tree position = TREE_VALUE(args);
107989 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
107990 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
107991 + *no_add_attrs = true;
107992 + }
107993 + }
107994 + return NULL_TREE;
107995 +}
107996 +
107997 +static struct attribute_spec size_overflow_attr = {
107998 + .name = "size_overflow",
107999 + .min_length = 1,
108000 + .max_length = -1,
108001 + .decl_required = true,
108002 + .type_required = false,
108003 + .function_type_required = false,
108004 + .handler = handle_size_overflow_attribute,
108005 +#if BUILDING_GCC_VERSION >= 4007
108006 + .affects_type_identity = false
108007 +#endif
108008 +};
108009 +
108010 +static struct attribute_spec intentional_overflow_attr = {
108011 + .name = "intentional_overflow",
108012 + .min_length = 1,
108013 + .max_length = -1,
108014 + .decl_required = true,
108015 + .type_required = false,
108016 + .function_type_required = false,
108017 + .handler = handle_intentional_overflow_attribute,
108018 +#if BUILDING_GCC_VERSION >= 4007
108019 + .affects_type_identity = false
108020 +#endif
108021 +};
108022 +
108023 +static void register_attributes(void __unused *event_data, void __unused *data)
108024 +{
108025 + register_attribute(&size_overflow_attr);
108026 + register_attribute(&intentional_overflow_attr);
108027 +}
108028 +
108029 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
108030 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
108031 +{
108032 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
108033 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
108034 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
108035 +
108036 + unsigned int m = 0x57559429;
108037 + unsigned int n = 0x5052acdb;
108038 + const unsigned int *key4 = (const unsigned int *)key;
108039 + unsigned int h = len;
108040 + unsigned int k = len + seed + n;
108041 + unsigned long long p;
108042 +
108043 + while (len >= 8) {
108044 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
108045 + len -= 8;
108046 + }
108047 + if (len >= 4) {
108048 + cwmixb(key4[0]) key4 += 1;
108049 + len -= 4;
108050 + }
108051 + if (len)
108052 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
108053 + cwmixb(h ^ (k + n));
108054 + return k ^ h;
108055 +
108056 +#undef cwfold
108057 +#undef cwmixa
108058 +#undef cwmixb
108059 +}
108060 +
108061 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
108062 +{
108063 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
108064 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
108065 + return fn ^ codes;
108066 +}
108067 +
108068 +static inline tree get_original_function_decl(tree fndecl)
108069 +{
108070 + if (DECL_ABSTRACT_ORIGIN(fndecl))
108071 + return DECL_ABSTRACT_ORIGIN(fndecl);
108072 + return fndecl;
108073 +}
108074 +
108075 +static inline gimple get_def_stmt(const_tree node)
108076 +{
108077 + gcc_assert(node != NULL_TREE);
108078 + if (TREE_CODE(node) != SSA_NAME)
108079 + return NULL;
108080 + return SSA_NAME_DEF_STMT(node);
108081 +}
108082 +
108083 +static unsigned char get_tree_code(const_tree type)
108084 +{
108085 + switch (TREE_CODE(type)) {
108086 + case ARRAY_TYPE:
108087 + return 0;
108088 + case BOOLEAN_TYPE:
108089 + return 1;
108090 + case ENUMERAL_TYPE:
108091 + return 2;
108092 + case FUNCTION_TYPE:
108093 + return 3;
108094 + case INTEGER_TYPE:
108095 + return 4;
108096 + case POINTER_TYPE:
108097 + return 5;
108098 + case RECORD_TYPE:
108099 + return 6;
108100 + case UNION_TYPE:
108101 + return 7;
108102 + case VOID_TYPE:
108103 + return 8;
108104 + case REAL_TYPE:
108105 + return 9;
108106 + case VECTOR_TYPE:
108107 + return 10;
108108 + case REFERENCE_TYPE:
108109 + return 11;
108110 + case OFFSET_TYPE:
108111 + return 12;
108112 + case COMPLEX_TYPE:
108113 + return 13;
108114 + default:
108115 + debug_tree((tree)type);
108116 + gcc_unreachable();
108117 + }
108118 +}
108119 +
108120 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108121 +{
108122 + gcc_assert(type != NULL_TREE);
108123 +
108124 + while (type && len < CODES_LIMIT) {
108125 + tree_codes[len] = get_tree_code(type);
108126 + len++;
108127 + type = TREE_TYPE(type);
108128 + }
108129 + return len;
108130 +}
108131 +
108132 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108133 +{
108134 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108135 + enum tree_code code = TREE_CODE(type);
108136 + size_t len = 0;
108137 +
108138 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108139 +
108140 + arg = TYPE_ARG_TYPES(type);
108141 + // skip builtins __builtin_constant_p
108142 + if (!arg && DECL_BUILT_IN(fndecl))
108143 + return 0;
108144 +
108145 + if (TREE_CODE_CLASS(code) == tcc_type)
108146 + result = type;
108147 + else
108148 + result = DECL_RESULT(fndecl);
108149 +
108150 + gcc_assert(result != NULL_TREE);
108151 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108152 +
108153 + if (arg == NULL_TREE) {
108154 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108155 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108156 + if (arg_field == NULL_TREE)
108157 + return 0;
108158 + arg = TREE_TYPE(arg_field);
108159 + len = add_type_codes(arg, tree_codes, len);
108160 + gcc_assert(len != 0);
108161 + return len;
108162 + }
108163 +
108164 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108165 + while (arg && len < CODES_LIMIT) {
108166 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108167 + arg = TREE_CHAIN(arg);
108168 + }
108169 +
108170 + gcc_assert(len != 0);
108171 + return len;
108172 +}
108173 +
108174 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108175 +{
108176 + unsigned int hash;
108177 + const struct size_overflow_hash *entry;
108178 + unsigned char tree_codes[CODES_LIMIT];
108179 + size_t len;
108180 + const char *func_name;
108181 +
108182 + fndecl = get_original_function_decl(fndecl);
108183 + len = get_function_decl(fndecl, tree_codes);
108184 + if (len == 0)
108185 + return NULL;
108186 +
108187 + func_name = get_asm_name(fndecl);
108188 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
108189 +
108190 + entry = size_overflow_hash[hash];
108191 + while (entry) {
108192 + if (!strcmp(entry->name, func_name))
108193 + return entry;
108194 + entry = entry->next;
108195 + }
108196 +
108197 + return NULL;
108198 +}
108199 +
108200 +static bool is_bool(const_tree node)
108201 +{
108202 + const_tree type;
108203 +
108204 + if (node == NULL_TREE)
108205 + return false;
108206 +
108207 + type = TREE_TYPE(node);
108208 + if (!INTEGRAL_TYPE_P(type))
108209 + return false;
108210 + if (TREE_CODE(type) == BOOLEAN_TYPE)
108211 + return true;
108212 + if (TYPE_PRECISION(type) == 1)
108213 + return true;
108214 + return false;
108215 +}
108216 +
108217 +static bool skip_types(const_tree var)
108218 +{
108219 + tree type;
108220 +
108221 + if (is_gimple_constant(var))
108222 + return true;
108223 +
108224 + switch (TREE_CODE(var)) {
108225 + case ADDR_EXPR:
108226 +#if BUILDING_GCC_VERSION >= 4006
108227 + case MEM_REF:
108228 +#endif
108229 + case ARRAY_REF:
108230 + case BIT_FIELD_REF:
108231 + case INDIRECT_REF:
108232 + case TARGET_MEM_REF:
108233 + return true;
108234 + case PARM_DECL:
108235 + case VAR_DECL:
108236 + case COMPONENT_REF:
108237 + return false;
108238 + default:
108239 + break;
108240 + }
108241 +
108242 + gcc_assert(TREE_CODE(var) == SSA_NAME);
108243 +
108244 + type = TREE_TYPE(var);
108245 + switch (TREE_CODE(type)) {
108246 + case INTEGER_TYPE:
108247 + case ENUMERAL_TYPE:
108248 + return false;
108249 + case BOOLEAN_TYPE:
108250 + return is_bool(var);
108251 + default:
108252 + break;
108253 + }
108254 +
108255 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
108256 +
108257 + type = TREE_TYPE(type);
108258 + gcc_assert(type != NULL_TREE);
108259 + switch (TREE_CODE(type)) {
108260 + case RECORD_TYPE:
108261 + case POINTER_TYPE:
108262 + case ARRAY_TYPE:
108263 + return true;
108264 + case VOID_TYPE:
108265 + case INTEGER_TYPE:
108266 + case UNION_TYPE:
108267 + return false;
108268 + default:
108269 + break;
108270 + }
108271 +
108272 + debug_tree((tree)var);
108273 + gcc_unreachable();
108274 +}
108275 +
108276 +static unsigned int find_arg_number(const_tree arg, tree func)
108277 +{
108278 + tree var;
108279 + unsigned int argnum = 1;
108280 +
108281 + if (TREE_CODE(arg) == SSA_NAME)
108282 + arg = SSA_NAME_VAR(arg);
108283 +
108284 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
108285 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
108286 + continue;
108287 + if (!skip_types(var))
108288 + return argnum;
108289 + }
108290 +
108291 + return 0;
108292 +}
108293 +
108294 +static tree create_new_var(tree type)
108295 +{
108296 + tree new_var = create_tmp_var(type, "cicus");
108297 +
108298 +#if BUILDING_GCC_VERSION <= 4007
108299 + add_referenced_var(new_var);
108300 +#endif
108301 + return new_var;
108302 +}
108303 +
108304 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
108305 +{
108306 + gimple assign;
108307 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108308 + tree type = TREE_TYPE(rhs1);
108309 + tree lhs = create_new_var(type);
108310 +
108311 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
108312 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
108313 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108314 +
108315 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108316 + update_stmt(assign);
108317 + gimple_set_plf(assign, MY_STMT, true);
108318 + return assign;
108319 +}
108320 +
108321 +static tree cast_a_tree(tree type, tree var)
108322 +{
108323 + gcc_assert(type != NULL_TREE);
108324 + gcc_assert(var != NULL_TREE);
108325 + gcc_assert(fold_convertible_p(type, var));
108326 +
108327 + return fold_convert(type, var);
108328 +}
108329 +
108330 +static tree get_lhs(const_gimple stmt)
108331 +{
108332 + switch (gimple_code(stmt)) {
108333 + case GIMPLE_ASSIGN:
108334 + return gimple_get_lhs(stmt);
108335 + case GIMPLE_PHI:
108336 + return gimple_phi_result(stmt);
108337 + case GIMPLE_CALL:
108338 + return gimple_call_lhs(stmt);
108339 + default:
108340 + return NULL_TREE;
108341 + }
108342 +}
108343 +
108344 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
108345 +{
108346 + const_gimple def_stmt = get_def_stmt(rhs);
108347 +
108348 + if (force)
108349 + return false;
108350 +
108351 + if (is_gimple_constant(rhs))
108352 + return false;
108353 +
108354 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108355 + return false;
108356 +
108357 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
108358 + return false;
108359 +
108360 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
108361 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108362 + return false;
108363 +
108364 + return true;
108365 +}
108366 +
108367 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
108368 +{
108369 + gimple assign, def_stmt;
108370 +
108371 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
108372 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
108373 + gcc_unreachable();
108374 +
108375 + def_stmt = get_def_stmt(rhs);
108376 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
108377 + return def_stmt;
108378 +
108379 + if (lhs == CREATE_NEW_VAR)
108380 + lhs = create_new_var(dst_type);
108381 +
108382 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
108383 +
108384 + if (!gsi_end_p(*gsi)) {
108385 + location_t loc = gimple_location(gsi_stmt(*gsi));
108386 + gimple_set_location(assign, loc);
108387 + }
108388 +
108389 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108390 +
108391 + if (before)
108392 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
108393 + else
108394 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
108395 + update_stmt(assign);
108396 + gimple_set_plf(assign, MY_STMT, true);
108397 +
108398 + return assign;
108399 +}
108400 +
108401 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
108402 +{
108403 + gimple_stmt_iterator gsi;
108404 + tree lhs;
108405 + const_gimple new_stmt;
108406 +
108407 + if (rhs == NULL_TREE)
108408 + return NULL_TREE;
108409 +
108410 + gsi = gsi_for_stmt(stmt);
108411 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
108412 +
108413 + lhs = get_lhs(new_stmt);
108414 + gcc_assert(lhs != NULL_TREE);
108415 + return lhs;
108416 +}
108417 +
108418 +static tree cast_to_TI_type(gimple stmt, tree node)
108419 +{
108420 + gimple_stmt_iterator gsi;
108421 + gimple cast_stmt;
108422 + tree type = TREE_TYPE(node);
108423 +
108424 + if (types_compatible_p(type, intTI_type_node))
108425 + return node;
108426 +
108427 + gsi = gsi_for_stmt(stmt);
108428 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108429 + return gimple_get_lhs(cast_stmt);
108430 +}
108431 +
108432 +static void check_function_hash(const_gimple stmt)
108433 +{
108434 + tree func;
108435 + const struct size_overflow_hash *hash;
108436 +
108437 + if (gimple_code(stmt) != GIMPLE_CALL)
108438 + return;
108439 +
108440 + func = gimple_call_fndecl(stmt);
108441 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
108442 + if (func == NULL_TREE)
108443 + return;
108444 +
108445 + hash = get_function_hash(func);
108446 + if (!hash)
108447 + print_missing_msg(func, 0);
108448 +}
108449 +
108450 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
108451 +{
108452 + tree lhs, new_lhs;
108453 + gimple_stmt_iterator gsi;
108454 +
108455 + if (rhs1 == NULL_TREE) {
108456 + debug_gimple_stmt(oldstmt);
108457 + error("%s: rhs1 is NULL_TREE", __func__);
108458 + gcc_unreachable();
108459 + }
108460 +
108461 + switch (gimple_code(oldstmt)) {
108462 + case GIMPLE_ASM:
108463 + lhs = rhs1;
108464 + break;
108465 + case GIMPLE_CALL:
108466 + lhs = gimple_call_lhs(oldstmt);
108467 + break;
108468 + case GIMPLE_ASSIGN:
108469 + lhs = gimple_get_lhs(oldstmt);
108470 + break;
108471 + default:
108472 + debug_gimple_stmt(oldstmt);
108473 + gcc_unreachable();
108474 + }
108475 +
108476 + gsi = gsi_for_stmt(oldstmt);
108477 + pointer_set_insert(visited, oldstmt);
108478 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
108479 + basic_block next_bb, cur_bb;
108480 + const_edge e;
108481 +
108482 + gcc_assert(before == false);
108483 + gcc_assert(stmt_can_throw_internal(oldstmt));
108484 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
108485 + gcc_assert(!gsi_end_p(gsi));
108486 +
108487 + cur_bb = gimple_bb(oldstmt);
108488 + next_bb = cur_bb->next_bb;
108489 + e = find_edge(cur_bb, next_bb);
108490 + gcc_assert(e != NULL);
108491 + gcc_assert(e->flags & EDGE_FALLTHRU);
108492 +
108493 + gsi = gsi_after_labels(next_bb);
108494 + gcc_assert(!gsi_end_p(gsi));
108495 +
108496 + before = true;
108497 + oldstmt = gsi_stmt(gsi);
108498 + }
108499 +
108500 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
108501 + return new_lhs;
108502 +}
108503 +
108504 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
108505 +{
108506 + gimple stmt;
108507 + gimple_stmt_iterator gsi;
108508 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
108509 +
108510 + if (gimple_plf(oldstmt, MY_STMT))
108511 + return lhs;
108512 +
108513 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
108514 + rhs1 = gimple_assign_rhs1(oldstmt);
108515 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
108516 + }
108517 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
108518 + rhs2 = gimple_assign_rhs2(oldstmt);
108519 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
108520 + }
108521 +
108522 + stmt = gimple_copy(oldstmt);
108523 + gimple_set_location(stmt, gimple_location(oldstmt));
108524 + gimple_set_plf(stmt, MY_STMT, true);
108525 +
108526 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
108527 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
108528 +
108529 + size_overflow_type = get_size_overflow_type(oldstmt, node);
108530 +
108531 + new_var = create_new_var(size_overflow_type);
108532 + new_var = make_ssa_name(new_var, stmt);
108533 + gimple_set_lhs(stmt, new_var);
108534 +
108535 + if (rhs1 != NULL_TREE)
108536 + gimple_assign_set_rhs1(stmt, rhs1);
108537 +
108538 + if (rhs2 != NULL_TREE)
108539 + gimple_assign_set_rhs2(stmt, rhs2);
108540 +#if BUILDING_GCC_VERSION >= 4007
108541 + if (rhs3 != NULL_TREE)
108542 + gimple_assign_set_rhs3(stmt, rhs3);
108543 +#endif
108544 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
108545 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
108546 +
108547 + gsi = gsi_for_stmt(oldstmt);
108548 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
108549 + update_stmt(stmt);
108550 + pointer_set_insert(visited, oldstmt);
108551 + return gimple_get_lhs(stmt);
108552 +}
108553 +
108554 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
108555 +{
108556 + basic_block first_bb;
108557 + gimple assign;
108558 + gimple_stmt_iterator gsi;
108559 +
108560 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108561 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108562 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
108563 +
108564 + gsi = gsi_start_bb(first_bb);
108565 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108566 + return gimple_get_lhs(assign);
108567 +}
108568 +
108569 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
108570 +{
108571 + gimple_stmt_iterator gsi;
108572 + const_gimple assign;
108573 + gimple def_stmt = get_def_stmt(new_arg);
108574 +
108575 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
108576 + gsi = gsi_after_labels(gimple_bb(def_stmt));
108577 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
108578 + } else {
108579 + gsi = gsi_for_stmt(def_stmt);
108580 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
108581 + }
108582 +
108583 + return gimple_get_lhs(assign);
108584 +}
108585 +
108586 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
108587 +{
108588 + basic_block bb;
108589 + gimple_stmt_iterator gsi;
108590 + const_gimple assign, def_stmt;
108591 +
108592 + def_stmt = get_def_stmt(arg);
108593 + bb = gimple_bb(def_stmt);
108594 + gcc_assert(bb->index != 0);
108595 + gsi = gsi_after_labels(bb);
108596 +
108597 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108598 + return gimple_get_lhs(assign);
108599 +}
108600 +
108601 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
108602 +{
108603 + tree size_overflow_type;
108604 + const_gimple def_stmt = get_def_stmt(arg);
108605 +
108606 + if (phi_ssa_name != NULL_TREE)
108607 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
108608 +
108609 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
108610 +
108611 + if (new_arg != NULL_TREE) {
108612 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
108613 + return use_phi_ssa_name(phi_ssa_name, new_arg);
108614 + }
108615 +
108616 + switch(gimple_code(def_stmt)) {
108617 + case GIMPLE_PHI:
108618 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
108619 + case GIMPLE_NOP:
108620 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
108621 + default:
108622 + debug_gimple_stmt((gimple)def_stmt);
108623 + gcc_unreachable();
108624 + }
108625 +}
108626 +
108627 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
108628 +{
108629 + basic_block bb;
108630 + gimple phi;
108631 + gimple_seq seq;
108632 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
108633 +
108634 + bb = gsi_bb(gsi);
108635 +
108636 + phi = create_phi_node(result, bb);
108637 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
108638 + seq = phi_nodes(bb);
108639 + gsi = gsi_last(seq);
108640 + gsi_remove(&gsi, false);
108641 +
108642 + gsi = gsi_for_stmt(oldstmt);
108643 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
108644 + gimple_set_bb(phi, bb);
108645 + gimple_set_plf(phi, MY_STMT, true);
108646 + return phi;
108647 +}
108648 +
108649 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
108650 +{
108651 + gimple new_phi = NULL;
108652 + gimple oldstmt = get_def_stmt(orig_result);
108653 + tree phi_ssa_name = NULL_TREE;
108654 + unsigned int i;
108655 +
108656 + pointer_set_insert(visited, oldstmt);
108657 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
108658 + tree arg, new_arg;
108659 +
108660 + arg = gimple_phi_arg_def(oldstmt, i);
108661 +
108662 + new_arg = expand(visited, arg);
108663 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
108664 + if (i == 0) {
108665 + phi_ssa_name = new_arg;
108666 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
108667 + }
108668 +
108669 + gcc_assert(new_phi != NULL);
108670 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
108671 + }
108672 +
108673 + gcc_assert(new_phi != NULL);
108674 + update_stmt(new_phi);
108675 + return gimple_phi_result(new_phi);
108676 +}
108677 +
108678 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
108679 +{
108680 + const_gimple assign;
108681 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108682 + tree origtype = TREE_TYPE(orig_rhs);
108683 +
108684 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
108685 +
108686 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108687 + return gimple_get_lhs(assign);
108688 +}
108689 +
108690 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
108691 +{
108692 + const_tree rhs1, lhs, rhs1_type, lhs_type;
108693 + enum machine_mode lhs_mode, rhs_mode;
108694 + gimple def_stmt = get_def_stmt(no_const_rhs);
108695 +
108696 + if (!gimple_assign_cast_p(def_stmt))
108697 + return false;
108698 +
108699 + rhs1 = gimple_assign_rhs1(def_stmt);
108700 + lhs = gimple_get_lhs(def_stmt);
108701 + rhs1_type = TREE_TYPE(rhs1);
108702 + lhs_type = TREE_TYPE(lhs);
108703 + rhs_mode = TYPE_MODE(rhs1_type);
108704 + lhs_mode = TYPE_MODE(lhs_type);
108705 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
108706 + return false;
108707 +
108708 + return true;
108709 +}
108710 +
108711 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
108712 +{
108713 + tree rhs1 = gimple_assign_rhs1(stmt);
108714 + tree lhs = gimple_get_lhs(stmt);
108715 + const_tree rhs1_type = TREE_TYPE(rhs1);
108716 + const_tree lhs_type = TREE_TYPE(lhs);
108717 +
108718 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
108719 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108720 +
108721 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
108722 +}
108723 +
108724 +static bool no_uses(tree node)
108725 +{
108726 + imm_use_iterator imm_iter;
108727 + use_operand_p use_p;
108728 +
108729 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
108730 + const_gimple use_stmt = USE_STMT(use_p);
108731 + if (use_stmt == NULL)
108732 + return true;
108733 + if (is_gimple_debug(use_stmt))
108734 + continue;
108735 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
108736 + continue;
108737 + return false;
108738 + }
108739 + return true;
108740 +}
108741 +
108742 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
108743 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
108744 +{
108745 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
108746 + gimple def_stmt = get_def_stmt(lhs);
108747 +
108748 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
108749 + return false;
108750 +
108751 + rhs1 = gimple_assign_rhs1(def_stmt);
108752 + rhs_type = TREE_TYPE(rhs1);
108753 + lhs_type = TREE_TYPE(lhs);
108754 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
108755 + return false;
108756 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
108757 + return false;
108758 +
108759 + def_stmt = get_def_stmt(rhs1);
108760 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
108761 + return false;
108762 +
108763 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
108764 + return false;
108765 +
108766 + rhs1 = gimple_assign_rhs1(def_stmt);
108767 + rhs2 = gimple_assign_rhs2(def_stmt);
108768 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
108769 + return false;
108770 +
108771 + if (is_gimple_constant(rhs2))
108772 + not_const_rhs = rhs1;
108773 + else
108774 + not_const_rhs = rhs2;
108775 +
108776 + return no_uses(not_const_rhs);
108777 +}
108778 +
108779 +static bool skip_lhs_cast_check(const_gimple stmt)
108780 +{
108781 + const_tree rhs = gimple_assign_rhs1(stmt);
108782 + const_gimple def_stmt = get_def_stmt(rhs);
108783 +
108784 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
108785 + if (gimple_code(def_stmt) == GIMPLE_ASM)
108786 + return true;
108787 +
108788 + if (is_const_plus_unsigned_signed_truncation(rhs))
108789 + return true;
108790 +
108791 + return false;
108792 +}
108793 +
108794 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
108795 +{
108796 + bool cast_lhs, cast_rhs;
108797 + tree lhs = gimple_get_lhs(stmt);
108798 + tree rhs = gimple_assign_rhs1(stmt);
108799 + const_tree lhs_type = TREE_TYPE(lhs);
108800 + const_tree rhs_type = TREE_TYPE(rhs);
108801 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
108802 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
108803 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
108804 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
108805 +
108806 + static bool check_lhs[3][4] = {
108807 + // ss su us uu
108808 + { false, true, true, false }, // lhs > rhs
108809 + { false, false, false, false }, // lhs = rhs
108810 + { true, true, true, true }, // lhs < rhs
108811 + };
108812 +
108813 + static bool check_rhs[3][4] = {
108814 + // ss su us uu
108815 + { true, false, true, true }, // lhs > rhs
108816 + { true, false, true, true }, // lhs = rhs
108817 + { true, false, true, true }, // lhs < rhs
108818 + };
108819 +
108820 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
108821 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
108822 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108823 +
108824 + if (lhs_size > rhs_size) {
108825 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108826 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108827 + } else if (lhs_size == rhs_size) {
108828 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108829 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108830 + } else {
108831 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108832 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108833 + }
108834 +
108835 + if (!cast_lhs && !cast_rhs)
108836 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108837 +
108838 + if (cast_lhs && !skip_lhs_cast_check(stmt))
108839 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
108840 +
108841 + if (cast_rhs)
108842 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
108843 +
108844 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108845 +}
108846 +
108847 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
108848 +{
108849 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
108850 +
108851 + if (gimple_plf(stmt, MY_STMT))
108852 + return lhs;
108853 +
108854 + rhs1 = gimple_assign_rhs1(stmt);
108855 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
108856 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108857 +
108858 + new_rhs1 = expand(visited, rhs1);
108859 +
108860 + if (new_rhs1 == NULL_TREE)
108861 + return create_cast_assign(visited, stmt);
108862 +
108863 + if (gimple_plf(stmt, NO_CAST_CHECK))
108864 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108865 +
108866 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
108867 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
108868 +
108869 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
108870 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
108871 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108872 + }
108873 +
108874 + if (!gimple_assign_cast_p(stmt))
108875 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108876 +
108877 + return create_cast_overflow_check(visited, new_rhs1, stmt);
108878 +}
108879 +
108880 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
108881 +{
108882 + tree rhs1, lhs = gimple_get_lhs(stmt);
108883 + gimple def_stmt = get_def_stmt(lhs);
108884 +
108885 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
108886 + rhs1 = gimple_assign_rhs1(def_stmt);
108887 +
108888 + if (is_gimple_constant(rhs1))
108889 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108890 +
108891 + switch (TREE_CODE(rhs1)) {
108892 + case SSA_NAME:
108893 + return handle_unary_rhs(visited, def_stmt);
108894 + case ARRAY_REF:
108895 + case BIT_FIELD_REF:
108896 + case ADDR_EXPR:
108897 + case COMPONENT_REF:
108898 + case INDIRECT_REF:
108899 +#if BUILDING_GCC_VERSION >= 4006
108900 + case MEM_REF:
108901 +#endif
108902 + case TARGET_MEM_REF:
108903 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108904 + case PARM_DECL:
108905 + case VAR_DECL:
108906 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108907 +
108908 + default:
108909 + debug_gimple_stmt(def_stmt);
108910 + debug_tree(rhs1);
108911 + gcc_unreachable();
108912 + }
108913 +}
108914 +
108915 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
108916 +{
108917 + gimple cond_stmt;
108918 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
108919 +
108920 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
108921 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
108922 + update_stmt(cond_stmt);
108923 +}
108924 +
108925 +static tree create_string_param(tree string)
108926 +{
108927 + tree i_type, a_type;
108928 + const int length = TREE_STRING_LENGTH(string);
108929 +
108930 + gcc_assert(length > 0);
108931 +
108932 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
108933 + a_type = build_array_type(char_type_node, i_type);
108934 +
108935 + TREE_TYPE(string) = a_type;
108936 + TREE_CONSTANT(string) = 1;
108937 + TREE_READONLY(string) = 1;
108938 +
108939 + return build1(ADDR_EXPR, ptr_type_node, string);
108940 +}
108941 +
108942 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
108943 +{
108944 + gimple func_stmt;
108945 + const_gimple def_stmt;
108946 + const_tree loc_line;
108947 + tree loc_file, ssa_name, current_func;
108948 + expanded_location xloc;
108949 + char *ssa_name_buf;
108950 + int len;
108951 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
108952 +
108953 + def_stmt = get_def_stmt(arg);
108954 + xloc = expand_location(gimple_location(def_stmt));
108955 +
108956 + if (!gimple_has_location(def_stmt)) {
108957 + xloc = expand_location(gimple_location(stmt));
108958 + if (!gimple_has_location(stmt))
108959 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
108960 + }
108961 +
108962 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
108963 +
108964 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
108965 + loc_file = create_string_param(loc_file);
108966 +
108967 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
108968 + current_func = create_string_param(current_func);
108969 +
108970 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
108971 + call_count++;
108972 + 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);
108973 + gcc_assert(len > 0);
108974 + ssa_name = build_string(len + 1, ssa_name_buf);
108975 + free(ssa_name_buf);
108976 + ssa_name = create_string_param(ssa_name);
108977 +
108978 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
108979 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
108980 +
108981 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
108982 +}
108983 +
108984 +static void __unused print_the_code_insertions(const_gimple stmt)
108985 +{
108986 + location_t loc = gimple_location(stmt);
108987 +
108988 + inform(loc, "Integer size_overflow check applied here.");
108989 +}
108990 +
108991 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
108992 +{
108993 + basic_block cond_bb, join_bb, bb_true;
108994 + edge e;
108995 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108996 +
108997 + cond_bb = gimple_bb(stmt);
108998 + if (before)
108999 + gsi_prev(&gsi);
109000 + if (gsi_end_p(gsi))
109001 + e = split_block_after_labels(cond_bb);
109002 + else
109003 + e = split_block(cond_bb, gsi_stmt(gsi));
109004 + cond_bb = e->src;
109005 + join_bb = e->dest;
109006 + e->flags = EDGE_FALSE_VALUE;
109007 + e->probability = REG_BR_PROB_BASE;
109008 +
109009 + bb_true = create_empty_bb(cond_bb);
109010 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
109011 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
109012 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
109013 +
109014 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109015 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
109016 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
109017 +
109018 + if (current_loops != NULL) {
109019 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
109020 + add_bb_to_loop(bb_true, cond_bb->loop_father);
109021 + }
109022 +
109023 + insert_cond(cond_bb, arg, cond_code, type_value);
109024 + insert_cond_result(bb_true, stmt, arg, min);
109025 +
109026 +// print_the_code_insertions(stmt);
109027 +}
109028 +
109029 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
109030 +{
109031 + const_tree rhs_type = TREE_TYPE(rhs);
109032 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
109033 +
109034 + gcc_assert(rhs_type != NULL_TREE);
109035 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
109036 + return;
109037 +
109038 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
109039 +
109040 + if (is_const_plus_unsigned_signed_truncation(rhs))
109041 + return;
109042 +
109043 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
109044 + // typemax (-1) < typemin (0)
109045 + if (TREE_OVERFLOW(type_max))
109046 + return;
109047 +
109048 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
109049 +
109050 + cast_rhs_type = TREE_TYPE(cast_rhs);
109051 + type_max_type = TREE_TYPE(type_max);
109052 + type_min_type = TREE_TYPE(type_min);
109053 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
109054 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
109055 +
109056 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
109057 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
109058 +}
109059 +
109060 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
109061 +{
109062 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
109063 + return false;
109064 + if (!is_gimple_constant(rhs))
109065 + return false;
109066 + return true;
109067 +}
109068 +
109069 +static tree get_def_stmt_rhs(const_tree var)
109070 +{
109071 + tree rhs1, def_stmt_rhs1;
109072 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
109073 +
109074 + def_stmt = get_def_stmt(var);
109075 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
109076 +
109077 + rhs1 = gimple_assign_rhs1(def_stmt);
109078 + rhs1_def_stmt = get_def_stmt(rhs1);
109079 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109080 + return rhs1;
109081 +
109082 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109083 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109084 +
109085 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109086 + case GIMPLE_CALL:
109087 + case GIMPLE_NOP:
109088 + case GIMPLE_ASM:
109089 + case GIMPLE_PHI:
109090 + return def_stmt_rhs1;
109091 + case GIMPLE_ASSIGN:
109092 + return rhs1;
109093 + default:
109094 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109095 + gcc_unreachable();
109096 + }
109097 +}
109098 +
109099 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109100 +{
109101 + tree new_rhs, orig_rhs;
109102 + void (*gimple_assign_set_rhs)(gimple, tree);
109103 + tree rhs1 = gimple_assign_rhs1(stmt);
109104 + tree rhs2 = gimple_assign_rhs2(stmt);
109105 + tree lhs = gimple_get_lhs(stmt);
109106 +
109107 + if (!check_overflow)
109108 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109109 +
109110 + if (change_rhs == NULL_TREE)
109111 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109112 +
109113 + if (new_rhs2 == NULL_TREE) {
109114 + orig_rhs = rhs1;
109115 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109116 + } else {
109117 + orig_rhs = rhs2;
109118 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109119 + }
109120 +
109121 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109122 +
109123 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109124 + gimple_assign_set_rhs(stmt, new_rhs);
109125 + update_stmt(stmt);
109126 +
109127 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109128 +}
109129 +
109130 +static bool is_subtraction_special(const_gimple stmt)
109131 +{
109132 + gimple rhs1_def_stmt, rhs2_def_stmt;
109133 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109134 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109135 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109136 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109137 +
109138 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109139 + return false;
109140 +
109141 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109142 +
109143 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109144 + return false;
109145 +
109146 + rhs1_def_stmt = get_def_stmt(rhs1);
109147 + rhs2_def_stmt = get_def_stmt(rhs2);
109148 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109149 + return false;
109150 +
109151 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109152 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109153 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109154 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109155 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109156 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109157 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109158 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109159 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109160 + return false;
109161 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109162 + return false;
109163 +
109164 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109165 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109166 + return true;
109167 +}
109168 +
109169 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109170 +{
109171 + tree new_rhs1, new_rhs2;
109172 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109173 + gimple assign, stmt = get_def_stmt(lhs);
109174 + tree rhs1 = gimple_assign_rhs1(stmt);
109175 + tree rhs2 = gimple_assign_rhs2(stmt);
109176 +
109177 + if (!is_subtraction_special(stmt))
109178 + return NULL_TREE;
109179 +
109180 + new_rhs1 = expand(visited, rhs1);
109181 + new_rhs2 = expand(visited, rhs2);
109182 +
109183 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
109184 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
109185 +
109186 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
109187 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
109188 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
109189 + }
109190 +
109191 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
109192 + new_lhs = gimple_get_lhs(assign);
109193 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
109194 +
109195 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109196 +}
109197 +
109198 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
109199 +{
109200 + const_gimple def_stmt;
109201 +
109202 + if (TREE_CODE(rhs) != SSA_NAME)
109203 + return false;
109204 +
109205 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
109206 + return false;
109207 +
109208 + def_stmt = get_def_stmt(rhs);
109209 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
109210 + return false;
109211 +
109212 + return true;
109213 +}
109214 +
109215 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
109216 +{
109217 + tree rhs1, rhs2, new_lhs;
109218 + gimple def_stmt = get_def_stmt(lhs);
109219 + tree new_rhs1 = NULL_TREE;
109220 + tree new_rhs2 = NULL_TREE;
109221 +
109222 + rhs1 = gimple_assign_rhs1(def_stmt);
109223 + rhs2 = gimple_assign_rhs2(def_stmt);
109224 +
109225 + /* no DImode/TImode division in the 32/64 bit kernel */
109226 + switch (gimple_assign_rhs_code(def_stmt)) {
109227 + case RDIV_EXPR:
109228 + case TRUNC_DIV_EXPR:
109229 + case CEIL_DIV_EXPR:
109230 + case FLOOR_DIV_EXPR:
109231 + case ROUND_DIV_EXPR:
109232 + case TRUNC_MOD_EXPR:
109233 + case CEIL_MOD_EXPR:
109234 + case FLOOR_MOD_EXPR:
109235 + case ROUND_MOD_EXPR:
109236 + case EXACT_DIV_EXPR:
109237 + case POINTER_PLUS_EXPR:
109238 + case BIT_AND_EXPR:
109239 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109240 + default:
109241 + break;
109242 + }
109243 +
109244 + new_lhs = handle_integer_truncation(visited, lhs);
109245 + if (new_lhs != NULL_TREE)
109246 + return new_lhs;
109247 +
109248 + if (TREE_CODE(rhs1) == SSA_NAME)
109249 + new_rhs1 = expand(visited, rhs1);
109250 + if (TREE_CODE(rhs2) == SSA_NAME)
109251 + new_rhs2 = expand(visited, rhs2);
109252 +
109253 + if (is_a_neg_overflow(def_stmt, rhs2))
109254 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
109255 + if (is_a_neg_overflow(def_stmt, rhs1))
109256 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
109257 +
109258 +
109259 + if (is_a_constant_overflow(def_stmt, rhs2))
109260 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
109261 + if (is_a_constant_overflow(def_stmt, rhs1))
109262 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
109263 +
109264 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109265 +}
109266 +
109267 +#if BUILDING_GCC_VERSION >= 4007
109268 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
109269 +{
109270 + if (is_gimple_constant(rhs))
109271 + return cast_a_tree(size_overflow_type, rhs);
109272 + if (TREE_CODE(rhs) != SSA_NAME)
109273 + return NULL_TREE;
109274 + return expand(visited, rhs);
109275 +}
109276 +
109277 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
109278 +{
109279 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
109280 + gimple def_stmt = get_def_stmt(lhs);
109281 +
109282 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
109283 +
109284 + rhs1 = gimple_assign_rhs1(def_stmt);
109285 + rhs2 = gimple_assign_rhs2(def_stmt);
109286 + rhs3 = gimple_assign_rhs3(def_stmt);
109287 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
109288 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
109289 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
109290 +
109291 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
109292 +}
109293 +#endif
109294 +
109295 +static tree get_size_overflow_type(gimple stmt, const_tree node)
109296 +{
109297 + const_tree type;
109298 + tree new_type;
109299 +
109300 + gcc_assert(node != NULL_TREE);
109301 +
109302 + type = TREE_TYPE(node);
109303 +
109304 + if (gimple_plf(stmt, MY_STMT))
109305 + return TREE_TYPE(node);
109306 +
109307 + switch (TYPE_MODE(type)) {
109308 + case QImode:
109309 + new_type = intHI_type_node;
109310 + break;
109311 + case HImode:
109312 + new_type = intSI_type_node;
109313 + break;
109314 + case SImode:
109315 + new_type = intDI_type_node;
109316 + break;
109317 + case DImode:
109318 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109319 + new_type = intDI_type_node;
109320 + else
109321 + new_type = intTI_type_node;
109322 + break;
109323 + default:
109324 + debug_tree((tree)node);
109325 + error("%s: unsupported gcc configuration.", __func__);
109326 + gcc_unreachable();
109327 + }
109328 +
109329 + if (TYPE_QUALS(type) != 0)
109330 + return build_qualified_type(new_type, TYPE_QUALS(type));
109331 + return new_type;
109332 +}
109333 +
109334 +static tree expand_visited(gimple def_stmt)
109335 +{
109336 + const_gimple next_stmt;
109337 + gimple_stmt_iterator gsi;
109338 + enum gimple_code code = gimple_code(def_stmt);
109339 +
109340 + if (code == GIMPLE_ASM)
109341 + return NULL_TREE;
109342 +
109343 + gsi = gsi_for_stmt(def_stmt);
109344 + gsi_next(&gsi);
109345 +
109346 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
109347 + return NULL_TREE;
109348 + gcc_assert(!gsi_end_p(gsi));
109349 + next_stmt = gsi_stmt(gsi);
109350 +
109351 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
109352 + return NULL_TREE;
109353 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
109354 +
109355 + return get_lhs(next_stmt);
109356 +}
109357 +
109358 +static tree expand(struct pointer_set_t *visited, tree lhs)
109359 +{
109360 + gimple def_stmt;
109361 +
109362 + if (skip_types(lhs))
109363 + return NULL_TREE;
109364 +
109365 + def_stmt = get_def_stmt(lhs);
109366 +
109367 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
109368 + return NULL_TREE;
109369 +
109370 + if (gimple_plf(def_stmt, MY_STMT))
109371 + return lhs;
109372 +
109373 + if (pointer_set_contains(visited, def_stmt))
109374 + return expand_visited(def_stmt);
109375 +
109376 + switch (gimple_code(def_stmt)) {
109377 + case GIMPLE_PHI:
109378 + return handle_phi(visited, lhs);
109379 + case GIMPLE_CALL:
109380 + case GIMPLE_ASM:
109381 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109382 + case GIMPLE_ASSIGN:
109383 + switch (gimple_num_ops(def_stmt)) {
109384 + case 2:
109385 + return handle_unary_ops(visited, def_stmt);
109386 + case 3:
109387 + return handle_binary_ops(visited, lhs);
109388 +#if BUILDING_GCC_VERSION >= 4007
109389 + case 4:
109390 + return handle_ternary_ops(visited, lhs);
109391 +#endif
109392 + }
109393 + default:
109394 + debug_gimple_stmt(def_stmt);
109395 + error("%s: unknown gimple code", __func__);
109396 + gcc_unreachable();
109397 + }
109398 +}
109399 +
109400 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
109401 +{
109402 + const_gimple assign;
109403 + tree orig_type = TREE_TYPE(orig_node);
109404 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109405 +
109406 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109407 + return gimple_get_lhs(assign);
109408 +}
109409 +
109410 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
109411 +{
109412 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
109413 + update_stmt(stmt);
109414 +}
109415 +
109416 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
109417 +{
109418 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
109419 + update_stmt(stmt);
109420 +}
109421 +
109422 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
109423 +{
109424 + tree arg;
109425 + const_tree origarg;
109426 +
109427 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
109428 + return true;
109429 +
109430 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
109431 + while (origarg && *argnum) {
109432 + (*argnum)--;
109433 + origarg = TREE_CHAIN(origarg);
109434 + }
109435 +
109436 + gcc_assert(*argnum == 0);
109437 +
109438 + gcc_assert(origarg != NULL_TREE);
109439 + *argnum = 0;
109440 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
109441 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
109442 + return true;
109443 + return false;
109444 +}
109445 +
109446 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
109447 +{
109448 + gimple phi = get_def_stmt(result);
109449 + unsigned int i, n = gimple_phi_num_args(phi);
109450 +
109451 + if (!phi)
109452 + return MARK_NO;
109453 +
109454 + pointer_set_insert(visited, phi);
109455 + for (i = 0; i < n; i++) {
109456 + enum mark marked;
109457 + const_tree arg = gimple_phi_arg_def(phi, i);
109458 + marked = pre_expand(visited, search_err_code, arg);
109459 + if (marked != MARK_NO)
109460 + return marked;
109461 + }
109462 + return MARK_NO;
109463 +}
109464 +
109465 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109466 +{
109467 + gimple def_stmt = get_def_stmt(lhs);
109468 + const_tree rhs;
109469 +
109470 + if (!def_stmt)
109471 + return MARK_NO;
109472 +
109473 + rhs = gimple_assign_rhs1(def_stmt);
109474 +
109475 + def_stmt = get_def_stmt(rhs);
109476 + if (is_gimple_constant(rhs))
109477 + search_err_code[FROM_CONST] = true;
109478 +
109479 + return pre_expand(visited, search_err_code, rhs);
109480 +}
109481 +
109482 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109483 +{
109484 + gimple def_stmt = get_def_stmt(lhs);
109485 + const_tree rhs1, rhs2;
109486 + enum mark marked;
109487 +
109488 + if (!def_stmt)
109489 + return MARK_NO;
109490 +
109491 + search_err_code[CAST_ONLY] = false;
109492 +
109493 + rhs1 = gimple_assign_rhs1(def_stmt);
109494 + rhs2 = gimple_assign_rhs2(def_stmt);
109495 + marked = pre_expand(visited, search_err_code, rhs1);
109496 + if (marked != MARK_NO)
109497 + return marked;
109498 + return pre_expand(visited, search_err_code, rhs2);
109499 +}
109500 +
109501 +static const_tree search_field_decl(const_tree comp_ref)
109502 +{
109503 + const_tree field = NULL_TREE;
109504 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
109505 +
109506 + for (i = 0; i < len; i++) {
109507 + field = TREE_OPERAND(comp_ref, i);
109508 + if (TREE_CODE(field) == FIELD_DECL)
109509 + break;
109510 + }
109511 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
109512 + return field;
109513 +}
109514 +
109515 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
109516 +{
109517 + const_tree attr, p;
109518 +
109519 + // 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);
109520 + if (fndecl == NULL_TREE)
109521 + return MARK_NO;
109522 +
109523 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
109524 + if (!attr || !TREE_VALUE(attr))
109525 + return MARK_NO;
109526 +
109527 + p = TREE_VALUE(attr);
109528 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
109529 + return MARK_TURN_OFF;
109530 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
109531 + return MARK_NOT_INTENTIONAL;
109532 + if (argnum == 0) {
109533 + gcc_assert(current_function_decl == fndecl);
109534 + return MARK_NO;
109535 + }
109536 +
109537 + do {
109538 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
109539 + return MARK_YES;
109540 + p = TREE_CHAIN(p);
109541 + } while (p);
109542 +
109543 + return MARK_NO;
109544 +}
109545 +
109546 +static void print_missing_msg(tree func, unsigned int argnum)
109547 +{
109548 + unsigned int new_hash;
109549 + size_t len;
109550 + unsigned char tree_codes[CODES_LIMIT];
109551 + location_t loc;
109552 + const char *curfunc;
109553 +
109554 + func = get_original_function_decl(func);
109555 + loc = DECL_SOURCE_LOCATION(func);
109556 + curfunc = get_asm_name(func);
109557 +
109558 + len = get_function_decl(func, tree_codes);
109559 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
109560 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
109561 +}
109562 +
109563 +static unsigned int search_missing_attribute(const_tree arg)
109564 +{
109565 + unsigned int argnum;
109566 + const struct size_overflow_hash *hash;
109567 + const_tree type = TREE_TYPE(arg);
109568 + tree func = get_original_function_decl(current_function_decl);
109569 +
109570 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
109571 +
109572 + if (TREE_CODE(type) == POINTER_TYPE)
109573 + return 0;
109574 +
109575 + argnum = find_arg_number(arg, func);
109576 + if (argnum == 0)
109577 + return 0;
109578 +
109579 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
109580 + return argnum;
109581 +
109582 + hash = get_function_hash(func);
109583 + if (!hash || !(hash->param & (1U << argnum))) {
109584 + print_missing_msg(func, argnum);
109585 + return 0;
109586 + }
109587 + return argnum;
109588 +}
109589 +
109590 +static enum mark is_already_marked(const_tree lhs)
109591 +{
109592 + unsigned int argnum;
109593 + const_tree fndecl;
109594 +
109595 + argnum = search_missing_attribute(lhs);
109596 + fndecl = get_original_function_decl(current_function_decl);
109597 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
109598 + return MARK_YES;
109599 + return MARK_NO;
109600 +}
109601 +
109602 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109603 +{
109604 + const_gimple def_stmt;
109605 +
109606 + if (skip_types(lhs))
109607 + return MARK_NO;
109608 +
109609 + if (TREE_CODE(lhs) == PARM_DECL)
109610 + return is_already_marked(lhs);
109611 +
109612 + if (TREE_CODE(lhs) == COMPONENT_REF) {
109613 + const_tree field, attr;
109614 +
109615 + field = search_field_decl(lhs);
109616 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
109617 + if (!attr || !TREE_VALUE(attr))
109618 + return MARK_NO;
109619 + return MARK_YES;
109620 + }
109621 +
109622 + def_stmt = get_def_stmt(lhs);
109623 +
109624 + if (!def_stmt)
109625 + return MARK_NO;
109626 +
109627 + if (pointer_set_contains(visited, def_stmt))
109628 + return MARK_NO;
109629 +
109630 + switch (gimple_code(def_stmt)) {
109631 + case GIMPLE_NOP:
109632 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
109633 + return is_already_marked(lhs);
109634 + return MARK_NO;
109635 + case GIMPLE_PHI:
109636 + return walk_phi(visited, search_err_code, lhs);
109637 + case GIMPLE_CALL:
109638 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
109639 + return MARK_TURN_OFF;
109640 + check_function_hash(def_stmt);
109641 + return MARK_NO;
109642 + case GIMPLE_ASM:
109643 + search_err_code[CAST_ONLY] = false;
109644 + return MARK_NO;
109645 + case GIMPLE_ASSIGN:
109646 + switch (gimple_num_ops(def_stmt)) {
109647 + case 2:
109648 + return walk_unary_ops(visited, search_err_code, lhs);
109649 + case 3:
109650 + return walk_binary_ops(visited, search_err_code, lhs);
109651 + }
109652 + default:
109653 + debug_gimple_stmt((gimple)def_stmt);
109654 + error("%s: unknown gimple code", __func__);
109655 + gcc_unreachable();
109656 + }
109657 +}
109658 +
109659 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
109660 +static bool skip_asm(const_tree arg)
109661 +{
109662 + gimple def_stmt = get_def_stmt(arg);
109663 +
109664 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109665 + return false;
109666 +
109667 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
109668 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
109669 +}
109670 +
109671 +/*
109672 +0</MARK_YES: no dup, search attributes (so, int)
109673 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
109674 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
109675 +*/
109676 +
109677 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
109678 +{
109679 + struct pointer_set_t *visited;
109680 + enum mark is_marked, is_found;
109681 + location_t loc;
109682 + bool search_err_code[2] = {true, false};
109683 +
109684 + is_marked = mark_status(current_function_decl, 0);
109685 + if (is_marked == MARK_TURN_OFF)
109686 + return true;
109687 +
109688 + is_marked = mark_status(fndecl, argnum + 1);
109689 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
109690 + return true;
109691 +
109692 + visited = pointer_set_create();
109693 + is_found = pre_expand(visited, search_err_code, arg);
109694 + pointer_set_destroy(visited);
109695 +
109696 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
109697 + return true;
109698 +
109699 + if (where == FROM_ARG && skip_asm(arg))
109700 + return true;
109701 +
109702 + if (is_found == MARK_TURN_OFF)
109703 + return true;
109704 +
109705 + if ((is_found == MARK_YES && is_marked == MARK_YES))
109706 + return true;
109707 +
109708 + if (is_found == MARK_YES) {
109709 + loc = DECL_SOURCE_LOCATION(fndecl);
109710 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
109711 + return true;
109712 + }
109713 + return false;
109714 +}
109715 +
109716 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
109717 +{
109718 + struct pointer_set_t *visited;
109719 + tree arg, new_arg;
109720 + bool match;
109721 +
109722 + if (argnum == 0)
109723 + return;
109724 +
109725 + argnum--;
109726 +
109727 + match = get_function_arg(&argnum, fndecl);
109728 + if (!match)
109729 + return;
109730 + gcc_assert(gimple_call_num_args(stmt) > argnum);
109731 + arg = gimple_call_arg(stmt, argnum);
109732 + if (arg == NULL_TREE)
109733 + return;
109734 +
109735 + if (skip_types(arg))
109736 + return;
109737 +
109738 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
109739 + return;
109740 +
109741 + visited = pointer_set_create();
109742 + new_arg = expand(visited, arg);
109743 + pointer_set_destroy(visited);
109744 +
109745 + if (new_arg == NULL_TREE)
109746 + return;
109747 +
109748 + change_function_arg(stmt, arg, argnum, new_arg);
109749 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
109750 +}
109751 +
109752 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
109753 +{
109754 + tree p = TREE_VALUE(attr);
109755 + do {
109756 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
109757 + p = TREE_CHAIN(p);
109758 + } while (p);
109759 +}
109760 +
109761 +static void handle_function_by_hash(gimple stmt, tree fndecl)
109762 +{
109763 + unsigned int num;
109764 + const struct size_overflow_hash *hash;
109765 +
109766 + hash = get_function_hash(fndecl);
109767 + if (!hash)
109768 + return;
109769 +
109770 + for (num = 0; num <= MAX_PARAM; num++)
109771 + if (hash->param & (1U << num))
109772 + handle_function_arg(stmt, fndecl, num);
109773 +}
109774 +
109775 +static bool check_return_value(void)
109776 +{
109777 + const struct size_overflow_hash *hash;
109778 +
109779 + hash = get_function_hash(current_function_decl);
109780 + if (!hash || !(hash->param & 1U << 0))
109781 + return false;
109782 +
109783 + return true;
109784 +}
109785 +
109786 +static void handle_return_value(gimple ret_stmt)
109787 +{
109788 + struct pointer_set_t *visited;
109789 + tree ret, new_ret;
109790 +
109791 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
109792 + return;
109793 +
109794 + ret = gimple_return_retval(ret_stmt);
109795 +
109796 + if (skip_types(ret))
109797 + return;
109798 +
109799 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
109800 + return;
109801 +
109802 + visited = pointer_set_create();
109803 + new_ret = expand(visited, ret);
109804 + pointer_set_destroy(visited);
109805 +
109806 + change_function_return(ret_stmt, ret, new_ret);
109807 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
109808 +}
109809 +
109810 +static void set_plf_false(void)
109811 +{
109812 + basic_block bb;
109813 +
109814 + FOR_ALL_BB(bb) {
109815 + gimple_stmt_iterator si;
109816 +
109817 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
109818 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
109819 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
109820 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
109821 + }
109822 +}
109823 +
109824 +static unsigned int handle_function(void)
109825 +{
109826 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
109827 + bool check_ret;
109828 +
109829 + set_plf_false();
109830 +
109831 + check_ret = check_return_value();
109832 +
109833 + do {
109834 + gimple_stmt_iterator gsi;
109835 + next = bb->next_bb;
109836 +
109837 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
109838 + tree fndecl, attr;
109839 + gimple stmt = gsi_stmt(gsi);
109840 +
109841 + if (check_ret)
109842 + handle_return_value(stmt);
109843 +
109844 + if (!(is_gimple_call(stmt)))
109845 + continue;
109846 + fndecl = gimple_call_fndecl(stmt);
109847 + if (fndecl == NULL_TREE)
109848 + continue;
109849 + if (gimple_call_num_args(stmt) == 0)
109850 + continue;
109851 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
109852 + if (!attr || !TREE_VALUE(attr))
109853 + handle_function_by_hash(stmt, fndecl);
109854 + else
109855 + handle_function_by_attribute(stmt, attr, fndecl);
109856 + gsi = gsi_for_stmt(stmt);
109857 + next = gimple_bb(stmt)->next_bb;
109858 + }
109859 + bb = next;
109860 + } while (bb);
109861 + return 0;
109862 +}
109863 +
109864 +static struct gimple_opt_pass size_overflow_pass = {
109865 + .pass = {
109866 + .type = GIMPLE_PASS,
109867 + .name = "size_overflow",
109868 +#if BUILDING_GCC_VERSION >= 4008
109869 + .optinfo_flags = OPTGROUP_NONE,
109870 +#endif
109871 + .gate = NULL,
109872 + .execute = handle_function,
109873 + .sub = NULL,
109874 + .next = NULL,
109875 + .static_pass_number = 0,
109876 + .tv_id = TV_NONE,
109877 + .properties_required = PROP_cfg,
109878 + .properties_provided = 0,
109879 + .properties_destroyed = 0,
109880 + .todo_flags_start = 0,
109881 + .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
109882 + }
109883 +};
109884 +
109885 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
109886 +{
109887 + tree fntype;
109888 +
109889 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
109890 +
109891 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
109892 + fntype = build_function_type_list(void_type_node,
109893 + const_char_ptr_type_node,
109894 + unsigned_type_node,
109895 + const_char_ptr_type_node,
109896 + const_char_ptr_type_node,
109897 + NULL_TREE);
109898 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
109899 +
109900 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
109901 + TREE_PUBLIC(report_size_overflow_decl) = 1;
109902 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
109903 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
109904 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
109905 +}
109906 +
109907 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
109908 +{
109909 + int i;
109910 + const char * const plugin_name = plugin_info->base_name;
109911 + const int argc = plugin_info->argc;
109912 + const struct plugin_argument * const argv = plugin_info->argv;
109913 + bool enable = true;
109914 +
109915 + struct register_pass_info size_overflow_pass_info = {
109916 + .pass = &size_overflow_pass.pass,
109917 + .reference_pass_name = "ssa",
109918 + .ref_pass_instance_number = 1,
109919 + .pos_op = PASS_POS_INSERT_AFTER
109920 + };
109921 +
109922 + if (!plugin_default_version_check(version, &gcc_version)) {
109923 + error(G_("incompatible gcc/plugin versions"));
109924 + return 1;
109925 + }
109926 +
109927 + for (i = 0; i < argc; ++i) {
109928 + if (!strcmp(argv[i].key, "no-size-overflow")) {
109929 + enable = false;
109930 + continue;
109931 + }
109932 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
109933 + }
109934 +
109935 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
109936 + if (enable) {
109937 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
109938 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
109939 + }
109940 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
109941 +
109942 + return 0;
109943 +}
109944 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
109945 new file mode 100644
109946 index 0000000..ac2901e
109947 --- /dev/null
109948 +++ b/tools/gcc/stackleak_plugin.c
109949 @@ -0,0 +1,327 @@
109950 +/*
109951 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
109952 + * Licensed under the GPL v2
109953 + *
109954 + * Note: the choice of the license means that the compilation process is
109955 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
109956 + * but for the kernel it doesn't matter since it doesn't link against
109957 + * any of the gcc libraries
109958 + *
109959 + * gcc plugin to help implement various PaX features
109960 + *
109961 + * - track lowest stack pointer
109962 + *
109963 + * TODO:
109964 + * - initialize all local variables
109965 + *
109966 + * BUGS:
109967 + * - none known
109968 + */
109969 +#include "gcc-plugin.h"
109970 +#include "config.h"
109971 +#include "system.h"
109972 +#include "coretypes.h"
109973 +#include "tree.h"
109974 +#include "tree-pass.h"
109975 +#include "flags.h"
109976 +#include "intl.h"
109977 +#include "toplev.h"
109978 +#include "plugin.h"
109979 +//#include "expr.h" where are you...
109980 +#include "diagnostic.h"
109981 +#include "plugin-version.h"
109982 +#include "tm.h"
109983 +#include "function.h"
109984 +#include "basic-block.h"
109985 +#include "gimple.h"
109986 +#include "rtl.h"
109987 +#include "emit-rtl.h"
109988 +
109989 +#if BUILDING_GCC_VERSION >= 4008
109990 +#define TODO_dump_func 0
109991 +#endif
109992 +
109993 +extern void print_gimple_stmt(FILE *, gimple, int, int);
109994 +
109995 +int plugin_is_GPL_compatible;
109996 +
109997 +static int track_frame_size = -1;
109998 +static const char track_function[] = "pax_track_stack";
109999 +static const char check_function[] = "pax_check_alloca";
110000 +static bool init_locals;
110001 +
110002 +static struct plugin_info stackleak_plugin_info = {
110003 + .version = "201302112000",
110004 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
110005 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
110006 +};
110007 +
110008 +static bool gate_stackleak_track_stack(void);
110009 +static unsigned int execute_stackleak_tree_instrument(void);
110010 +static unsigned int execute_stackleak_final(void);
110011 +
110012 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
110013 + .pass = {
110014 + .type = GIMPLE_PASS,
110015 + .name = "stackleak_tree_instrument",
110016 +#if BUILDING_GCC_VERSION >= 4008
110017 + .optinfo_flags = OPTGROUP_NONE,
110018 +#endif
110019 + .gate = gate_stackleak_track_stack,
110020 + .execute = execute_stackleak_tree_instrument,
110021 + .sub = NULL,
110022 + .next = NULL,
110023 + .static_pass_number = 0,
110024 + .tv_id = TV_NONE,
110025 + .properties_required = PROP_gimple_leh | PROP_cfg,
110026 + .properties_provided = 0,
110027 + .properties_destroyed = 0,
110028 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
110029 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
110030 + }
110031 +};
110032 +
110033 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
110034 + .pass = {
110035 + .type = RTL_PASS,
110036 + .name = "stackleak_final",
110037 +#if BUILDING_GCC_VERSION >= 4008
110038 + .optinfo_flags = OPTGROUP_NONE,
110039 +#endif
110040 + .gate = gate_stackleak_track_stack,
110041 + .execute = execute_stackleak_final,
110042 + .sub = NULL,
110043 + .next = NULL,
110044 + .static_pass_number = 0,
110045 + .tv_id = TV_NONE,
110046 + .properties_required = 0,
110047 + .properties_provided = 0,
110048 + .properties_destroyed = 0,
110049 + .todo_flags_start = 0,
110050 + .todo_flags_finish = TODO_dump_func
110051 + }
110052 +};
110053 +
110054 +static bool gate_stackleak_track_stack(void)
110055 +{
110056 + return track_frame_size >= 0;
110057 +}
110058 +
110059 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
110060 +{
110061 + gimple check_alloca;
110062 + tree fntype, fndecl, alloca_size;
110063 +
110064 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
110065 + fndecl = build_fn_decl(check_function, fntype);
110066 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110067 +
110068 + // insert call to void pax_check_alloca(unsigned long size)
110069 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
110070 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
110071 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
110072 +}
110073 +
110074 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
110075 +{
110076 + gimple track_stack;
110077 + tree fntype, fndecl;
110078 +
110079 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110080 + fndecl = build_fn_decl(track_function, fntype);
110081 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110082 +
110083 + // insert call to void pax_track_stack(void)
110084 + track_stack = gimple_build_call(fndecl, 0);
110085 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110086 +}
110087 +
110088 +#if BUILDING_GCC_VERSION == 4005
110089 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110090 +{
110091 + tree fndecl;
110092 +
110093 + if (!is_gimple_call(stmt))
110094 + return false;
110095 + fndecl = gimple_call_fndecl(stmt);
110096 + if (!fndecl)
110097 + return false;
110098 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110099 + return false;
110100 +// print_node(stderr, "pax", fndecl, 4);
110101 + return DECL_FUNCTION_CODE(fndecl) == code;
110102 +}
110103 +#endif
110104 +
110105 +static bool is_alloca(gimple stmt)
110106 +{
110107 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110108 + return true;
110109 +
110110 +#if BUILDING_GCC_VERSION >= 4007
110111 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110112 + return true;
110113 +#endif
110114 +
110115 + return false;
110116 +}
110117 +
110118 +static unsigned int execute_stackleak_tree_instrument(void)
110119 +{
110120 + basic_block bb, entry_bb;
110121 + bool prologue_instrumented = false, is_leaf = true;
110122 +
110123 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110124 +
110125 + // 1. loop through BBs and GIMPLE statements
110126 + FOR_EACH_BB(bb) {
110127 + gimple_stmt_iterator gsi;
110128 +
110129 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110130 + gimple stmt;
110131 +
110132 + stmt = gsi_stmt(gsi);
110133 +
110134 + if (is_gimple_call(stmt))
110135 + is_leaf = false;
110136 +
110137 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110138 + if (!is_alloca(stmt))
110139 + continue;
110140 +
110141 + // 2. insert stack overflow check before each __builtin_alloca call
110142 + stackleak_check_alloca(&gsi);
110143 +
110144 + // 3. insert track call after each __builtin_alloca call
110145 + stackleak_add_instrumentation(&gsi);
110146 + if (bb == entry_bb)
110147 + prologue_instrumented = true;
110148 + }
110149 + }
110150 +
110151 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110152 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110153 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110154 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110155 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110156 + return 0;
110157 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110158 + return 0;
110159 +
110160 + // 4. insert track call at the beginning
110161 + if (!prologue_instrumented) {
110162 + gimple_stmt_iterator gsi;
110163 +
110164 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110165 + if (dom_info_available_p(CDI_DOMINATORS))
110166 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110167 + gsi = gsi_start_bb(bb);
110168 + stackleak_add_instrumentation(&gsi);
110169 + }
110170 +
110171 + return 0;
110172 +}
110173 +
110174 +static unsigned int execute_stackleak_final(void)
110175 +{
110176 + rtx insn, next;
110177 +
110178 + if (cfun->calls_alloca)
110179 + return 0;
110180 +
110181 + // keep calls only if function frame is big enough
110182 + if (get_frame_size() >= track_frame_size)
110183 + return 0;
110184 +
110185 + // 1. find pax_track_stack calls
110186 + for (insn = get_insns(); insn; insn = next) {
110187 + // 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))
110188 + rtx body;
110189 +
110190 + next = NEXT_INSN(insn);
110191 + if (!CALL_P(insn))
110192 + continue;
110193 + body = PATTERN(insn);
110194 + if (GET_CODE(body) != CALL)
110195 + continue;
110196 + body = XEXP(body, 0);
110197 + if (GET_CODE(body) != MEM)
110198 + continue;
110199 + body = XEXP(body, 0);
110200 + if (GET_CODE(body) != SYMBOL_REF)
110201 + continue;
110202 + if (strcmp(XSTR(body, 0), track_function))
110203 + continue;
110204 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110205 + // 2. delete call
110206 + delete_insn_and_edges(insn);
110207 +#if BUILDING_GCC_VERSION >= 4007
110208 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
110209 + insn = next;
110210 + next = NEXT_INSN(insn);
110211 + delete_insn_and_edges(insn);
110212 + }
110213 +#endif
110214 + }
110215 +
110216 +// print_simple_rtl(stderr, get_insns());
110217 +// print_rtl(stderr, get_insns());
110218 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110219 +
110220 + return 0;
110221 +}
110222 +
110223 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110224 +{
110225 + const char * const plugin_name = plugin_info->base_name;
110226 + const int argc = plugin_info->argc;
110227 + const struct plugin_argument * const argv = plugin_info->argv;
110228 + int i;
110229 + struct register_pass_info stackleak_tree_instrument_pass_info = {
110230 + .pass = &stackleak_tree_instrument_pass.pass,
110231 +// .reference_pass_name = "tree_profile",
110232 + .reference_pass_name = "optimized",
110233 + .ref_pass_instance_number = 1,
110234 + .pos_op = PASS_POS_INSERT_BEFORE
110235 + };
110236 + struct register_pass_info stackleak_final_pass_info = {
110237 + .pass = &stackleak_final_rtl_opt_pass.pass,
110238 + .reference_pass_name = "final",
110239 + .ref_pass_instance_number = 1,
110240 + .pos_op = PASS_POS_INSERT_BEFORE
110241 + };
110242 +
110243 + if (!plugin_default_version_check(version, &gcc_version)) {
110244 + error(G_("incompatible gcc/plugin versions"));
110245 + return 1;
110246 + }
110247 +
110248 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
110249 +
110250 + for (i = 0; i < argc; ++i) {
110251 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
110252 + if (!argv[i].value) {
110253 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110254 + continue;
110255 + }
110256 + track_frame_size = atoi(argv[i].value);
110257 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
110258 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110259 + continue;
110260 + }
110261 + if (!strcmp(argv[i].key, "initialize-locals")) {
110262 + if (argv[i].value) {
110263 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110264 + continue;
110265 + }
110266 + init_locals = true;
110267 + continue;
110268 + }
110269 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110270 + }
110271 +
110272 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
110273 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
110274 +
110275 + return 0;
110276 +}
110277 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
110278 new file mode 100644
110279 index 0000000..4fae911
110280 --- /dev/null
110281 +++ b/tools/gcc/structleak_plugin.c
110282 @@ -0,0 +1,277 @@
110283 +/*
110284 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
110285 + * Licensed under the GPL v2
110286 + *
110287 + * Note: the choice of the license means that the compilation process is
110288 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110289 + * but for the kernel it doesn't matter since it doesn't link against
110290 + * any of the gcc libraries
110291 + *
110292 + * gcc plugin to forcibly initialize certain local variables that could
110293 + * otherwise leak kernel stack to userland if they aren't properly initialized
110294 + * by later code
110295 + *
110296 + * Homepage: http://pax.grsecurity.net/
110297 + *
110298 + * Usage:
110299 + * $ # for 4.5/4.6/C based 4.7
110300 + * $ 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
110301 + * $ # for C++ based 4.7/4.8+
110302 + * $ 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
110303 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
110304 + *
110305 + * TODO: eliminate redundant initializers
110306 + * increase type coverage
110307 + */
110308 +
110309 +#include "gcc-plugin.h"
110310 +#include "config.h"
110311 +#include "system.h"
110312 +#include "coretypes.h"
110313 +#include "tree.h"
110314 +#include "tree-pass.h"
110315 +#include "intl.h"
110316 +#include "plugin-version.h"
110317 +#include "tm.h"
110318 +#include "toplev.h"
110319 +#include "function.h"
110320 +#include "tree-flow.h"
110321 +#include "plugin.h"
110322 +#include "gimple.h"
110323 +#include "diagnostic.h"
110324 +#include "cfgloop.h"
110325 +#include "langhooks.h"
110326 +
110327 +#if BUILDING_GCC_VERSION >= 4008
110328 +#define TODO_dump_func 0
110329 +#endif
110330 +
110331 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110332 +
110333 +// unused type flag in all versions 4.5-4.8
110334 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
110335 +
110336 +int plugin_is_GPL_compatible;
110337 +void debug_gimple_stmt(gimple gs);
110338 +
110339 +static struct plugin_info structleak_plugin_info = {
110340 + .version = "201304082245",
110341 + .help = "disable\tdo not activate plugin\n",
110342 +};
110343 +
110344 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
110345 +{
110346 + *no_add_attrs = true;
110347 +
110348 + // check for types? for now accept everything linux has to offer
110349 + if (TREE_CODE(*node) != FIELD_DECL)
110350 + return NULL_TREE;
110351 +
110352 + *no_add_attrs = false;
110353 + return NULL_TREE;
110354 +}
110355 +
110356 +static struct attribute_spec user_attr = {
110357 + .name = "user",
110358 + .min_length = 0,
110359 + .max_length = 0,
110360 + .decl_required = false,
110361 + .type_required = false,
110362 + .function_type_required = false,
110363 + .handler = handle_user_attribute,
110364 +#if BUILDING_GCC_VERSION >= 4007
110365 + .affects_type_identity = true
110366 +#endif
110367 +};
110368 +
110369 +static void register_attributes(void *event_data, void *data)
110370 +{
110371 + register_attribute(&user_attr);
110372 +// register_attribute(&force_attr);
110373 +}
110374 +
110375 +static tree get_field_type(tree field)
110376 +{
110377 + return strip_array_types(TREE_TYPE(field));
110378 +}
110379 +
110380 +static bool is_userspace_type(tree type)
110381 +{
110382 + tree field;
110383 +
110384 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
110385 + tree fieldtype = get_field_type(field);
110386 + enum tree_code code = TREE_CODE(fieldtype);
110387 +
110388 + if (code == RECORD_TYPE || code == UNION_TYPE)
110389 + if (is_userspace_type(fieldtype))
110390 + return true;
110391 +
110392 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
110393 + return true;
110394 + }
110395 + return false;
110396 +}
110397 +
110398 +static void finish_type(void *event_data, void *data)
110399 +{
110400 + tree type = (tree)event_data;
110401 +
110402 + if (TYPE_USERSPACE(type))
110403 + return;
110404 +
110405 + if (is_userspace_type(type))
110406 + TYPE_USERSPACE(type) = 1;
110407 +}
110408 +
110409 +static void initialize(tree var)
110410 +{
110411 + basic_block bb;
110412 + gimple_stmt_iterator gsi;
110413 + tree initializer;
110414 + gimple init_stmt;
110415 +
110416 + // this is the original entry bb before the forced split
110417 + // TODO: check further BBs in case more splits occured before us
110418 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
110419 +
110420 + // first check if the variable is already initialized, warn otherwise
110421 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110422 + gimple stmt = gsi_stmt(gsi);
110423 + tree rhs1;
110424 +
110425 + // we're looking for an assignment of a single rhs...
110426 + if (!gimple_assign_single_p(stmt))
110427 + continue;
110428 + rhs1 = gimple_assign_rhs1(stmt);
110429 +#if BUILDING_GCC_VERSION >= 4007
110430 + // ... of a non-clobbering expression...
110431 + if (TREE_CLOBBER_P(rhs1))
110432 + continue;
110433 +#endif
110434 + // ... to our variable...
110435 + if (gimple_get_lhs(stmt) != var)
110436 + continue;
110437 + // if it's an initializer then we're good
110438 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
110439 + return;
110440 + }
110441 +
110442 + // these aren't the 0days you're looking for
110443 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
110444 +
110445 + // build the initializer expression
110446 + initializer = build_constructor(TREE_TYPE(var), NULL);
110447 +
110448 + // build the initializer stmt
110449 + init_stmt = gimple_build_assign(var, initializer);
110450 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
110451 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
110452 + update_stmt(init_stmt);
110453 +}
110454 +
110455 +static unsigned int handle_function(void)
110456 +{
110457 + basic_block bb;
110458 + unsigned int ret = 0;
110459 + tree var;
110460 +
110461 +#if BUILDING_GCC_VERSION == 4005
110462 + tree vars;
110463 +#else
110464 + unsigned int i;
110465 +#endif
110466 +
110467 + // split the first bb where we can put the forced initializers
110468 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110469 + if (dom_info_available_p(CDI_DOMINATORS))
110470 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110471 +
110472 + // enumarate all local variables and forcibly initialize our targets
110473 +#if BUILDING_GCC_VERSION == 4005
110474 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
110475 + var = TREE_VALUE(vars);
110476 +#else
110477 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
110478 +#endif
110479 + tree type = TREE_TYPE(var);
110480 +
110481 + gcc_assert(DECL_P(var));
110482 + if (!auto_var_in_fn_p(var, current_function_decl))
110483 + continue;
110484 +
110485 + // only care about structure types
110486 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
110487 + continue;
110488 +
110489 + // if the type is of interest, examine the variable
110490 + if (TYPE_USERSPACE(type))
110491 + initialize(var);
110492 + }
110493 +
110494 + return ret;
110495 +}
110496 +
110497 +static struct gimple_opt_pass structleak_pass = {
110498 + .pass = {
110499 + .type = GIMPLE_PASS,
110500 + .name = "structleak",
110501 +#if BUILDING_GCC_VERSION >= 4008
110502 + .optinfo_flags = OPTGROUP_NONE,
110503 +#endif
110504 + .gate = NULL,
110505 + .execute = handle_function,
110506 + .sub = NULL,
110507 + .next = NULL,
110508 + .static_pass_number = 0,
110509 + .tv_id = TV_NONE,
110510 + .properties_required = PROP_cfg,
110511 + .properties_provided = 0,
110512 + .properties_destroyed = 0,
110513 + .todo_flags_start = 0,
110514 + .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
110515 + }
110516 +};
110517 +
110518 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110519 +{
110520 + int i;
110521 + const char * const plugin_name = plugin_info->base_name;
110522 + const int argc = plugin_info->argc;
110523 + const struct plugin_argument * const argv = plugin_info->argv;
110524 + bool enable = true;
110525 +
110526 + struct register_pass_info structleak_pass_info = {
110527 + .pass = &structleak_pass.pass,
110528 + .reference_pass_name = "ssa",
110529 + .ref_pass_instance_number = 1,
110530 + .pos_op = PASS_POS_INSERT_AFTER
110531 + };
110532 +
110533 + if (!plugin_default_version_check(version, &gcc_version)) {
110534 + error(G_("incompatible gcc/plugin versions"));
110535 + return 1;
110536 + }
110537 +
110538 + if (strcmp(lang_hooks.name, "GNU C")) {
110539 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
110540 + enable = false;
110541 + }
110542 +
110543 + for (i = 0; i < argc; ++i) {
110544 + if (!strcmp(argv[i].key, "disable")) {
110545 + enable = false;
110546 + continue;
110547 + }
110548 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110549 + }
110550 +
110551 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
110552 + if (enable) {
110553 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
110554 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
110555 + }
110556 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110557 +
110558 + return 0;
110559 +}
110560 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
110561 index 280dd82..077b427 100644
110562 --- a/tools/lib/lk/Makefile
110563 +++ b/tools/lib/lk/Makefile
110564 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
110565
110566 LIBFILE = liblk.a
110567
110568 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110569 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110570 EXTLIBS = -lelf -lpthread -lrt -lm
110571 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
110572 ALL_LDFLAGS = $(LDFLAGS)
110573 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
110574 index 6789d78..4afd019e 100644
110575 --- a/tools/perf/util/include/asm/alternative-asm.h
110576 +++ b/tools/perf/util/include/asm/alternative-asm.h
110577 @@ -5,4 +5,7 @@
110578
110579 #define altinstruction_entry #
110580
110581 + .macro pax_force_retaddr rip=0, reload=0
110582 + .endm
110583 +
110584 #endif
110585 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
110586 index 96b919d..c49bb74 100644
110587 --- a/tools/perf/util/include/linux/compiler.h
110588 +++ b/tools/perf/util/include/linux/compiler.h
110589 @@ -18,4 +18,12 @@
110590 #define __force
110591 #endif
110592
110593 +#ifndef __size_overflow
110594 +# define __size_overflow(...)
110595 +#endif
110596 +
110597 +#ifndef __intentional_overflow
110598 +# define __intentional_overflow(...)
110599 +#endif
110600 +
110601 #endif
110602 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
110603 index 1580dd4..5627b5b 100644
110604 --- a/virt/kvm/kvm_main.c
110605 +++ b/virt/kvm/kvm_main.c
110606 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
110607
110608 static cpumask_var_t cpus_hardware_enabled;
110609 static int kvm_usage_count = 0;
110610 -static atomic_t hardware_enable_failed;
110611 +static atomic_unchecked_t hardware_enable_failed;
110612
110613 struct kmem_cache *kvm_vcpu_cache;
110614 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
110615
110616 -static __read_mostly struct preempt_ops kvm_preempt_ops;
110617 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
110618 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
110619 +static struct preempt_ops kvm_preempt_ops = {
110620 + .sched_in = kvm_sched_in,
110621 + .sched_out = kvm_sched_out,
110622 +};
110623
110624 struct dentry *kvm_debugfs_dir;
110625
110626 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
110627 /* We can read the guest memory with __xxx_user() later on. */
110628 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
110629 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
110630 - !access_ok(VERIFY_WRITE,
110631 + !__access_ok(VERIFY_WRITE,
110632 (void __user *)(unsigned long)mem->userspace_addr,
110633 mem->memory_size)))
110634 goto out;
110635 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
110636 return 0;
110637 }
110638
110639 -static struct file_operations kvm_vcpu_fops = {
110640 +static file_operations_no_const kvm_vcpu_fops __read_only = {
110641 .release = kvm_vcpu_release,
110642 .unlocked_ioctl = kvm_vcpu_ioctl,
110643 #ifdef CONFIG_COMPAT
110644 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
110645 return 0;
110646 }
110647
110648 -static struct file_operations kvm_vm_fops = {
110649 +static file_operations_no_const kvm_vm_fops __read_only = {
110650 .release = kvm_vm_release,
110651 .unlocked_ioctl = kvm_vm_ioctl,
110652 #ifdef CONFIG_COMPAT
110653 @@ -2662,7 +2667,7 @@ out:
110654 return r;
110655 }
110656
110657 -static struct file_operations kvm_chardev_ops = {
110658 +static file_operations_no_const kvm_chardev_ops __read_only = {
110659 .unlocked_ioctl = kvm_dev_ioctl,
110660 .compat_ioctl = kvm_dev_ioctl,
110661 .llseek = noop_llseek,
110662 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
110663
110664 if (r) {
110665 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
110666 - atomic_inc(&hardware_enable_failed);
110667 + atomic_inc_unchecked(&hardware_enable_failed);
110668 printk(KERN_INFO "kvm: enabling virtualization on "
110669 "CPU%d failed\n", cpu);
110670 }
110671 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
110672
110673 kvm_usage_count++;
110674 if (kvm_usage_count == 1) {
110675 - atomic_set(&hardware_enable_failed, 0);
110676 + atomic_set_unchecked(&hardware_enable_failed, 0);
110677 on_each_cpu(hardware_enable_nolock, NULL, 1);
110678
110679 - if (atomic_read(&hardware_enable_failed)) {
110680 + if (atomic_read_unchecked(&hardware_enable_failed)) {
110681 hardware_disable_all_nolock();
110682 r = -EBUSY;
110683 }
110684 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
110685 kvm_arch_vcpu_put(vcpu);
110686 }
110687
110688 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110689 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110690 struct module *module)
110691 {
110692 int r;
110693 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110694 if (!vcpu_align)
110695 vcpu_align = __alignof__(struct kvm_vcpu);
110696 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
110697 - 0, NULL);
110698 + SLAB_USERCOPY, NULL);
110699 if (!kvm_vcpu_cache) {
110700 r = -ENOMEM;
110701 goto out_free_3;
110702 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110703 if (r)
110704 goto out_free;
110705
110706 + pax_open_kernel();
110707 kvm_chardev_ops.owner = module;
110708 kvm_vm_fops.owner = module;
110709 kvm_vcpu_fops.owner = module;
110710 + pax_close_kernel();
110711
110712 r = misc_register(&kvm_dev);
110713 if (r) {
110714 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110715
110716 register_syscore_ops(&kvm_syscore_ops);
110717
110718 - kvm_preempt_ops.sched_in = kvm_sched_in;
110719 - kvm_preempt_ops.sched_out = kvm_sched_out;
110720 -
110721 r = kvm_init_debug();
110722 if (r) {
110723 printk(KERN_ERR "kvm: create debugfs files failed\n");